TuxLearnTuxLearn

Linux Commands

Essential commands organized by category for quick reference.

Showing 96 of 96 commands

Navigation

CommandDescription
pwdPrint current working directory
cd <dir>Change directory (cd .. for parent, cd ~ for home)
lsList directory contents
ls -laList all files (including hidden) with details
treeDisplay directory structure as a tree

File Management

CommandDescription
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

CommandDescription
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

CommandDescription
ip addrShow IP addresses for all interfaces
ip routeDisplay 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 -tulnpShow listening ports and associated processes
ss -tulnpModern 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 -LList firewall rules (legacy)
firewall-cmd --list-allList firewalld rules (RHEL/CentOS)
scp <src> <user@host:dst>Secure copy files over SSH

Process Management

CommandDescription
ps auxList all running processes
topReal-time process monitor (q to quit)
htopInteractive 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 / fgResume a job in background / foreground
jobsList 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

CommandDescription
df -hShow disk space usage (human-readable)
du -sh <dir>Show size of a directory
lsblkList block devices (disks, partitions)
fdisk -lList partition tables
mount <dev> <dir>Mount a filesystem
umount <dir>Unmount a filesystem
blkidShow block device attributes (UUID, type)
mkfs.ext4 <dev>Create an ext4 filesystem on a device

Archive & Compression

CommandDescription
tar -czvf <archive>.tar.gz <dir>Create a gzipped tar archive
tar -xzvf <archive>.tar.gzExtract 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>.zipExtract a zip archive
gzip <file> / gunzip <file>.gzCompress/decompress with gzip

User Management

CommandDescription
whoamiPrint 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
visudoSafely edit the sudoers file
lastShow recent login history
wShow who is logged in and what they are doing

System Info

CommandDescription
uname -aPrint kernel and system information
hostnameShow or set the system hostname
uptimeShow how long the system has been running
free -hDisplay memory usage (human-readable)
lscpuShow CPU architecture info
dmesg | tailView recent kernel ring buffer messages
cat /etc/os-releaseShow distribution name and version
envPrint all environment variables
dateDisplay or set the system date/time
timedatectlView and configure time/timezone settings

Package Management

CommandDescription
apt update && apt upgradeUpdate package lists and upgrade (Debian/Ubuntu)
apt install <pkg>Install a package (Debian/Ubuntu)
apt remove <pkg>Remove a package (Debian/Ubuntu)
dpkg -lList 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 -qaList all installed RPM packages
snap install <pkg>Install a snap package