Bash Cheatsheet

Other cheatsheets

Basic Terminal Shortcuts

$ CTRL L | Clear the terminal
$ CTRL D | Logout
$ SHIFT Page Up/Down | Go up/down the terminal
$ CTRL A | Cursor to start of line
$ CTRL E | Cursor the end of line
$ CTRL U | Delete left of the cursor
$ CTRL K | Delete right of the cursor
$ CTRL W | Delete word on the left
$ CTRL Y | Paste (after CTRL U,K or W)
$ TAB | Auto completion of file or command
$ CTRL R | Reverse search history
$ !! | Repeat last command

Back to top

Basic Terminal Navigation

$ ls -a | List all files and folders
$ ls <folder> | List all files in folder
$ cd <folder> | Change directory
$ cd / | Go to root
$ cd .. | Go up one folder
$ du -h | Disk usage of folders, human readable
$ du -ah | Disk usage of files and folders, human readable
$ pwd | Print working directory
$ man <command> | Shows manual

Back to top

Basic File Manipulation

$ cat <filename> | Show content of file
$ mkdir | Create a new folder
$ cp <file> <newFileName> | Copy and rename a file
$ cp <file> <folder>/ | Copy to folder
$ mv <file> <folder>/ | Move file in folder
$ mv <oldFileName> <newFileName> | Rename file
$ rm <file> .. | Delete file(s)
$ rm -i <file> .. | Ask for confirmation each file
$ rm -f <file> | Force deletion of a file
$ rm -f <folder>/ | Delete folder
$ touch <file> | Create or update a file

Back to top

Researching

$ locate <text> | Search content of all the files
$ locate <file> | Search for a file
$ find -name "<file>" | Search for a file
$ find -name "text" | Search for a file who starts with the word "text"
$ find -name "*text" | Search for a file who ends with the word "text"
$ grep <text> <file> | Search for text in file

Back to top

Process Management

$ w | Who is logged on and what they are doing
$ tload | Graphic representation of system load average
$ ps | Static process list
$ top | Dynamic process list
$ Ctrl+C | Stop a current terminal process
$ kill <PID #> | Kill a process
$ kill -9 <PID #> | Violent kill
$ killall | kill multiple process's
$ sudo halt | close computer
$ sudo reboot | Reboot

Back to top

User Accounts

$ sudo adduser <user> | Creates user
$ sudo passwd <user> | Change user's password
$ sudo deluser <user> | Delete user
$ addgroup <group> | Add anew user group
$ delgroup <group> | Delete a user group
$ usermod -g <group> <user> | Add user to the group

Back to top

File Permission

$ chown <user> <file> | Set user as the owner of the file
$ chmod | Modify user access and permission

Back to top

Installing Software

$ sudo apt-get install <software> | Install the software, download the package if needed

Back to top