When you open a terminal you are presented with a command prompt, waiting for you to input a command. It will look something like this:
username@computer-name:~$ |
It gives you information about:
-
Your username
-
The name of your computer
-
The location in your filesystem (~ indicates your home directory) A separator, usually $ symbol
-
The prompt (often blinking) waiting for your command input
The location of files in Unix is represented as a file path. For example:
/home/participant/Documents
Indicates the “Documents” folder of a user called “participant”. The first / at the beginning of the path indicates the root (or start) of the filesystem.
Paths can be specific in two ways:
Absolute path: specify the full path starting from the root. These paths always start with /.
Relative path: specify the path starting from your current location. For example, if you are located in /home/participant, the path Documents/resources would be equivalent to /home/participant/Documents/ resources. Relative paths never start with /.
Here are some key commands to navigate the filesystem:
Up Arrow: Will show your last commandDown Arrow: Will show your next commandTab: Will auto-complete your commandCtrl + L: Will clear the screenCtrl + C: Will cancel a commandCtrl + R: Will search for a commandCtrl + D: Will exit the terminal
Some of the commands to know for navigation:
pwdprints your current directorycdchanges directorylslists files and folders*is known as a “wildcard” and can be used to match multiple files
Here are some key commands to create directories and investigate the content of text files:
mkdircreates a directoryheadprints the top lines of a filetailprints the bottom lines of a filelessopens the file in a viewerwccounts lines, words and characters in a filegrepprints lines that match a specified text pattern
pwd # Print the current working directoryls reference/*.fasta
Only matches the files with .fasta extension.
clear # Clear the terminal screenkill process_name # Kill a process by namekill -9 process_name # Force kill a process by name