This is a very abridged summary of the Linux & Bash Tutorial, which we highly recommend you go through if you are unfamiliar with Linux.

1 - Useful Bash Commands

Purpose Example Notes
Change Directory $ cd path/to/directory .. to go up a directory
List Directory $ ls path/to/directory Path is optional
Show Current Directory $ pwd  
Print File Contents $ cat <filename>  
Display End of File $ tail -n <num_lines> <filename>  
Display Top of File $ head -n <num_lines> <filename>  
Monitor Changes to File $ tail -f <filename> CTRL+C to exit
Copy a File $ cp <src_file> <dest_file>  
Move a File $ mv <src_file> /new/path/  
Rename a File $ mv <src_file> <new_filename>  
Create New Directory $ mkdir path/to/<new_directory> Omit path to create in PWD
Delete File $ rm <filename> This is permanent!
Delete Empty Directory $ rmdir <empty_directory>  
Delete Directory and Contents $ rm -rf <directory> This is permanent!
Create Empty File $ touch path/to/<filename> Omit path to create in PWD
Find Files/Directories By Name $ find <path> <options>  
Search Inside Files $ grep <options> <pattern> <path>  
Sort Lines In File $ sort <filename>  
Filter Adjacent Matching Lines $ uniq <filename> Lines must be sorted first
View Help for Command $ man <command> $ command --help may also help
View Previous Commands $ history  
Clear Terminal Screen $ clear  
Monitor CPU/RAM/etc $ htop -u <abc1234>  
Monitor GPU $ nvidia-smi  
Check Storage Quota $ df -h /home/<abc1234> Also works for shared directories
Terminal Multiplexing $ tmux $ tmux attach to existing session
Current Timestamp $ date  
View Your Groups $ groups  
Add Permissions (Symbolic) $ chmod <u,g,o,a>+<r,w,x> <file/dir> -R for recursive
Remove Permissions (Symbolic) $ chmod <u,g,o,a>-<r,w,x> <file/dir> -R for recursive
Set Permissions (Symbolic) $ chmod <u,g,o,a>=<r,w,x> <file/dir> -R for recursive
Set Permissions (Octal) $ chmod <octal_code> <file/dir> -R for recursive
Change Owner $ chown <abc1234>:<group> <file/dir> -R for recursive (use caution)
Get Path to Command $ which <command>  
Connect to Remote Host $ ssh <abc1234>@<hostname>  

2 - Bash Syntax

Here is a cheatsheet for Bash syntax.

3 - Filesystem Permissions

There are three types of permissions that control access to files and directories.

  Files Directories
Read (r) View file contents View directory contents (ls)
Write (w) Modify file contents Create/rename/delete files/directories
Execute (x) Execute file cd into directory

There are also three levels of permissions:

  • Owner (u): The owner of the file/directory
  • Group (g): The group with permissions
  • Other (o): Everyone else

Example ls -l output:

An example of an 'ls -l' directory listing on Linux, with different permissions levels outlined in different colors: (1) Owner permissions outlined in red, (2) Group permissions outlined in green, and (3) Other permissions outlined in blue.


Tags: