Unix notes: Difference between revisions
No edit summary |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 23: | Line 23: | ||
In this guide, placeholders like `<something>` indicate where you should input specific text. For example, `<filename>` should be replaced with an actual file name, such as `MyFile.txt`. | In this guide, placeholders like `<something>` indicate where you should input specific text. For example, `<filename>` should be replaced with an actual file name, such as `MyFile.txt`. | ||
'''Naming Conventions''': | |||
* Avoid spaces and special characters in file and directory names. Use: | * Avoid spaces and special characters in file and directory names. Use: | ||
** `abcdefghijklmnopqrstuvwxyz` | |||
** `ABCDEFGHIJKLMNOPQRSTUVWXYZ` | |||
** `0123456789.-_` | |||
* Remember, UNIX is case-sensitive: `MyFile.txt` and `myfile.txt` are treated as distinct files. | * Remember, UNIX is case-sensitive: `MyFile.txt` and `myfile.txt` are treated as distinct files. | ||
* Although file extensions (like `.txt` or `.doc`) aren't required, using them helps identify file types. | * Although file extensions (like `.txt` or `.doc`) aren't required, using them helps identify file types. | ||
Line 56: | Line 57: | ||
This indicates that `gorm_directory` is a directory with: | This indicates that `gorm_directory` is a directory with: | ||
* '''User (`gorm`)''': Read, write, and execute permissions. | * '''User (`gorm`)''': Read, write, and execute permissions. | ||
* '''Group (`user`)''': Read and execute permissions. | * '''Group (`user`)''': Read and execute permissions. | ||
* '''Others''': Read and execute permissions. | * '''Others''': Read and execute permissions. | ||
'''Note on Directories''': | |||
* '''Write (`w`)''': Allows creating or deleting files within the directory. | * '''Write (`w`)''': Allows creating or deleting files within the directory. | ||
* '''Execute (`x`)''': Allows listing the directory's contents. If execute permission is missing, the directory will appear empty. | * '''Execute (`x`)''': Allows listing the directory's contents. If execute permission is missing, the directory will appear empty. | ||
Line 77: | Line 79: | ||
* Commands like `less` and `man` display information and wait for your input. Press `q` to exit these commands. | * Commands like `less` and `man` display information and wait for your input. Press `q` to exit these commands. | ||
For a summary of common UNIX commands and their usage, see the [ | For a summary of common UNIX commands and their usage, see the [https://teaching.healthtech.dtu.dk/unix/index.php/Commands_summary UNIX Commands Summary]. | ||
This guide is an introduction to the UNIX system, designed to help you understand the basics and gradually become proficient in using the command line. | This guide is an introduction to the UNIX system, designed to help you understand the basics and gradually become proficient in using the command line. |
Latest revision as of 15:59, 14 November 2024
Introduction to UNIX
UNIX refers to a family of multitasking, multi-user computer operating systems that originated from AT&T Unix, first developed in 1969 at Bell Labs by Ken Thompson, Dennis Ritchie, and others. These systems have influenced many modern operating systems and are known for their stability, flexibility, and robust command-line interface. Despite appearing complex at first, using UNIX-based systems efficiently provides a powerful way to manage and operate computing tasks.
Accessing UNIX
There are various ways to use UNIX depending on your operating system:
- Windows: Download and install [MobaXTerm](https://mobaxterm.mobatek.net/).
- Mac: macOS is built on a UNIX-based system, so you can use the built-in Terminal application.
- Linux: Most Linux distributions are based on UNIX, and the terminal is readily available.
Opening the terminal launches a shell where you can enter commands.
The Shell
The shell is the interface where you input commands. The prompt, which varies across systems, indicates that the shell is ready for your input. Examples of prompts include:
- `aix4(s010178) $`
- `interaction[pws]:/home/people/pws>`
- `pws@antros:~$`
Different shells and operating systems may have unique prompts and behaviors.
File System Basics
In this guide, placeholders like `<something>` indicate where you should input specific text. For example, `<filename>` should be replaced with an actual file name, such as `MyFile.txt`.
Naming Conventions:
- Avoid spaces and special characters in file and directory names. Use:
- `abcdefghijklmnopqrstuvwxyz`
- `ABCDEFGHIJKLMNOPQRSTUVWXYZ`
- `0123456789.-_`
- Remember, UNIX is case-sensitive: `MyFile.txt` and `myfile.txt` are treated as distinct files.
- Although file extensions (like `.txt` or `.doc`) aren't required, using them helps identify file types.
File Permissions
UNIX has a permission system that controls file and directory access:
- Three categories of users:
- User: The file's owner.
- Group: Users in the file's group.
- Others: Everyone else.
- Three types of permissions:
- Read (`r`): View the contents of the file.
- Write (`w`): Modify the file.
- Execute (`x`): Run the file as a program.
For example, running `ls -l` might yield:
-rwxr--r-- 1 root sys 113520 Sep 5 14:15 good_program
This indicates that `good_program` is a file with:
- User (`root`): Read, write, and execute permissions.
- Group (`sys`): Read permission only.
- Others: Read permission only.
For directories, a leading `d` denotes a directory:
drwxr-xr-x 6 gorm user 72 Jun 26 23:50 gorm_directory
This indicates that `gorm_directory` is a directory with:
- User (`gorm`): Read, write, and execute permissions.
- Group (`user`): Read and execute permissions.
- Others: Read and execute permissions.
Note on Directories:
- Write (`w`): Allows creating or deleting files within the directory.
- Execute (`x`): Allows listing the directory's contents. If execute permission is missing, the directory will appear empty.
Common UNIX Commands
Most UNIX commands come with options that modify their behavior. You can use the `man` command to read manual pages for detailed explanations:
man <command>
For example, `man ls` provides detailed information about the `ls` command.
Note:
- Many commands can be stopped with `Ctrl + C`.
- Commands like `less` and `man` display information and wait for your input. Press `q` to exit these commands.
For a summary of common UNIX commands and their usage, see the UNIX Commands Summary.
This guide is an introduction to the UNIX system, designed to help you understand the basics and gradually become proficient in using the command line.