Linux commands may seem intimidating at first glance if you do not use the terminal often. There are many commands for performing operations and processes on Linux systems.
Whether you are new to Linux or an experienced user, having a list of common commands close at hand is helpful. Something like a Cheat Sheet.
If you are configuring from the root user, the “sudo” command will not work and you will need to remove it from the command line you are typing.

File Commands
| Command | Description |
|---|---|
mkdir [directory_name] | Create a new directory. |
rm [file_name] | Remove a file. |
rm -r [directory_name] | Remove a directory recursively. |
rm -rf [directory_name] | Recursively remove a directory without requiring confirmation. |
cp [source_file] [destination_file] | Copy the contents of one file to another file using the cp command. |
cp -r [source_directory] [destination_directory] | Recursively copy a directory to a second directory. |
mv [source_file] [destination_file] | Move or rename files or directories. |
ln -s [path]/[file_name] [link_name] | Create a symbolic link to a file. |
touch [file_name] | Create a new file using touch. |
cat [file_name] | Show the contents of a file. |
cat [source_file] >> [destination_file] | Append file contents to another file. |
head [file_name] | Show the first ten lines of a file. |
tail [file_name] | Show the last ten lines of a file with the tail command. |
more [file_name] | Display contents of a file page by page. |
less [file_name] | Show the contents of a file with navigation using the less command. |
nano [file_name] | Open or create a file using the nano text editor. |
vi [file_name]vim [file_name] | Open or create a file using the Vi/Vim text editor. |
gpg -c [file_name] | Encrypt a file. |
gpg [file_name].gpg | Decrypt an encrypted .gpg file. |
wc -w [file_name] | Show the number of words, lines, and bytes in a file using wc. |
ls | xargs wc | List the number of lines/words/characters in each file in a directory with the xargs command. |
cut -d [delimiter] [file_name] | Cut a section of a file and print the result to standard output. |
[data] | cut -d [delimiter] | Cut a section of piped data and print the result to standard output. |
shred -u [file_name] | Overwrite a file to prevent its recovery, then delete it. |
diff [first_file] [second_file] | Compare two files and display differences. |
source [file_name] | Read and execute the file content in the current shell. |
[command] | tee [file_name] >/dev/null | Store the command output in a file and skip the terminal output. |
Directory Navigation Commands
| Navigation Commands | Description |
|---|---|
ls | List files and directories in the current directory. |
ls -a | List all files and directories in the current directory (shows hidden files). |
ls -l | List files and directories in long format. |
pwd | Show the directory you are currently working in. |
cdcd ~ | Change directory to $HOME. |
cd .. | Move up one directory level. |
cd - | Change to the previous directory. |
cd [directory_path] | Change location to a specified directory. |
dirs | Show current directory stack. |
File Compression Commands
| Command | Description |
|---|---|
tar cf [archive.tar] [file/directory] | Archive an existing file or directory. |
tar xf [archive.tar] | Extract an archived file. |
tar czf [archive.tar.gz] | Create a .gz compressed tar archive. |
gzip [file_name]gunzip [file_name.gz] | Compress or decompress .gz files. |
bzip2 [file_name]bunzip2 [file_name.bz2] | Compress or decompress .bz2 files. |
File Transfer Commands
| Command | Description |
|---|---|
scp [source_file] [user]@[remote_host]:[destination_path] | Copy a file to a server directory securely using the Linux scp command. |
rsync -a [source_directory] [user]@[remote_host]:[destination_directory] | Synchronize the contents of a directory with a backup directory using the rsync command. |
wget [link] | Download files from FTP or web servers via the wget command. |
curl -O [link] | Transfer data to or from a server with various protocols using the curl command. |
ftp [remote_host] | Transfer files between local and remote systems interactively using FTP. |
sftp [user]@[remote_host] | Securely transfer between local and remote hosts using SFTP. |
User and Group Commands
| Command | Description |
|---|---|
id | See details about the active users. |
last | Show the last system logins. |
who | Display who is currently logged into the system with the who command. |
w | Show which users are logged in and their activity with the w command. |
finger [user_name] | Show user information. |
sudo useradd [user_name] | Create a new user account. |
sudo adduser [user_name] | Create a new user account through the adduser command interface. |
sudo userdel [user_name] | Delete a user account. |
sudo usermod -aG [group_name] [user_name] | Modify user information (add a user to a group). |
passwdsudo passwd [user_name] | Change the current user’s password or another user’s password with the passwd command. |
sudo groupadd [group_name] | Add a new group. |
sudo groupdel [group_name] | Delete a group. |
sudo groupmod -n [new_name] [old_name] | Modify a user group (change group name). |
sudo [command] | Temporarily elevate user privileges to superuser or root using the sudo command. |
su - [user_name] | Switch the user account or become a superuser. |
chgrp [group_name] [file/directory] | Change file or directory group. |
Package Installation Commands
| Command | Description |
|---|---|
sudo apt-get install [package_name] | Install an APT package using the apt-get package utility. |
sudo apt install [package_name] | Install an APT package using a newer APT package manager. |
apt search [keyword] | Search for a package in the APT repositories. |
apt list | List packages installed with APT. |
apt show [package_name] | Show information about a package. |
sudo dpkg -i [package_name.deb] | Install a .deb package with the Debian package manager (dpkg command). |
sudo dpkg -l | List packages installed with dpkg. |
System Management and Information Commands
| Command | Description |
|---|---|
uname -r | Show system information via uname command. |
uname -a | See kernel release information. |
uptime | Display system uptime, including the load average. |
hostname | View system hostname. |
hostname -i / ip a | Show the IP address of the system. |
last reboot | List system reboot history. |
date | See current time and date. |
timedatectl | Query and change the system clock. |
cal | Show current calendar (month and day). |
w | List logged-in users. |
whoami | See which user you are using. |
finger [user_name] | Show information about a particular user. |
ulimit [flags] [limit] | View or limit system resource amounts. |
shutdown [hh:mm] | Schedule a system shutdown. |
shutdown now | Shut down the system immediately. |
modprobe [module_name] | Add a new kernel module. |
dmesg | Show bootup messages. |
SSH Login Commands
| Command | Description |
|---|---|
ssh [user_name]@[remote_host] | Connect to a remote host as a user via SSH. |
ssh [host] | Securely connect to a host via SSH default port 22. |
ssh -p [port] [user_name]@[remote_host] | Connect to the host using a particular port. |
ssh-keygen | Generate SSH key pairs. |
sudo service sshd start | Start SSH server daemon. |
scp [file_name] [user_name]@[remote_host]:[remote_path] | Securely copy files between local and remote systems via SSH. |
sftp [user_name]@[remote_host] | Interactive file transfer over encrypted SSH session using SFTP protocol. |
telnet [host] | Connect to the host via Telnet default port 23. |
Shell Command Management
| Command | Description |
|---|---|
alias [alias-name]='[command]' | Create an alias for a command. |
watch -n [interval-in-seconds] [command] | Set a custom interval to run a user-defined command. |
sleep [time-interval] && [command] | Postpone the execution of a command. |
at [hh:mm] | Create a job to be executed at a certain time (Ctrl+D to exit prompt after you type in the command). |
man [command] | Display a built-in manual for a command. |
history | Print the command history used in the terminal. |
Linux Shell Keyboard Shortcuts
| Shortcut | Description |
|---|---|
| Ctrl + C | Kill process running in the terminal. |
| Ctrl + Z | Stop the current process. The process can be resumed in the foreground with fg or in the background with bg. |
| Ctrl + W | Cut one word before the cursor and add it to the clipboard. |
| Ctrl + U | Cut part of the line before the cursor and add it to the clipboard. |
| Ctrl + K | Cut part of the line after the cursor and add it to the clipboard. |
| Ctrl + Y | Paste from clipboard. |
| Ctrl + R | Recall the last command that matches the provided characters. |
| Ctrl + O | Run the previously recalled command. |
| Ctrl + G | Exit command history without running a command. |
clear | Clear the terminal screen. |
!! | Run the last command again. |
exit | Log out of the current session. |
NETWORK PORTS
A network port is a logical communication endpoint used by computers to identify specific processes or network services.
When data is sent over the Internet or a local network, it includes both an IP address (which identifies the device) and a port number (which identifies the application or service).
Well-known ports (0 - 1023)
| Port | Protocol | Typical Service |
|---|---|---|
| 0 | — | Reserved |
| 1 | TCP | tcpmux |
| 5 | TCP | rje |
| 7 | TCP | echo |
| 9 | TCP | discard / wake-on-LAN |
| 11 | TCP | systat |
| 13 | TCP | daytime |
| 17 | TCP | qotd (quote of the day) |
| 19 | TCP | chargen |
| 20 | TCP | FTP data |
| 21 | TCP | FTP control |
| 22 | TCP | SSH |
| 23 | TCP | Telnet |
| 25 | TCP | SMTP |
| 37 | TCP | time |
| 38 | TCP | route access protocol |
| 39 | TCP | resource location protocol |
| 42 | TCP | WINS name service |
| 43 | TCP | whois |
| 49 | TCP | TACACS |
| 53 | TCP/UDP | DNS |
| 67 | UDP | DHCP (server) |
| 68 | UDP | DHCP (client) |
| 69 | UDP | TFTP |
| 70 | TCP | Gopher |
| 79 | TCP | Finger |
| 80 | TCP | HTTP |
| 88 | TCP | Kerberos |
| 102 | TCP | ISO-TSAP |
| 110 | TCP | POP3 |
| 111 | TCP/UDP | RPC / portmapper |
| 119 | TCP | NNTP |
| 123 | UDP | NTP |
| 135 | TCP | MS RPC endpoint mapper |
| 137 | UDP | NetBIOS name service |
| 138 | UDP | NetBIOS datagram |
| 139 | TCP | NetBIOS session |
| 143 | TCP | IMAP |
| 161 | UDP | SNMP |
| 162 | UDP | SNMP trap |
| 179 | TCP | BGP |
| 194 | TCP | IRC |
| 201 | TCP | AppleTalk routing |
| 389 | TCP/UDP | LDAP |
| 443 | TCP | HTTPS |
| 445 | TCP | SMB (Windows file sharing) |
| 465 | TCP | SMTPS |
| 514 | UDP | Syslog |
| 515 | TCP | LPD (printers) |
| 520 | UDP | RIP |
| 554 | TCP | RTSP |
| 587 | TCP | SMTP (submission) |
| 631 | TCP | IPP (impresión) |
| 636 | TCP | LDAPS |
| 873 | TCP | rsync |
| 989 | TCP | FTPS data |
| 990 | TCP | FTPS control |
| 993 | TCP | IMAPS |
| 995 | TCP | POP3S |
| 1023 | — | Last well-known port |
Registered ports (1024 - 49151)
| Port | Protocol | Typical Service |
|---|---|---|
| 1024 | TCP/UDP | Reserved / dynamic start |
| 1080 | TCP | SOCKS proxy |
| 1194 | UDP | OpenVPN |
| 1433 | TCP | Microsoft SQL Server |
| 1434 | UDP | Microsoft SQL Monitor |
| 1521 | TCP | Oracle Database listener |
| 1723 | TCP | PPTP (VPN) |
| 1812 | UDP | RADIUS authentication |
| 1813 | UDP | RADIUS accounting |
| 2049 | TCP/UDP | NFS (Network File System) |
| 2082 | TCP | cPanel (unsecured) |
| 2083 | TCP | cPanel (secure, SSL) |
| 2181 | TCP | Apache ZooKeeper |
| 2375 | TCP | Docker daemon (unsecured) |
| 2376 | TCP | Docker daemon (TLS secured) |
| 2483 | TCP | Oracle DB (TCP) |
| 2484 | TCP | Oracle DB (TCP over SSL) |
| 2600 | TCP | Zebra (routing daemon) |
| 3000 | TCP | Node.js / development servers |
| 3128 | TCP | Squid proxy |
| 3260 | TCP | iSCSI |
| 3306 | TCP | MySQL |
| 3389 | TCP | Microsoft RDP |
| 3690 | TCP | Subversion (SVN) |
| 4000 | TCP | ICQ / custom app use |
| 4369 | TCP | Erlang Port Mapper Daemon (epmd) |
| 5000 | TCP | UPnP / Flask development |
| 5432 | TCP | PostgreSQL |
| 5500 | TCP | VNC remote desktop |
| 5671 | TCP | AMQP over SSL |
| 5672 | TCP | AMQP (RabbitMQ) |
| 5900 | TCP | VNC |
| 5984 | TCP | CouchDB |
| 6000 | TCP | X11 |
| 6379 | TCP | Redis |
| 6660–6669 | TCP | IRC alternate ports |
| 6881–6889 | TCP | BitTorrent |
| 7000 | TCP | Cassandra / Vuze |
| 8000 | TCP | Alternate HTTP / web apps |
| 8080 | TCP | HTTP alternate / proxy |
| 8081 | TCP | Web admin interfaces |
| 8443 | TCP | HTTPS alternate (Tomcat, Spring Boot) |
| 8888 | TCP | Web testing / proxies |
| 9000 | TCP | SonarQube / PHP-FPM |
| 9090 | TCP | Web management / Prometheus |
| 9200 | TCP | Elasticsearch |
| 9300 | TCP | Elasticsearch (cluster) |
| 9418 | TCP | Git |
| 9999 | TCP | Misc. management interfaces |
| 10000 | TCP | Webmin |
| 11211 | TCP/UDP | Memcached |
| 27017 | TCP | MongoDB |
| 28017 | TCP | MongoDB HTTP interface |
| 37777 | TCP | Dahua DVR (CCTV systems) |
| 40000+ | TCP | Various vendor or application-specific services |
Dynamic / Private ports (49152 – 65535)
| Scenario | Source Port (Client) | Destination Port (Server) | Description |
|---|---|---|---|
| Web browsing | 50234 | 443 | Client → HTTPS server |
| Email client sending mail | 51723 | 587 | Client → SMTP submission |
| Database connection | 54872 | 3306 | Client → MySQL server |
| SSH client | 61002 | 22 | Client → Remote SSH server |
| DNS request (recursive) | 52000 | 53 | Client → DNS resolver |
| Operating System | Default Ephemeral Port Range |
|---|---|
| Windows (Vista and newer) | 49152–65535 |
| Linux (kernel 2.6.20+) | 32768–60999 |
| macOS / BSD | 49152–65535 |
| Older Windows (XP, 2003) | 1025–5000 |
| Feature | Description |
|---|---|
| Range | 49152–65535 |
| Total Ports | 16,384 |
| Type | Dynamic / Private / Ephemeral |
| Use | Temporary connections initiated by client systems |
| Registration | Not registered with IANA |
| Persistence | Exists only during active sessions |