Complete Linux commands reference with syntax, examples, and FAQs. 164 commands across 13 categories.
pwdPrints the current working directory (full path from root).
Syntax: pwd [options]
lsLists files and directories in the current directory.
Syntax: ls [options] [path]
cdChanges the current working directory to the specified path.
Syntax: cd [directory]
cd ..Moves up one directory level (to the parent directory).
Syntax: cd ..
cd ~Changes to the current user's home directory.
Syntax: cd ~
cd -Switches back to the previous working directory.
Syntax: cd -
pushdSaves the current directory and then changes to the specified directory.
Syntax: pushd [directory]
popdReturns to the directory saved by the last pushd command.
Syntax: popd
dirsDisplays the directory stack (list of directories saved with pushd).
Syntax: dirs [options]
mkdirCreates a new directory (folder). Use -p to create nested directories.
Syntax: mkdir [options] directory_name
touchCreates an empty file or updates the timestamp of an existing file.
Syntax: touch [options] filename
cpCopies files or directories from one location to another.
Syntax: cp [options] source destination
mvMoves or renames files and directories.
Syntax: mv [options] source destination
rmRemoves (deletes) files or directories. Use -rf for recursive force delete.
Syntax: rm [options] file
rmdirRemoves an empty directory. Safer than rm -r for removing directories.
Syntax: rmdir directory_name
catDisplays the entire contents of a file on the terminal.
Syntax: cat [options] filename
lessViews file contents page by page with forward and backward navigation.
Syntax: less filename
moreViews file contents one screen at a time (forward-only navigation).
Syntax: more filename
headDisplays the first 10 lines of a file by default. Use -n to specify count.
Syntax: head [options] filename
tailDisplays the last 10 lines of a file. Use -f to follow file changes in real time.
Syntax: tail [options] filename
nanoOpens a simple, beginner-friendly terminal text editor.
Syntax: nano filename
vimOpens the powerful Vim text editor for editing files.
Syntax: vim filename
wcCounts lines, words, and characters in a file.
Syntax: wc [options] filename
lnCreates links between files. Use -s for symbolic (soft) links.
Syntax: ln [options] source target
statDisplays detailed file and filesystem information (size, permissions, timestamps).
Syntax: stat filename
fileDetermines and displays the file type (text, binary, image, etc.).
Syntax: file filename
teeReads from stdin and writes to both stdout and one or more files simultaneously.
Syntax: command | tee filename
diffCompares two files line by line and shows the differences.
Syntax: diff [options] file1 file2
whoamiDisplays the username of the currently logged-in user.
Syntax: whoami
whoShows all users currently logged into the system with login details.
Syntax: who [options]
wDisplays who is logged in and what they are currently doing.
Syntax: w [username]
idPrints user and group IDs (UID, GID) for the specified or current user.
Syntax: id [username]
suSwitches to another user account or the root user.
Syntax: su [options] [username]
sudoExecutes a command with superuser (root) privileges.
Syntax: sudo command
passwdChanges the password for a user account.
Syntax: passwd [username]
useraddCreates a new user account on the system.
Syntax: useradd [options] username
usermodModifies an existing user account (groups, shell, home directory, etc.).
Syntax: usermod [options] username
userdelDeletes a user account. Use -r to also remove the home directory.
Syntax: userdel [options] username
groupaddCreates a new group on the system.
Syntax: groupadd groupname
groupdelDeletes an existing group from the system.
Syntax: groupdel groupname
groupsDisplays all groups the current user is a member of.
Syntax: groups [username]
lastShows the last logged-in users from the system log file.
Syntax: last [options]
chmodChanges the read, write, and execute permissions of files and directories.
Syntax: chmod [options] mode file
chownChanges the owner and/or group of a file or directory.
Syntax: chown [options] owner[:group] file
chgrpChanges the group ownership of a file or directory.
Syntax: chgrp [options] group file
umaskSets the default permission mask for newly created files and directories.
Syntax: umask [mode]
getfaclDisplays the Access Control List (ACL) of a file or directory.
Syntax: getfacl filename
setfaclSets or modifies the Access Control List (ACL) for a file or directory.
Syntax: setfacl [options] acl_spec file
sudo -lLists the allowed and forbidden sudo commands for the current user.
Syntax: sudo -l
visudoSafely edits the /etc/sudoers file to configure sudo permissions.
Syntax: sudo visudo
pingSends ICMP echo request packets to test network connectivity to a host.
Syntax: ping [options] host
ifconfigDisplays or configures network interface parameters (deprecated, use ip).
Syntax: ifconfig [interface]
ipModern replacement for ifconfig. Shows and manipulates routing, devices, and tunnels.
Syntax: ip [options] object command
netstatDisplays network connections, routing tables, interface statistics, and more.
Syntax: netstat [options]
ssModern replacement for netstat. Dumps socket statistics quickly.
Syntax: ss [options]
curlTransfers data from or to a server using various protocols (HTTP, FTP, etc.).
Syntax: curl [options] URL
wgetDownloads files from the internet non-interactively via HTTP, HTTPS, or FTP.
Syntax: wget [options] URL
digPerforms DNS lookups and displays detailed name server query information.
Syntax: dig [options] domain
nslookupQueries DNS servers to resolve domain names to IP addresses and vice versa.
Syntax: nslookup [domain]
hostSimple utility for performing DNS lookups (forward and reverse).
Syntax: host [options] name
tracerouteTraces and displays the route packets take to reach a network host.
Syntax: traceroute host
arpDisplays and modifies the system's ARP cache (IP-to-MAC address mappings).
Syntax: arp [options]
routeDisplays and modifies the IP routing table.
Syntax: route [options]
hostnameShows or sets the system's hostname.
Syntax: hostname [new-name]
iwconfigDisplays and configures wireless network interface parameters.
Syntax: iwconfig [interface]
nmapNetwork exploration tool and port scanner (basic usage).
Syntax: nmap [options] target
psReports a snapshot of current running processes with their PIDs.
Syntax: ps [options]
topDisplays an interactive, real-time view of system processes and resource usage.
Syntax: top
htopEnhanced, more user-friendly version of top with color and mouse support.
Syntax: htop
killSends a signal to terminate a process by its PID.
Syntax: kill [options] PID
killallKills all processes matching a given name.
Syntax: killall [options] process_name
pkillSends a signal to processes based on name and other attributes.
Syntax: pkill [options] pattern
bgResumes a suspended job in the background.
Syntax: bg [job_id]
fgBrings a background job to the foreground.
Syntax: fg [job_id]
jobsLists active jobs (background and suspended processes) in the current shell.
Syntax: jobs [options]
niceRuns a command with a specified scheduling priority (niceness value).
Syntax: nice -n priority command
reniceChanges the priority (niceness) of an already running process.
Syntax: renice priority -p PID
nohupRuns a command that keeps running even after the terminal session is closed.
Syntax: nohup command &
pgrepSearches for processes by name and returns their PIDs.
Syntax: pgrep [options] pattern
unamePrints system information such as kernel name, version, and architecture.
Syntax: uname [options]
uptimeShows how long the system has been running along with load averages.
Syntax: uptime
hostnamectlDisplays and changes the system hostname and related settings.
Syntax: hostnamectl [options]
lscpuDisplays detailed CPU architecture information.
Syntax: lscpu
lsblkLists information about all available block devices (disks and partitions).
Syntax: lsblk [options]
lspciLists all PCI devices connected to the system (graphics cards, network adapters).
Syntax: lspci [options]
lsusbLists all USB devices connected to the system.
Syntax: lsusb [options]
freeDisplays the amount of free and used system memory (RAM and swap).
Syntax: free [options]
vmstatReports virtual memory statistics including CPU, memory, and I/O.
Syntax: vmstat [options] [interval]
dmesgPrints the kernel ring buffer messages (boot-time and hardware diagnostics).
Syntax: dmesg [options]
lsmodLists all currently loaded kernel modules.
Syntax: lsmod
modinfoDisplays detailed information about a specific kernel module.
Syntax: modinfo module_name
envDisplays all current environment variables.
Syntax: env
echoPrints text or the value of variables to the terminal.
Syntax: echo [options] [string]
dateDisplays or sets the system date and time.
Syntax: date [options] [format]
calDisplays a calendar in the terminal.
Syntax: cal [month] [year]
historyShows the list of previously executed commands in the current shell session.
Syntax: history [n]
clearClears the terminal screen.
Syntax: clear
aliasCreates or displays command aliases (shortcuts for longer commands).
Syntax: alias [name='command']
unaliasRemoves a previously defined command alias.
Syntax: unalias name
apt updateUpdates the local package index with the latest information from repositories.
Syntax: apt update
apt upgradeUpgrades all installed packages to their latest available versions.
Syntax: apt upgrade
apt installInstalls one or more packages from the repository.
Syntax: apt install package_name
apt removeRemoves a package but keeps its configuration files.
Syntax: apt remove package_name
apt purgeRemoves a package along with all its configuration files.
Syntax: apt purge package_name
apt autoremoveRemoves packages that were automatically installed as dependencies and are no longer needed.
Syntax: apt autoremove
apt searchSearches for packages in the repository by keyword.
Syntax: apt search keyword
apt showDisplays detailed information about a specific package.
Syntax: apt show package_name
apt listLists packages based on package names with options for installed/upgradeable.
Syntax: apt list [options]
dpkg -iInstalls a .deb package file directly (does not resolve dependencies).
Syntax: dpkg -i package.deb
dpkg -rRemoves an installed package (keeps config files).
Syntax: dpkg -r package_name
dpkg -lLists all installed packages with version and description.
Syntax: dpkg -l [pattern]
snap installInstalls a snap package from the Snap Store.
Syntax: snap install package_name
pip installInstalls Python packages from the Python Package Index (PyPI).
Syntax: pip install package_name
tarArchives multiple files into a single tarball. Use -czf to compress with gzip.
Syntax: tar [options] archive_name files
gzipCompresses a single file using the gzip algorithm (replaces original with .gz).
Syntax: gzip [options] filename
gunzipDecompresses a .gz file back to its original form.
Syntax: gunzip filename.gz
bzip2Compresses files using the bzip2 algorithm (better compression than gzip, slower).
Syntax: bzip2 filename
bunzip2Decompresses a .bz2 file back to its original form.
Syntax: bunzip2 filename.bz2
zipCreates a compressed ZIP archive of files and directories.
Syntax: zip [options] archive.zip files
unzipExtracts files from a ZIP archive.
Syntax: unzip archive.zip
xzCompresses files using the xz (LZMA2) algorithm — very high compression ratio.
Syntax: xz filename
unxzDecompresses a .xz file back to its original form.
Syntax: unxz filename.xz
7zHigh-compression archiver supporting many formats (7z, zip, rar, tar, etc.).
Syntax: 7z a archive.7z files
sshConnects securely to a remote machine via the SSH protocol.
Syntax: ssh [options] user@host
scpSecurely copies files between local and remote hosts over SSH.
Syntax: scp [options] source destination
rsyncEfficiently syncs files and directories between two locations (local or remote).
Syntax: rsync [options] source destination
ftpTransfers files to and from a remote host using the File Transfer Protocol.
Syntax: ftp host
sftpSecurely transfers files over SSH (interactive FTP-like interface).
Syntax: sftp user@host
telnetConnects to a remote host via the Telnet protocol (unencrypted — prefer SSH).
Syntax: telnet host port
ssh-keygenGenerates SSH public/private key pairs for passwordless authentication.
Syntax: ssh-keygen [options]
ssh-copy-idCopies your SSH public key to a remote server for key-based authentication.
Syntax: ssh-copy-id user@host
findSearches for files and directories in a directory hierarchy by name, type, size, etc.
Syntax: find [path] [expression]
grepSearches for patterns (text or regex) inside files and prints matching lines.
Syntax: grep [options] pattern file
locateQuickly finds files by name using a pre-built database (run updatedb to refresh).
Syntax: locate [options] pattern
whichShows the full path of the executable that would run for a given command.
Syntax: which command
whereisLocates the binary, source, and manual page files for a command.
Syntax: whereis command
typeDisplays how a command name would be interpreted (alias, builtin, external, etc.).
Syntax: type command
awkPowerful text processing language for pattern scanning and data extraction.
Syntax: awk 'pattern { action }' file
sedStream editor for filtering and transforming text (find/replace, insert, delete).
Syntax: sed [options] 'command' file
sortSorts lines of text files alphabetically or numerically.
Syntax: sort [options] file
uniqReports or filters out repeated lines in a sorted file.
Syntax: uniq [options] file
cutExtracts specific columns/fields from each line of a file.
Syntax: cut [options] file
trTranslates, deletes, or squeezes characters from standard input.
Syntax: tr [options] set1 set2
xargsBuilds and executes command lines from standard input (useful with pipes).
Syntax: xargs [options] command
dfReports disk space usage for all mounted filesystems (human-readable with -h).
Syntax: df [options]
duEstimates file and directory space usage (disk usage).
Syntax: du [options] [path]
fdiskManipulates disk partition table (create, delete, resize partitions).
Syntax: fdisk [options] device
mountMounts a filesystem (attaches a device to the directory tree).
Syntax: mount [options] device mount_point
umountUnmounts a filesystem (detaches a mounted device from the directory tree).
Syntax: umount [options] mount_point
mkfsCreates a filesystem (formats) on a disk partition.
Syntax: mkfs -t type device
fsckChecks and optionally repairs a filesystem for errors.
Syntax: fsck [options] device
ddCopies and converts raw data at the block level (disk cloning, bootable USB creation).
Syntax: dd if=input of=output [options]
blkidDisplays block device attributes including UUID and filesystem type.
Syntax: blkid [device]
partedDisk partitioning tool (supports GPT and MBR partition tables).
Syntax: parted [options] device
ncduInteractive disk usage analyzer with a terminal UI (ncurses-based).
Syntax: ncdu [path]
systemctl startStarts a systemd service immediately.
Syntax: systemctl start service_name
systemctl stopStops a running systemd service immediately.
Syntax: systemctl stop service_name
systemctl restartStops and then starts a systemd service.
Syntax: systemctl restart service_name
systemctl enableEnables a service to start automatically at boot time.
Syntax: systemctl enable service_name
systemctl disableDisables a service from starting automatically at boot.
Syntax: systemctl disable service_name
systemctl statusShows the current status, recent logs, and PID of a systemd service.
Syntax: systemctl status service_name
systemctl list-unitsLists all loaded and active systemd units (services, mounts, sockets, etc.).
Syntax: systemctl list-units [options]
serviceLegacy command to run SysV init scripts (works on both SysV and systemd).
Syntax: service service_name action
journalctlQueries and displays logs from the systemd journal.
Syntax: journalctl [options]