File Commands
Command | Description |
cat | Print file contents |
touch | Create file (or update timestamp) |
cp | Copy a file |
mv | Move / rename a file |
rm | Remove file |
head | Print first 10 lines of file |
tail | Print last 10 lines of file |
tail -f | Print last 10 lines and new lines added to file |
Directory Commands
Command | Description |
ls | List files in the current directory |
ls -l | List files with details |
ls -a | List all files (including hidden) |
ls -al | List all files with details |
pwd | Print the current/working directory |
cd | Change current directory |
System Information Commands
Command | Description |
df | Show file system disk usage |
df -h | Show disk usage in MB/GB/TB |
du | Show disk usage per directory |
du -h | Show disk usage in MB/GB/TB |
free | Show memory usage |
free -h | Show memory usage in MB/GB/TB |
uptime | Show uptime |
whoami | Show current user |
uname | Show system information |
uname -a | Show all system information |
Shutdown/Reboot Commands
Command | Description |
shutdown | Power off the system after 1 minute |
shutdown now | Power off the system immediately |
shutdown 16:30 | Power off the system at 16:30 |
shutdown -c | Cancel a scheduled shutdown |
reboot | Reboot system |
poweroff | Power off system |
Process Commands
Command | Description |
ps | List processes |
ps -ef | List all processes |
top | Display processes in real-time |
kill | Kill process |
pkill | Kill process with name |
killall | Kill all processes with name |
Bash Shortcuts
Shortcut | Description |
Ctrl + C | Stop current command |
Ctrl + A | Go to beginning of line |
Ctrl + E | Go to end of line |
Ctrl + K | Cut current line |
Ctrl + L | Clear screen |
Secure Shell (SSH) Commands
Command | Description |
ssh-keygen | Generate SSH key pair |
ssh-add | Add SSH key to SSH agent |
ssh-add -l | List SSH keys in SSH agent |
ssh-copy-id @ | Copy SSH key to <user@host> |
ssh | Connect to <host> as current user |
ssh @ | Connect to <user@host> |
scp <file> <host>: | Copy local file <file> to <host> |
scp <host>:<file> | Copy file <file> from <host> to local |
APT Commands (Debian/Ubuntu)
Command | Description |
apt install | Install package |
apt remove | Remove package |
apt purge | Remove package and config files |
apt update | Update package list |
apt upgrade | Upgrade packages |
apt search | Search for package |
IO Redirection
Command | Description |
> | Replace contents of file with output |
>> | Append output to file |
< | Redirect input from file |
2> | Redirect stderr to file |
&> | Redirect stdout and stderr to file |
Pipe Commands
Command | Description | ||
<cmd1> | <cmd2> | Pipe stdout to next cmd | |
<cmd1> | &<cmd2> | Pipe stderr to next cmd |
Directory Structure
Directory | Description |
/ | Root |
/bin | Binary or executable programs |
/etc | System configuration files |
/home | User home directories |
/opt | Optional or third-party software |
/tmp | Temporary files |
/usr | User programs |
/var | Variable data |
/var/log | Log files |
Other Commands
Command | Description |
echo | Print message to stdout |
man | Display manual page for a command |
history | Display history of given commands |
which | Find path to executable |
whereis | Locate binary, source, and manual page for a command |