Unix notes: Difference between revisions

From 22126
Jump to navigation Jump to search
(Created page with "Certainly! Here's a Markdown version of the UNIX instructions from the provided PDF: # Using UNIX UNIX primarily operates through a command-line interface, allowing users to execute commands directly. While this may initially seem less intuitive than graphical interfaces, its power becomes evident with experience. ## Obtaining UNIX There are various methods to access UNIX: - **Windows**: Download and install [MobaXTerm](https://mobaxterm.mobatek.net/). - **Mac**: ma...")
 
No edit summary
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
Certainly! Here's a Markdown version of the UNIX instructions from the provided PDF:
=== Introduction to UNIX ===
UNIX refers to a family of multitasking, multi-user 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.


# Using UNIX
Although UNIX may appear complex at first, it provides powerful tools for working with large datasets and automating workflows. In bioinformatics and NGS analysis, most tools run exclusively on the command line, making UNIX an essential skill.


UNIX primarily operates through a command-line interface, allowing users to execute commands directly. While this may initially seem less intuitive than graphical interfaces, its power becomes evident with experience.
=== Accessing UNIX ===
There are various ways to use UNIX depending on your operating system:


## Obtaining UNIX
* '''Windows''': Download and install [https://mobaxterm.mobatek.net/ MobaXTerm].
* '''Mac''': macOS is UNIX-based; use the built-in Terminal application.
* '''Linux''': Most Linux distributions are UNIX-like and include a terminal by default.


There are various methods to access UNIX:
Opening the terminal launches a shell where you can enter commands.


- **Windows**: Download and install [MobaXTerm](https://mobaxterm.mobatek.net/).
=== The Shell ===
- **Mac**: macOS is built on UNIX. Use the built-in Terminal application.
The shell is the interface where you input commands. The prompt indicates the shell is ready for input. Examples include:
- **Linux**: Linux distributions are UNIX-based; the terminal is readily available.


Launching the terminal opens the shell, the command-line interface awaiting your input.
* `aix4(s010178) $`
* `interaction[pws]:/home/people/pws>`
* `pws@antros:~$`


## The Shell
Different systems and shells (bash, zsh, etc.) may show different prompts.


The shell is the command-line interface where you input commands. The prompt, which varies across systems, indicates readiness for your input. Examples include:
Useful shortcuts:
* Press '''TAB''' to autocomplete commands and file names.
* Press '''Up/Down arrows''' to scroll through command history.
* Press '''Ctrl + R''' to search command history.


- `aix4(s010178) $`
=== File System Basics ===
- `interaction[pws]:/home/people/pws>`
In this guide, placeholders like `<filename>` indicate where you must substitute actual names (e.g., replace `<filename>` with `mydata.txt`).
- `pws@antros:~$`


Different shells and operating systems may present unique prompts and behaviors.
'''Naming conventions:'''
* Avoid spaces and special characters in file and directory names.
* Safe characters include:
** `abcdefghijklmnopqrstuvwxyz`
** `ABCDEFGHIJKLMNOPQRSTUVWXYZ`
** `0123456789.-_`
* UNIX is case-sensitive: `MyFile.txt` and `myfile.txt` are different.
* File extensions are optional but recommended for clarity.


## The File System
Navigation commands:
* `pwd` — show current directory
* `ls -l` — list files with details
* `cd <directory>` — change directory
* `mkdir <name>` — create directory


In this guide, placeholders like `<something>` indicate where you should input specific text. For example, `<filename>` should be replaced with the actual file name, such as `MyFile.txt`.
Viewing files:
* `cat <file>`
* `less <file>`
* `head <file>`
* `tail <file>`


**Naming Conventions**:
Be extremely careful with:
* `rm` — deletes files permanently
* `rm -rf` — recursively deletes directories ('''no undo!''')


- Avoid spaces and special characters in file and directory names. Stick to:
=== File Permissions ===
  - `abcdefghijklmnopqrstuvwxyz`
UNIX uses a permission system controlling access to files and directories.
  - `ABCDEFGHIJKLMNOPQRSTUVWXYZ`
  - `0123456789.-_`
- UNIX is case-sensitive: `MyFile.txt` and `myfile.txt` are distinct files.
- While file extensions (e.g., `.doc`, `.txt`) aren't mandatory in UNIX, using them helps identify file types.


**File Permissions**:
Three user categories:
* '''User''' — the file's owner
* '''Group''' — users in the same group
* '''Others''' — everyone else


UNIX employs a permission system to control access:
Three permission types:
* '''Read''' (`r`)
* '''Write''' (`w`)
* '''Execute''' (`x`)


- Three user categories:
Example from `ls -l`:
  - **User**: The file owner.
<pre>
  - **Group**: Users in the file's group.
  - **Others**: All other users.
- Each category has three permissions:
  - **Read (`r`)**: View the file's contents.
  - **Write (`w`)**: Modify the file.
  - **Execute (`x`)**: Run the file as a program.
 
For example, the command `ls -l` might display:
 
```
-rwxr--r-- 1 root sys 113520 Sep 5 14:15 good_program
-rwxr--r-- 1 root sys 113520 Sep 5 14:15 good_program
```
</pre>


This indicates:
This means:
* User `root`: read, write, execute
* Group `sys`: read
* Others: read


- `good_program` is a file with:
Directory example:
  - User (`root`): Read, write, and execute permissions.
<pre>
  - Group (`sys`): Read permission.
  - Others: Read permission.
 
For directories, a leading `d` denotes a directory:
 
```
drwxr-xr-x 6 gorm user 72 Jun 26 23:50 gorm_directory
drwxr-xr-x 6 gorm user 72 Jun 26 23:50 gorm_directory
```
</pre>
 
Here:
 
- `gorm_directory` is a directory with:
  - User (`gorm`): Read, write, and execute permissions.
  - Group (`user`): Read and execute permissions.
  - Others: Read and execute permissions.
 
In directories:
 
- **Write (`w`)**: Allows creating or deleting files within the directory.
- **Execute (`x`)**: Permits listing the directory's contents. Without execute permission, the directory appears empty when listed.
 
## Common UNIX Commands


UNIX commands often have options that modify their behavior. Use the `man` command to access manual pages for detailed information:
Directory permissions:
* '''Read (r)''' — list directory contents
* '''Write (w)''' — create/delete files inside the directory
* '''Execute (x)''' — enter the directory (without x, directory looks empty)


```
=== Common UNIX Commands ===
man <command>
Most commands have options. Use `man <command>` to read manual pages.
```


For example, `man ls` provides details about the `ls` command.
Examples:
* `man ls`
* `man grep`


**Note**: Many commands can be terminated with `Ctrl + C`. Commands like `less` and `man` display information and await further input; press `q` to exit these commands.
Notes:
* Press '''q''' to exit `man`, `less`, and similar programs.
* Press '''Ctrl + C''' to interrupt running commands.


For a comprehensive list of common UNIX commands and their descriptions, refer to the [UNIX Commands Summary](https://teaching.healthtech.dtu.dk/unix/index.php/Commands_summary).
For a complete list of commands used in this course, see the
[https://teaching.healthtech.dtu.dk/unix/index.php/Commands_summary UNIX Commands Summary].


This guide offers a foundational understanding of UNIX. As you become more familiar with the command-line interface, you'll discover its efficiency and versatility.
This guide provides the basics; you will become more comfortable with UNIX as you use it throughout the exercises and project work.

Latest revision as of 15:36, 19 November 2025

Introduction to UNIX

UNIX refers to a family of multitasking, multi-user 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.

Although UNIX may appear complex at first, it provides powerful tools for working with large datasets and automating workflows. In bioinformatics and NGS analysis, most tools run exclusively on the command line, making UNIX an essential skill.

Accessing UNIX

There are various ways to use UNIX depending on your operating system:

  • Windows: Download and install MobaXTerm.
  • Mac: macOS is UNIX-based; use the built-in Terminal application.
  • Linux: Most Linux distributions are UNIX-like and include a terminal by default.

Opening the terminal launches a shell where you can enter commands.

The Shell

The shell is the interface where you input commands. The prompt indicates the shell is ready for input. Examples include:

  • `aix4(s010178) $`
  • `interaction[pws]:/home/people/pws>`
  • `pws@antros:~$`

Different systems and shells (bash, zsh, etc.) may show different prompts.

Useful shortcuts:

  • Press TAB to autocomplete commands and file names.
  • Press Up/Down arrows to scroll through command history.
  • Press Ctrl + R to search command history.

File System Basics

In this guide, placeholders like `<filename>` indicate where you must substitute actual names (e.g., replace `<filename>` with `mydata.txt`).

Naming conventions:

  • Avoid spaces and special characters in file and directory names.
  • Safe characters include:
    • `abcdefghijklmnopqrstuvwxyz`
    • `ABCDEFGHIJKLMNOPQRSTUVWXYZ`
    • `0123456789.-_`
  • UNIX is case-sensitive: `MyFile.txt` and `myfile.txt` are different.
  • File extensions are optional but recommended for clarity.

Navigation commands:

  • `pwd` — show current directory
  • `ls -l` — list files with details
  • `cd <directory>` — change directory
  • `mkdir <name>` — create directory

Viewing files:

  • `cat <file>`
  • `less <file>`
  • `head <file>`
  • `tail <file>`

Be extremely careful with:

  • `rm` — deletes files permanently
  • `rm -rf` — recursively deletes directories (no undo!)

File Permissions

UNIX uses a permission system controlling access to files and directories.

Three user categories:

  • User — the file's owner
  • Group — users in the same group
  • Others — everyone else

Three permission types:

  • Read (`r`)
  • Write (`w`)
  • Execute (`x`)

Example from `ls -l`:

-rwxr--r-- 1 root sys 113520 Sep 5 14:15 good_program

This means:

  • User `root`: read, write, execute
  • Group `sys`: read
  • Others: read

Directory example:

drwxr-xr-x 6 gorm user 72 Jun 26 23:50 gorm_directory

Directory permissions:

  • Read (r) — list directory contents
  • Write (w) — create/delete files inside the directory
  • Execute (x) — enter the directory (without x, directory looks empty)

Common UNIX Commands

Most commands have options. Use `man <command>` to read manual pages.

Examples:

  • `man ls`
  • `man grep`

Notes:

  • Press q to exit `man`, `less`, and similar programs.
  • Press Ctrl + C to interrupt running commands.

For a complete list of commands used in this course, see the UNIX Commands Summary.

This guide provides the basics; you will become more comfortable with UNIX as you use it throughout the exercises and project work.