Click on any topic to go there
- Navigation
- File Operations
- File Permissions
- Process Management
- Text Manipulation
- System Information
- Network
- Miscellaneous
cd [directory]
: Change directory- Example:
cd Documents
(change to the "Documents" directory)
- Example:
ls
: List files and directories- Example:
ls -l
(list files in long format)
- Example:
pwd
: Print working directory- Example:
pwd
(print current working directory)
- Example:
touch [filename]
: Create an empty file- Example:
touch file.txt
(create a new file named "file.txt")
- Example:
cp [source] [destination]
: Copy a file or directory- Example:
cp file.txt /path/to/directory/
(copy file.txt to a directory at specified path)
- Example:
mv [source] [destination]
: Move or rename a file or directory- Example:
mv file.txt newname.txt
(rename file.txt to newname.txt)
- Example:
rm [filename]
: Remove a file- Example:
rm file.txt
(remove file.txt)
- Example:
mkdir [directory]
: Create a directory- Example:
mkdir newdirectory
(create a directory named "newdirectory")
- Example:
rmdir [directory]
: Remove an empty directory- Example:
rmdir emptydirectory
(remove an empty directory named "emptydirectory")
- Example:
rm -r [directory]
: Remove a directory and its contents recursively- Example:
rm -r directory
(remove the "directory" and all its contents recursively)
- Example:
cat [filename]
: Display the contents of a file- Example:
cat file.txt
(display the contents of file.txt)
- Example:
head [filename]
: Display the first lines of a file- Example:
head -n 5 file.txt
(display the first 5 lines of file.txt)
- Example:
tail [filename]
: Display the last lines of a file- Example:
tail -n 10 file.txt
(display the last 10 lines of file.txt)
- Example:
chmod [permissions] [filename]
: Change file permissions- Example:
chmod 644 file.txt
(change the permissions of file.txt to read-write for owner and read-only for others)
- Example:
chown [owner:group] [filename]
: Change file owner and group- Example:
chown username:group file.txt
(change the owner of file.txt to "username" and the group to "group")
- Example:
ps
: List currently running processes- Example:
ps aux
(list all running processes and their details)
- Example:
kill [process_ID]
: Terminate a process- Example:
kill 1234
(terminate the process with ID 1234)
- Example:
bg
: Send a process to the background- Example:
bg %1
(send the job with ID 1 to the background)
- Example:
fg
: Bring a background process to the foreground- Example:
fg %1
(bring the job with ID 1 to the foreground)
- Example:
jobs
: List background jobs- Example:
jobs
(list all background jobs)
- Example:
grep [pattern] [filename]
: Search for a pattern in a file- Example:
grep "apple" fruits.txt
(search for the word "apple" in fruits.txt)
- Example:
sed [command] [filename]
: Stream editor for filtering and transforming text- Example:
sed 's/cat/dog/g' file.txt
(replace all occurrences of "cat" with "dog" in file.txt)
- Example:
awk [pattern] [filename]
: Text processing tool for pattern matching and data manipulation- Example:
awk '{print $1}' file.txt
(print the first column of data in file.txt)
- Example:
uname
: Print system information- Example:
uname -a
(print all system information)
- Example:
df
: Display disk space usage- Example:
df -h
(display disk space usage in human-readable format)
- Example:
free
: Display memory usage- Example:
free -h
(display memory usage in human-readable format)
- Example:
top
: Display real-time system statistics- Example:
top
(display real-time system statistics)
- Example:
history
: View command history- Example:
history
(display the command history)
- Example:
ping [hostname/IP]
: Test network connectivity to a host- Example:
ping google.com
(test network connectivity to google.com)
- Example:
nslookup [hostname]
: Look up the IP address of a domain name- Example:
nslookup google.com
(look up the IP address of google.com)
- Example:
ifconfig
: Display network interface configuration- Example:
ifconfig
(display network interface configuration)
- Example:
netstat
: Display network connections and listening ports- Example:
netstat -a
(display all network connections and listening ports)
- Example:
echo [text]
: Print text to the terminal- Example:
echo "Hello, world!"
(print "Hello, world!" to the terminal)
- Example:
date
: Display current date and time- Example:
date
(display the current date and time)
- Example:
whoami
: Print current user name- Example:
whoami
(print the current user name)
- Example:
sudo [command]
: Execute a command with superuser (root) privileges- Example:
sudo apt-get update
(execute "apt-get update" command with superuser privileges)
- Example:
man [command]
: Display manual page for a command- Example:
man ls
(display the manual page for the "ls" command)
- Example:
! [command_number]
: Execute a command from command history by its number- Example:
!25
(execute the command with number 25 from the command history)
- Example:
Click on any topic to go there
Shortcut | Description |
---|---|
Ctrl + A | Move cursor to the beginning of the line |
Ctrl + E | Move cursor to the end of the line |
Ctrl + B | Move cursor one character back |
Ctrl + F | Move cursor one character forward |
Alt + B | Move cursor one word back |
Alt + F | Move cursor one word forward |
Ctrl + U | Delete from cursor position to the beginning of the line |
Ctrl + K | Delete from cursor position to the end of the line |
Ctrl + W | Delete the word before the cursor |
Ctrl + Y | Paste the last deleted text |
Shortcut | Description |
---|---|
Ctrl + L | Clear the screen |
Ctrl + C | Interrupt current process |
Ctrl + D | Exit current shell or end input (EOF) |
Ctrl + R | Search command history |
Ctrl + G | Cancel current editing command |
Tab | Auto-complete file or directory names |
Up Arrow | Move to previous command in history |
Down Arrow | Move to next command in history |
Ctrl + P | Move to previous command in history (alternative) |
Ctrl + N | Move to next command in history (alternative) |
Ctrl + Z | Suspend current process |
fg | Resume suspended process in foreground |
bg | Resume suspended process in background |
jobs | List background processes |
Shortcut | Description |
---|---|
Ctrl + D | Log out of current session (equivalent to exit ) |
Ctrl + Alt + Del | Restart the system |
Ctrl + Alt + F1/F2/F3... | Switch to virtual terminal 1/2/3... |
Ctrl + Alt + F7 | Switch back to X window (if using virtual terminals) |
Ctrl + Alt + L | Lock the screen |
Note: These cheatsheets are not exhaustive; they cover some of the most commonly used commands and shortcuts. For more information, please refer to the Bash documentation and command manuals.