Unix notes: Difference between revisions

From 22126
Jump to navigation Jump to search
No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
=== Introduction to UNIX ===
=== Introduction to UNIX ===
UNIX refers to a family of multitasking, multi-user computer operating systems that originated from the 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.
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 ===
=== Accessing UNIX ===
There are various ways to use UNIX depending on your operating system:
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.
* '''Windows''': Download and install [MobaXTerm](https://mobaxterm.mobatek.net/).
- **Linux**: Most Linux distributions are based on UNIX, and the terminal is readily available.
* '''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.
Opening the terminal launches a shell where you can enter commands.


=== The Shell ===
=== 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:
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) $`
* `aix4(s010178) $`
- `interaction[pws]:/home/people/pws>`
* `interaction[pws]:/home/people/pws>`
- `pws@antros:~$`
* `pws@antros:~$`


Different shells and operating systems may have unique prompts and behaviors.
Different shells and operating systems may have unique prompts and behaviors.
Line 21: 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**:
'''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`
  - `ABCDEFGHIJKLMNOPQRSTUVWXYZ`
** `ABCDEFGHIJKLMNOPQRSTUVWXYZ`
  - `0123456789.-_`
** `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.
* 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 ===
=== File Permissions ===
UNIX has a permission system that controls file and directory access:
UNIX has a permission system that controls file and directory access:
- Three categories of users:
* Three categories of users:
  - **User**: The file's owner.
** '''User''': The file's owner.
  - **Group**: Users in the file's group.
** '''Group''': Users in the file's group.
  - **Others**: Everyone else.
** '''Others''': Everyone else.
- Three types of permissions:
* Three types of permissions:
  - **Read (`r`)**: View the contents of the file.
** '''Read''' (`r`): View the contents of the file.
  - **Write (`w`)**: Modify the file.
** '''Write''' (`w`): Modify the file.
  - **Execute (`x`)**: Run the file as a program.
** '''Execute''' (`x`): Run the file as a program.


For example, running `ls -l` might yield:
For example, running `ls -l` might yield:
Line 45: Line 48:


This indicates that `good_program` is a file with:
This indicates that `good_program` is a file with:
- **User (`root`)**: Read, write, and execute permissions.
* '''User (`root`)''': Read, write, and execute permissions.
- **Group (`sys`)**: Read permission only.
* '''Group (`sys`)''': Read permission only.
- **Others**: Read permission only.
* '''Others''': Read permission only.


For directories, a leading `d` denotes a directory:
For directories, a leading `d` denotes a directory:
Line 54: 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.
- **Group (`user`)**: Read and execute permissions.
- **Others**: Read and execute permissions.


**Note on Directories**:
* '''User (`gorm`)''': Read, write, and execute permissions.
- **Write (`w`)**: Allows creating or deleting files within the directory.
* '''Group (`user`)''': Read and execute permissions.
- **Execute (`x`)**: Allows listing the directory's contents. If execute permission is missing, the directory will appear empty.
* '''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 ===
=== 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:
Most UNIX commands come with options that modify their behavior. You can use the `man` command to read manual pages for detailed explanations:


Line 70: Line 75:
For example, `man ls` provides detailed information about the `ls` command.
For example, `man ls` provides detailed information about the `ls` command.


**Note**:
'''Note''':
- Many commands can be stopped with `Ctrl + C`.
* 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.
* 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](https://teaching.healthtech.dtu.dk/unix/index.php/Commands_summary).
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.