Linux Commands
Essential commands organized by category for quick reference.
Showing 96 of 96 commands
Navigation
| Command | Description |
|---|---|
| pwd | Print current working directory |
| cd <dir> | Change directory (cd .. for parent, cd ~ for home) |
| ls | List directory contents |
| ls -la | List all files (including hidden) with details |
| tree | Display directory structure as a tree |
File Management
| Command | Description |
|---|---|
| cp <src> <dst> | Copy file or directory (-r for recursive) |
| mv <src> <dst> | Move or rename a file/directory |
| rm <file> | Remove a file (-r for directory, -f to force) |
| mkdir <dir> | Create a directory (-p for nested paths) |
| rmdir <dir> | Remove an empty directory |
| touch <file> | Create an empty file or update timestamps |
| cat <file> | Display file contents |
| head -n <N> <file> | Show first N lines of a file |
| tail -n <N> <file> | Show last N lines (-f to follow in real time) |
| less <file> | View file with scrollable pager |
| find <path> -name <pattern> | Search for files by name or criteria |
| locate <name> | Fast file search using pre-built index |
| ln -s <target> <link> | Create a symbolic link |
| stat <file> | Display detailed file/filesystem information |
Permissions
| Command | Description |
|---|---|
| chmod <mode> <file> | Change file permissions (e.g., 755, u+x) |
| chown <user>:<group> <file> | Change file owner and/or group |
| chgrp <group> <file> | Change group ownership |
| umask <mask> | Set default permission mask for new files |
| getfacl <file> | View Access Control List (ACL) for a file |
| setfacl -m u:<user>:rwx <file> | Set ACL entry for a specific user |
Networking
| Command | Description |
|---|---|
| ip addr | Show IP addresses for all interfaces |
| ip route | Display or modify the routing table |
| ping <host> | Send ICMP echo requests to test connectivity |
| traceroute <host> | Trace the route packets take to a host |
| netstat -tulnp | Show listening ports and associated processes |
| ss -tulnp | Modern replacement for netstat — socket statistics |
| curl <url> | Transfer data from or to a server |
| wget <url> | Download files from the web |
| dig <domain> | DNS lookup utility |
| nslookup <domain> | Query DNS name servers |
| nmap <target> | Network scanner — discover hosts and services |
| iptables -L | List firewall rules (legacy) |
| firewall-cmd --list-all | List firewalld rules (RHEL/CentOS) |
| scp <src> <user@host:dst> | Secure copy files over SSH |
Process Management
| Command | Description |
|---|---|
| ps aux | List all running processes |
| top | Real-time process monitor (q to quit) |
| htop | Interactive process viewer (enhanced top) |
| kill <PID> | Send signal to a process (default: SIGTERM) |
| kill -9 <PID> | Force-kill a process (SIGKILL) |
| killall <name> | Kill all processes by name |
| bg / fg | Resume a job in background / foreground |
| jobs | List background jobs in current shell |
| nice -n <val> <cmd> | Run command with modified scheduling priority |
| renice <val> -p <PID> | Change priority of a running process |
| systemctl status <svc> | Check status of a systemd service |
| systemctl start|stop|restart <svc> | Manage a systemd service |
| journalctl -u <svc> | View logs for a systemd service |
Disk & Storage
| Command | Description |
|---|---|
| df -h | Show disk space usage (human-readable) |
| du -sh <dir> | Show size of a directory |
| lsblk | List block devices (disks, partitions) |
| fdisk -l | List partition tables |
| mount <dev> <dir> | Mount a filesystem |
| umount <dir> | Unmount a filesystem |
| blkid | Show block device attributes (UUID, type) |
| mkfs.ext4 <dev> | Create an ext4 filesystem on a device |
Archive & Compression
| Command | Description |
|---|---|
| tar -czvf <archive>.tar.gz <dir> | Create a gzipped tar archive |
| tar -xzvf <archive>.tar.gz | Extract a gzipped tar archive |
| tar -cjvf <archive>.tar.bz2 <dir> | Create a bzip2 tar archive |
| zip -r <archive>.zip <dir> | Create a zip archive |
| unzip <archive>.zip | Extract a zip archive |
| gzip <file> / gunzip <file>.gz | Compress/decompress with gzip |
User Management
| Command | Description |
|---|---|
| whoami | Print current username |
| id <user> | Show user ID, group ID, and groups |
| useradd <user> | Create a new user account |
| usermod -aG <group> <user> | Add user to a supplementary group |
| userdel -r <user> | Delete a user and their home directory |
| passwd <user> | Change a user password |
| groupadd <group> | Create a new group |
| su - <user> | Switch user (login shell) |
| sudo <cmd> | Run command as root or another user |
| visudo | Safely edit the sudoers file |
| last | Show recent login history |
| w | Show who is logged in and what they are doing |
System Info
| Command | Description |
|---|---|
| uname -a | Print kernel and system information |
| hostname | Show or set the system hostname |
| uptime | Show how long the system has been running |
| free -h | Display memory usage (human-readable) |
| lscpu | Show CPU architecture info |
| dmesg | tail | View recent kernel ring buffer messages |
| cat /etc/os-release | Show distribution name and version |
| env | Print all environment variables |
| date | Display or set the system date/time |
| timedatectl | View and configure time/timezone settings |
Package Management
| Command | Description |
|---|---|
| apt update && apt upgrade | Update package lists and upgrade (Debian/Ubuntu) |
| apt install <pkg> | Install a package (Debian/Ubuntu) |
| apt remove <pkg> | Remove a package (Debian/Ubuntu) |
| dpkg -l | List all installed packages (Debian/Ubuntu) |
| yum install <pkg> | Install a package (RHEL/CentOS 7) |
| dnf install <pkg> | Install a package (RHEL/CentOS 8+, Fedora) |
| rpm -qa | List all installed RPM packages |
| snap install <pkg> | Install a snap package |