🐧 Linux Command Line
Basic and advanced commands for navigation, files, processes, networking, monitoring, packages and automation. Suited for DevOps workflows.
🔹 Basic commands
| Command | Example | Description | 
|---|---|---|
| cat | Show file content or concatenate multiple files | |
| cat file.txt | View file content | |
| cat file1 file2 | Concatenate and output two files | |
| cat file1 file2 > merged.txt | Concatenate files and save to a new file | |
| cd | Change the current working directory | |
| cd /etc | Go to absolute path  | |
| cd ~ | Go to the home directory | |
| cd .. | Move one level up | |
| cd - | Return to the previous directory | |
| clear | Clear the terminal screen | |
| cp | Copy files and directories | |
| cp file1.txt file2.txt | Copy a file with a new name | |
| cp -r dir1 dir2 | Recursively copy a directory | |
| cp -i file.txt /tmp/ | Copy with confirmation before overwrite | |
| echo | Print a string or environment variable | |
| echo "Hello, World!" | Print a simple string | |
| echo $HOME | Show the home directory path | |
| echo -e "1\t2\n3" | Interpret escape sequences ( ) | |
| history | Display command history | |
| id | Show UID, GID and group memberships of the current user | |
| ls | List files and directories | |
| ls -l | Long listing with permissions and owners | |
| ls -a | Show hidden files | |
| ls -lh | Human-readable sizes | |
| mkdir | Create directories | |
| mkdir folder | Create a single directory | |
| mkdir -p a/b/c | Create nested directories | |
| mkdir dir{1,2,3} | Create multiple directories at once | |
| mv | Move or rename files/directories | |
| mv oldname.txt newname.txt | Rename a file | |
| mv file.txt /path/to/dir/ | Move a file to another directory | |
| mv *.txt archive/ | Move all  | |
| pwd | Print the current working directory | |
| pwd -P | Show the physical path (no symlinks) | |
| cd /tmp && pwd | Show path after changing to  | |
| rm | Remove files or directories | |
| rm file.txt | Delete a file | |
| rm -i file.txt | Delete a file with confirmation | |
| rm -r folder/ | Recursively delete a directory | |
| rm -rf folder/ | Force delete without confirmation | |
| rmdir | Remove an empty directory | |
| rmdir emptydir | Remove the  | |
| touch | Create empty files or update modification time | |
| touch newfile.txt | Create a new empty file if it doesn’t exist | |
| touch a b c | Create multiple files at once | |
| touch -c file.txt | Update time without creating a file if absent | |
| whereis | Locate the binary, source and man pages of a command | |
| whereis ls | Find locations for  | |
| whereis bash | Show paths for Bash binary and docs | |
| whereis -b bash | Search for the binary only | |
| which | Show the path of the command executable | |
| which python3 | Path to  | |
| which grep | Path to  | |
| which --skip-alias ls | Skip aliases while searching | |
| whoami | Print the effective user name | 
🔸 Intermediate level
| Command | Example | Description | 
|---|---|---|
| chmod | Change file or directory permissions | |
| chmod 755 file | Set permissions with octal notation (e.g. 755) | |
| chmod +x script.sh | Add the execute bit to a script | |
| chmod -R 644 dir/ | Recursively set permissions on a directory | |
| chown | Change file owner and group | |
| chown user file | Change the owner of a file | |
| chown user:group file | Change owner and group | |
| chown -R user:group dir/ | Recursively change owner and group | |
| curl | Transfer data from/to a server (HTTP, HTTPS, etc.) | |
| curl -I https://example.com | Send a HEAD request (headers only) | |
| curl -O https://example.com/file.txt | Download a file and keep its name | |
| curl -d "a=1&b=2" -X POST URL | Send a POST request with form data | |
| df | Report file system disk space usage | |
| df -h | Human-readable sizes | |
| df /home | Usage of a specific mount point | |
| df -T | Show file system types | |
| diff | Compare files or directories | |
| diff file1 file2 | Compare two files | |
| diff -u old.c new.c | Unified diff (patch-style) | |
| diff -r dir1 dir2 | Recursive directory comparison | |
| du | Estimate file and directory space usage | |
| du -sh * | Show size of items in the current directory | |
| du -h file.txt | Show size of a single file | |
| du -sh --max-depth=1 /var | Summarize sizes of top-level subdirs | |
| find | Search for files/directories by name, size, time, etc. | |
| find . -name "*.log" | Find all  | |
| find / -type f -size +100M | Find files larger than 100 MB | |
| find . -mtime -1 | Files modified within the last day | |
| free | Display the amount of free and used memory | |
| free -h | Human-readable memory units | |
| free -m | Show values in MB | |
| watch -n 2 free -h | Refresh output every 2 seconds | |
| grep | Search text using patterns (regular expressions) | |
| grep "error" logfile | Find lines containing  | |
| grep -r "error" /var/log | Recursive search in a directory | |
| grep -i "fail" file | Case-insensitive search | |
| head | Output the first lines of a file | |
| head -n 10 file | First 10 lines | |
| head -n 20 file.txt | First 20 lines | |
| head -c 100 file | First 100 bytes | |
| hostname | Show or set the system’s host name | |
| hostname newname | Temporarily set the host name until reboot | |
| hostname -I | Show IP addresses | |
| kill | Send signals to processes | |
| kill -9 1234 | Force-kill a process by PID | |
| kill -TERM 1234 | Terminate gracefully with SIGTERM | |
| pkill -f python | Kill processes matching a pattern | |
| ping | Check network connectivity using ICMP echo requests | |
| ping 8.8.8.8 | Ping an address | |
| ping -c 4 ya.ru | Send 4 packets | |
| ping -i 2 1.1.1.1 | Set a 2-second interval | |
| ps | Report process status | |
| ps aux | List all processes | |
| ps -ef | grep nginx | Filter by name using  | |
| ps -u $USER | Processes of the current user | |
| rsync | Fast incremental file transfer | |
| rsync -av src/ dst/ | Synchronize directories locally | |
| rsync -avz user@host:/src /dst | Sync with a remote host over SSH | |
| rsync --delete src/ dst/ | Delete files in dest missing in src | |
| scp | Secure copy (remote file copy program) | |
| scp file user@host:/path | Copy a file to a remote host | |
| scp user@host:/file.txt . | Copy a file from a remote host | |
| scp -r dir user@host:/path | Recursively copy a directory | |
| sort | Sort lines of text | |
| sort file.txt | Alphabetical sort | |
| sort -r file.txt | Reverse order | |
| sort -n numbers.txt | Numeric sort | |
| tail | Output the last part of files; follow changes | |
| tail -f logfile.log | Follow a log in real time | |
| tail -n 20 file.txt | Show the last 20 lines | |
| tail -c 100 file.txt | Show the last 100 bytes | |
| tar | Create, list or extract tar archives | |
| tar -czf archive.tgz dir/ | Create a compressed  | |
| tar -xzf archive.tgz | Extract a  | |
| tar -tf archive.tgz | List archive contents | |
| tee | Read from stdin and write to stdout and files | |
| echo "test" | tee out.txt | Write output to  | |
| ls | tee list.txt | Save  | |
| command | tee -a log.txt | Append output to the end of  | |
| top | Display Linux tasks (interactive process viewer) | |
| top | Start top | |
| htop | Alternative interactive viewer (htop) | |
| top -o %MEM | Sort by memory usage | |
| uptime | Show how long the system has been running | |
| uptime -p | Pretty uptime | |
| uptime -s | System boot time | |
| wget | Non-interactive network downloader | |
| wget https://site.com/file.zip | Download a file by URL | |
| wget -c file.zip | Resume an interrupted download | |
| wget -O saved.txt URL | Save with a different filename | |
| wc | Print line, word, and byte counts for files | |
| wc -l file | Count lines | |
| wc -w file | Count words | |
| wc -m file | Count characters | |
| uniq | Report or filter out repeated lines (adjacent duplicates) | |
| uniq file.txt | Remove adjacent duplicates | |
| sort file | uniq | Remove duplicates after sort | |
| sort file | uniq -c | Count occurrences of each line | |
| yes | Output a string repeatedly until killed; useful for scripting | |
| yes "y" | command | Always answer “y” to prompts | |
| yes | rm -i * | Auto-confirm interactive deletions | |
| yes no | command | Answer “no” to prompts | 
🔧 Advanced commands
| Command | Example | Description | 
|---|---|---|
| at | Schedule a one-time command to run at a given time | |
| at now + 1 minute | Run a command one minute from now | |
| atq | List pending jobs | |
| atrm | Remove a pending job | |
| awk | Pattern-scanning and processing language | |
| awk '{print $1}' file | Print the first column | |
| ps aux | awk '$3 > 50' | Filter processes by CPU usage | |
| cat file.txt | awk '{print $2}' | Print the second field from each line | |
| awk '/error/ {print $0}' logfile | Print lines matching a pattern | |
| crontab | Install, list, or remove per-user cron jobs | |
| crontab -e | Edit current user’s crontab | |
| crontab -l | List cron jobs | |
| crontab -r | Remove current user’s crontab | |
| cut | Remove or select sections from each line of files | |
| cut -d':' -f1 /etc/passwd | Print usernames from  | |
| echo "a:b:c" | cut -d':' -f2 | Cut the second field using ‘:’ as delimiter | |
| cut -c1-5 filename | Select characters by position | |
| df | Report file system disk space usage | |
| df -h | Human-readable sizes | |
| df -T | Show file system types | |
| df /home | Usage for the home directory | |
| env | Run a command in a modified environment or print env | |
| env | grep PATH | Show PATH entries | |
| env -i bash | Start a clean shell with an empty environment | |
| export | Set environment variables for the current shell/session | |
| export VAR=value | Set a variable for this shell | |
| export PATH=$PATH:/new/path | Append a directory to PATH | |
| export -p | List exported variables | |
| free | Display memory usage | |
| free -m | Show in MB | |
| free -h | Human-readable units | |
| free -s 5 | Sample every 5 seconds | |
| hostnamectl | Query and change the system host name and related settings | |
| hostnamectl status | Show host name status | |
| hostnamectl set-hostname newname | Set a new static host name | |
| ifconfig/ip | IP tools to view/manage interfaces and addresses | |
| ifconfig | Show network interfaces (legacy) | |
| ip a | Show addresses with  | |
| ip link set eth0 up | Bring an interface up | |
| iostat | Report CPU and I/O statistics | |
| iostat -x 2 | Extended stats every 2 seconds | |
| iostat -d 5 3 | Device statistics (5s interval, 3 reports) | |
| iptables | Administration tool for IPv4 packet filtering and NAT | |
| iptables -L | List current rules | |
| iptables -A INPUT -p tcp --dport 22 -j ACCEPT | Allow incoming SSH on port 22 | |
| iptables -F | Flush all rules | |
| journalctl | Query the systemd journal | |
| journalctl -xe | Show recent errors with context | |
| journalctl -u nginx.service | Show logs for a service | |
| journalctl --since "2 hours ago" | Show logs since a relative time | |
| ln | Make links between files | |
| ln -s target link | Create a symbolic link | |
| ln file.txt backup.txt | Create a hard link | |
| ln -sf target link | Force recreate a symbolic link | |
| sed | Stream editor for filtering and transforming text | |
| sed 's/old/new/g' file | Replace a string globally | |
| sed -n '1,5p' file | Print only a range of lines | |
| sed '/pattern/d' file | Delete matching lines | |
| systemctl | Control the systemd system and service manager | |
| systemctl status nginx | Show service status | |
| systemctl start nginx | Start a service | |
| systemctl enable nginx | Enable a service on boot | |
| tr | Translate or delete characters | |
| tr a-z A-Z | Convert lowercase to uppercase | |
| echo "hello" | tr 'h' 'H' | Replace a character | |
| echo "abc123" | tr -d '0-9' | Delete digits | |
| type | Describe how a name would be interpreted in the shell | |
| type ls | Show how  | |
| type cd | Show how  | |
| type python3 | Show how  | |
| ulimit | Get or set user process resource limits | |
| ulimit -n | Show max open files | |
| ulimit -c unlimited | Enable core dumps | |
| ulimit -u 4096 | Limit the number of user processes | |
| uptime | Show system uptime and average load | |
| uptime -p | Pretty uptime | |
| uptime -s | Show boot time | |
| xargs | Build and execute command lines from standard input | |
| xargs -n 1 echo | Echo each argument on a separate line | |
| echo "a b c" | xargs -n 1 | Split words into separate args | |
| find . -name '*.txt' | xargs rm | Find files and remove them with xargs | 
🌐 Network commands
| Command | Example | Description | 
|---|---|---|
| curl | Transfer data to/from servers | |
| curl -X POST -d "a=1" URL | POST request with form data | |
| curl -I URL | Fetch headers only | |
| curl -o file.html URL | Download and save to a file | |
| dig | DNS lookup utility | |
| dig openai.com | Query A records | |
| dig +short openai.com | Short answer | |
| dig @8.8.8.8 openai.com | Use a specific DNS server | |
| ftp | File Transfer Protocol client | |
| ftp host | Connect to an FTP server | |
| ftp -n host | Connect without auto-login | |
| ftp> get file.txt | Download a file in an FTP session | |
| ip address | Show/manipulate IP addresses | |
| ip addr show eth0 | Show address info for  | |
| ip addr | List all addresses | |
| ip link | Show/manipulate network devices | |
| ip link show | Show network links | |
| ip link set eth0 up | Bring an interface up | |
| ip route | Show/manipulate the IP routing table | |
| ip route list | List routing table | |
| ip route add default via 192.168.1.1 | Add a default route | |
| nc | Arbitrary TCP/UDP connections and listens | |
| nc -zv host 22 | Port scan a host | |
| nc -l 1234 | Listen on a TCP port | |
| nc host 1234 < file | Send a file to a remote port | |
| nmap | Network exploration tool and security/port scanner | |
| nmap -sP 192.168.1.0/24 | Ping scan a subnet | |
| nmap -sV 192.168.1.1 | Service/version detection | |
| nmap -O 192.168.1.1 | OS detection | |
| nslookup | Query Internet domain name servers | |
| nslookup google.com | Query a domain name | |
| nslookup 8.8.8.8 | Reverse lookup for an IP | |
| ssh | OpenSSH remote login client | |
| ssh user@host | Connect to a host | |
| ssh -p 2222 user@host | Connect using a non-default port | |
| ssh -i ~/.ssh/id_rsa user@host | Login with a specific private key | |
| ss | Utility to investigate sockets | |
| ss -tuln | List TCP/UDP listening ports | |
| ss -s | Summary statistics | |
| ss -l | List listening sockets | |
| telnet | User interface to the TELNET protocol | |
| telnet host 80 | Connect to a host on port 80 | |
| telnet example.com 443 | Connect to 443 | |
| telnet localhost 25 | Connect to local SMTP | |
| traceroute | Trace the route to a network host | |
| traceroute 8.8.8.8 | Trace path to an IP | |
| traceroute -m 15 8.8.8.8 | Limit max hops | |
| wget | Retrieve files from the web | |
| wget -O file.txt URL | Save output to a file | |
| wget URL | Download to current directory | |
| wget -c URL | Continue a partial download | 
🔍 Searching and managing files
| Command | Example | Description | 
|---|---|---|
| basename | Strip directory and suffix from filenames | |
| basename /path/to/file | Print the filename from a path | |
| basename /path/to/file .txt | Strip a suffix from the name | |
| dirname | Strip last component from a path | |
| dirname /path/to/file | Show directory part of the path | |
| dirname /etc/passwd | Show parent of  | |
| du | Estimate file space usage | |
| du -sh folder/ | Show size of a directory | |
| du -h * | Show size of items in current directory | |
| du -c folder1 folder2 | Cumulative size of multiple dirs | |
| file | Determine file type | |
| file some.bin | Detect file type | |
| file * | Detect types for all files in dir | |
| file -i file.txt | Show MIME type | |
| find | Search for files | |
| find /path -type f -name "*.sh" | Find shell scripts by name | |
| find . -size +10M | Find files larger than 10 MB | |
| find /tmp -mtime -1 | Find files modified in last day | |
| locate | Find files by name using database | |
| locate filename | Locate a filename | |
| locate *.conf | Wildcard search | |
| locate -i README | Case-insensitive search | |
| realpath | Print the resolved absolute path | |
| realpath file | Resolve a file path | |
| realpath ../relative/path | Resolve a relative path | |
| stat | Display file or file system status | |
| stat file | Show detailed file status | |
| stat -c %s file | Print file size only | |
| stat -f file | Show file system status | |
| tree | List contents of directories in a tree-like format | |
| tree | Print directory tree | |
| tree -L 2 | Limit the display depth | |
| tree -a | Include hidden files | 
📊 System monitoring
| Command | Example | Description | 
|---|---|---|
| dmesg | Print or control the kernel ring buffer | |
| dmesg | tail | Show the last kernel messages | |
| dmesg | grep usb | Filter for USB messages | |
| free | Display memory usage | |
| free -h | Human-readable units | |
| free -m | Show in MB | |
| htop | Interactive process viewer | |
| htop | Run  | |
| iotop | Display I/O usage by processes | |
| iotop | Run  | |
| iotop -o | Show only processes doing I/O | |
| lsof | List open files | |
| lsof -i :80 | Show processes using port 80 | |
| lsof -u username | Show files open by a user | |
| uptime | Show system uptime and load averages | |
| vmstat | Report virtual memory statistics | |
| vmstat 1 | Refresh every 1 second | |
| vmstat 5 3 | Five-second interval, 3 reports | |
| watch | Execute a program periodically, showing output | |
| watch -n 1 df -h | Watch disk usage | |
| watch -d free -h | Highlight differences and watch memory | 
📦 Package management
| Command | Example | Description | 
|---|---|---|
| apt | APT package manager (Debian/Ubuntu) | |
| apt install curl | Install a package | |
| apt remove curl | Remove a package | |
| apt update && apt upgrade | Update package lists and upgrade | |
| dnf | Dandified YUM (Fedora/RHEL family) | |
| dnf install curl | Install a package | |
| dnf upgrade | Upgrade packages | |
| rpm | RPM package manager | |
| rpm -ivh package.rpm | Install an RPM package | |
| rpm -e package | Erase (uninstall) a package | |
| snap | Snappy package manager | |
| snap install app | Install a snap | |
| snap remove app | Remove a snap | |
| yum | Yellowdog Updater Modified (RHEL/CentOS) | |
| yum install curl | Install a package | |
| yum remove curl | Remove a package | 
💽 File systems
| Command | Example | Description | 
|---|---|---|
| blkid | Locate/print block device attributes | |
| blkid | List block devices and attributes | |
| df | Report file system disk space usage | |
| df -Th | Human-readable sizes by type | |
| fsck | Check and repair a Linux file system | |
| fsck /dev/sda1 | Check a device | |
| lsblk | List information about block devices | |
| lsblk | List devices in a tree | |
| mkfs | Build a Linux file system | |
| mkfs.ext4 /dev/sdb1 | Create an ext4 file system | |
| mount | Mount a file system | |
| mount /dev/sdb1 /mnt | Mount a device to  | |
| mount | grep /mnt | Show mounted file systems filtered by path | |
| parted | Partition manipulation program | |
| parted /dev/sdb | Open a disk for partitioning | |
| umount | Unmount file systems | |
| umount /mnt | Unmount a mount point | 
🤖 Scripts and automation
| Command | Example | Description | 
|---|---|---|
| alias | Define or display shell aliases | |
| alias ll='ls -la' | Create a handy alias | |
| alias | List defined aliases | |
| bash/sh | Run shell scripts | |
| bash script.sh | Run a script with Bash | |
| sh script.sh | Run a script with  | |
| crontab | Per-user cron tables | |
| crontab -e | Edit current user’s crontab | |
| read | Prompt for user input in shell scripts | |
| read name | Read into a variable | |
| set | Set shell options/positional parameters | |
| set -e | Exit on first error | |
| source | Read and execute commands from a file in the current shell | |
| source ~/.bashrc | Reload shell configuration | |
| trap | Trap signals and execute commands | |
| trap "echo 'exit'" EXIT | Run a command on shell exit | 
🛠 Development and debugging
| Command | Example | Description | 
|---|---|---|
| gcc | GNU C compiler | |
| gcc main.c -o app | Compile a C source file | |
| gdb | GNU debugger | |
| gdb ./app | Debug a compiled binary | |
| git | Distributed version control system | |
| git status | Show status of the working tree | |
| git commit -m "msg" | Commit with a message | |
| ltrace | Library call tracer | |
| ltrace ./app | Trace library calls of a binary | |
| make | Utility to maintain groups of programs | |
| make | Build according to Makefile | |
| shellcheck | Static analysis for shell scripts | |
| shellcheck script.sh | Lint a shell script | |
| strace | Trace system calls and signals | |
| strace ./app | Trace a program’s syscalls | |
| valgrind | Instrumentation framework for building dynamic analysis tools | |
| valgrind ./app | Run a program under Valgrind | |
| vim/nano | Command-line text editors | |
| vim file.sh | Edit with Vim | |
| nano file.sh | Edit with Nano | 
📌 Miscellaneous
| Command | Example | Description | 
|---|---|---|
| cal | Display a calendar | |
| cal 2025 | Show a year calendar | |
| cal 08 2025 | Show a specific month | |
| date | Display or set the system date and time | |
| date +%T | Print current time (HH:MM:SS) | |
| date -d "next friday" | Print date for a relative day | |
| factor | Factor integers | |
| factor 100 | Factorize a number | |
| man | Format and display the on-line manual pages | |
| man tar | Open a man page | |
| man -k copy | Search manuals by keyword | |
| man 5 passwd | Open a specific manual section | |
| seq | Print sequences of numbers | |
| seq 1 5 | Count from 1 to 5 | |
| seq 1 2 9 | Count with step | |
| seq -s ',' 1 5 | Join numbers with a custom separator | |
| yes | Output a string repeatedly until killed | |
| yes | rm -r dir | Auto-confirm a recursive removal | 
📚 Additional resources
📘 man pages - detailed manuals for commands:
man ls
man rm📙 TLDR - concise usage examples of popular commands:
🧠 Tip: Install tldr for cheat-sheet-style help:
sudo apt install tldr   # or: npm install -g tldr
tldr tar                # example of a short summary for the tar command🌐 Useful links
Linux man pages online — official manual pages, searchable by command name:
https://man7.org/linux/man-pages/
Simplified and community-driven man pages — community-driven help pages with practical examples:
https://tldr.sh/