Essential Linux Commands: A Practical Reference by Task

Frequently used Linux commands are organized according to practical tasks such as file management, text processing, users and permissions, processes, system, disk, network, and package management. You can quickly find the basic usage of commands, and for commands with links, click on the name to check detailed usage and examples.

Even the same command may have different supported options depending on the distribution and installed packages. On an actual system, it is recommended to check the current environment's description using man command or command --help.

How to find Linux commands

If you do not know the exact syntax or execution location of a command, try using the following commands.

man ls
ls --help
type cd
command -v python

Help and shell environment commands

Command Overview
man View the manual pages of commands, configuration files, and system calls.
info Reads detailed Info documents of GNU programs.
help Displays help for Bash built-in commands such as cd and read.
apropos Searches keywords in the manual description to find related commands.
whatis Shows a short description from the manual about what a command does.
type Checks whether a name is an alias, function, shell built-in command, or executable file.
command Avoids name conflicts with shell functions when executing a command or checks the execution location with -v.
history Used to check or re-execute the history of commands previously run in the current shell.
alias Assigns short aliases to frequently used long commands.
unalias Removes the command aliases set in the current shell.
clear Clears the terminal screen.
watch Repeatedly executes the specified command at regular intervals to observe changes in the results.
time Measures the actual execution time and CPU usage time of a command.
env Displays environment variables or runs a command with temporary environment variables.
printenv Outputs the values of all environment variables or specified environment variables.

Commands for changing directories and obtaining file information.

Command Overview
pwd Prints the absolute path of the current working directory.
ls Check the list of files and directories, permissions, owner, and size, etc.
cd Change the current working directory to another path.
tree Display the directory and file structure in a tree form. Installation may be required separately.
file Estimate the file type by inspecting the file contents instead of the extension.
stat Display detailed file size, permissions, inode, and access/modification times.
basename Extract only the last file or directory name from a full path.
dirname Extract the directory path excluding the last component from a full path.
realpath Output the absolute path by resolving relative paths and symbolic links.
readlink Check the target path that the symbolic link points to.

File and directory management commands

Command Overview
touch Create an empty file or change the access/modification times of an existing file.
mkdir Create a new directory.
rmdir Delete an empty directory.
cp Copy files or directories to another location.
mv Move or rename files and directories.
rm Delete files or directories. The deletion does not go to the recycle bin, so carefully check the target.
ln Create a hard link or symbolic link of a file.
install Copy a file while setting the owner, permissions, and target directory.
shred Overwrite file content multiple times and then delete it, but effectiveness may be limited depending on the type of storage device and file system.
mktemp Safely create temporary files or temporary directories that avoid name conflicts.
truncate Truncate or extend a file to the specified size.
dd Copy or convert data in blocks. If the target device is incorrectly specified, data may be lost.
Command Overview
cat Display file contents or concatenate multiple files.
tac Prints in reverse order from the last line of the file.
less Reads large files page by page while moving up and down and searching.
more Checks the contents of a file sequentially, one screen at a time.
head Checks the beginning part of a file or command output.
tail Prints the last part of a file, and with the -f option, you can continuously monitor log changes.
grep Finds lines in a file or command output that match a string or regular expression.
find Searches for files in a specified path using conditions such as name, type, size, permissions, and modification time.
locate Quickly finds paths by searching a pre-built file database.
which Finds the path of a program that will be executed from PATH. type is more suitable for checking aliases or shell functions.
whereis Searches for a command's executable, source, and manual page location.
diff Compares the differences between two files or directories line by line.
cmp Compares two files byte by byte to find the first different location.

Text processing commands

Command Overview
wc Counts the number of lines, words, characters, and bytes in files or input.
sort Sorts text lines based on characters, numbers, or specified columns.
uniq Removes adjacent duplicate lines or counts the number of duplicates.
cut Extract fields from each line based on the specified character range or delimiter.
paste Combine corresponding lines from multiple files horizontally.
join Join lines of two text files sorted based on common fields.
comm Compare two sorted files to distinguish common lines and lines unique to each file.
tr Replace characters in the input with other characters or remove repeated characters and specific characters.
tee Display the input on the screen while also saving it to a file.
xargs Convert items received via standard input into arguments for another command and execute it.
sed Perform search, replace, delete, and line selection operations in a text stream.
awk Analyze text by field and calculate or output according to conditions.
column Arrange delimited text into an easy-to-read column format.
split Split large files into multiple files based on size or number of lines.
csplit Split files based on line numbers or the positions where patterns appear.
fmt Readjust the line length of general text paragraphs to make them easier to read.
fold Split long input lines into multiple lines according to a specified width.
printf Output strings and numbers in a specified format.

User and permission commands

Command Overview
whoami Prints the name of the user executing the current command.
id Checks user ID, default group, and supplementary group information.
who Displays the users currently logged into the system and their login terminals.
w Shows logged-in users, running tasks, and system load together.
last Checks login and logout records.
groups Prints the groups the current or specified user belongs to.
passwd Changes or manages user passwords.
sudo Allows authorized users to execute commands as other users, usually with root privileges.
su Switch the current shell to another user account.
chmod Change the read, write, and execute permissions of files and directories.
chown Change the owner or owning group of files and directories.
chgrp Change the owning group of files and directories.
umask Check or set the default permission limit values that will be applied to new files and directories.
getent Query entries in the Name Service Switch database, such as users, groups, and hosts.

Process and terminal session commands

Command Overview
ps Check the ID, user, status, and execution command of currently running processes.
top Check CPU and memory usage by process in real time.
htop View and manage processes in an interactive screen. Separate installation may be required.
pgrep Search for process IDs by process name and conditions.
pkill Send a signal to processes matching the name or conditions.
kill Send a signal such as a termination request by specifying a process ID.
killall Send a signal to processes that match the specified name.
jobs Check background and stopped jobs executed in the current shell.
bg Continue running stopped shell jobs in the background.
fg Brings a background or stopped shell job to the foreground.
nohup Runs a command so that it ignores the hangup signal and does not terminate even after the terminal is closed.
nice Runs by adjusting the CPU scheduling priority of a new process.
renice Changes the CPU scheduling priority of a running process.
screen Creates multiple virtual sessions in one terminal and allows detaching and reconnecting.
tmux A terminal multiplexer that manages multiple shell windows and panels, and allows detaching and reconnecting sessions.

System information and service commands

Command Overview
uptime Checks system uptime, the number of logged-in users, and average load.
free Check the total capacity and usage status of physical memory and swap space.
uname Display information such as the currently running kernel release and hardware architecture.
hostnamectl In a systemd environment, check the host name, distribution, kernel, and architecture information or set the host name.
date Display the current date and time or output them in a specified format.
timedatectl In a systemd environment, manage time, time zones, and network time synchronization status.
lscpu Display CPU architecture, cores, threads, and virtualization information.
lsmod Check the list of modules currently loaded in the kernel and their usage status.
modinfo Check the file location, description, version, and parameters of kernel modules.
dmesg Check the boot, hardware, and driver messages in the kernel ring buffer.
systemctl Check the status of systemd services and other units, and start, stop, or enable them.
journalctl View system and service logs stored in the systemd journal.
reboot Safely restart the system. You should first check running tasks and other users.
shutdown Schedule a system shutdown or restart immediately or at a specified time.

Disk and filesystem commands

Command Overview
df Check the total capacity and available space for each mounted filesystem.
du Calculate the disk usage of files and directories.
lsblk Check the hierarchy of disks, partitions, and logical volumes, as well as their mount points.
blkid Query the UUID, file system type, and label of block devices.
mount Mount a file system to a specified directory or check the current mount status.
umount Safely unmount a mounted file system.
fdisk Mainly check or edit the partition table of MBR and GPT disks. You should verify the target disk before making changes.
parted Create partitions on various partition tables and manage their size and location.
mkfs Create a new file system on a partition or device. Existing data may be lost.
fsck Check for errors in a file system and recover them if necessary. First, check the status of the target file system.
sync Requests that file system write data remaining in memory be reflected on the storage device.

Network commands

Command Overview
ip Checks or configures network interfaces, IP addresses, routing, and neighbor tables.
ss Checks TCP/UDP sockets, receiving ports, and connection status.
ping Sends ICMP packets to check whether the target host responds and measures round-trip time.
tracepath Investigates the network path and maximum transmission unit (MTU) to the destination.
traceroute Traces the router path that packets take to reach the destination.
dig Queries records from DNS servers and examines the responses in detail.
host Briefly query DNS information for domain names and IP addresses.
nslookup Query domain or IP address information on a DNS server.
curl Request or send data using various protocols such as HTTP through a URL.
wget Download files from web and FTP addresses and perform recursive downloads.
nc Use Netcat to perform TCP/UDP connections, port checks, and simple data transfers.
nmap Investigate hosts, open ports, and service information of authorized targets.
ethtool Check link speed, driver, and feature settings of an Ethernet interface.
resolvectl Check DNS settings and query status in a systemd-resolved environment.

Remote Access and File Transfer Commands

Command Overview
ssh Log in to a remote system or execute remote commands through an encrypted SSH connection.
scp Copy files between local and remote systems using an SSH connection.
sftp Use an interactive file transfer session based on SSH.
rsync Efficiently synchronize local or remote directories focusing on changed files.
ssh-keygen Create SSH public and private key pairs and manage key fingerprints.
ssh-copy-id Add a public key to the authorized keys list of a remote account.

Compression and archiving commands

Command Overview
tar Combine or extract multiple files and directories into a single archive, and use it with compression tools.
gzip Compress files in gzip format.
gunzip Extract files compressed with gzip.
bzip2 Compress files in bzip2 format.
bunzip2 Extract files compressed with bzip2.
xz Compress files in xz format.
unxz Extract files compressed with xz.
zip Compress files and directories in ZIP format.
unzip Check the list of a ZIP archive or extract it.

Package management commands

Package management commands vary depending on the distribution. You should check the current distribution with cat /etc/os-release and use the appropriate tool.

Command Overview
apt User commands used in Debian/Ubuntu systems to search, install, remove, and upgrade packages.
apt-get APT commands widely used in Debian/Ubuntu systems for scripts and detailed package operations.
dpkg Performs local DEB package installation and package database queries on Debian-based systems.
dnf Manages packages and repositories on Fedora/RHEL/Rocky Linux/AlmaLinux systems.
rpm Queries or manages RPM package files and the installed package database.
zypper Manage packages and repositories on openSUSE and SUSE Linux Enterprise.
pacman Install and remove packages and update the system on Arch Linux-based distributions.
apk Search, install, remove packages, and refresh repository information on Alpine Linux.

Points to check when using commands

  • For commands that modify or delete data, such as rm, dd, mkfs, fdisk, first check the target path and device.
  • Use sudo only for necessary commands, and do not run commands as administrator if you do not understand them.
  • Check with man and --help whether options found on the internet exist on your current system.
  • Commands or options may not exist depending on the distribution, program version, and installed packages.

Refer to official documents

This list is a starting point for quickly finding commands. In actual use, it is safer to check each command's basic syntax, commonly used options, execution examples, and cautions before using it.

More in This Category
Linux Tutorial / File Permissions and Safe sudo Use

Linux Tutorial / File Permissions and Safe sudo Use

Learn to read file and directory permissions, practice chmod safely, and understand when to use sudo and how to diagnose access errors.

Linux which Command: Find Executables in PATH

Linux which Command: Find Executables in PATH

Learn how Linux which searches PATH for executables, shows all matching paths, differs from type and command -v, and should be used carefully in scripts.

Linux find Command: Search Files by Name, Type, Size, and Time

Linux find Command: Search Files by Name, Type, Size, and Time

Learn how to search with Linux find by name, file type, size, and modification time, combine expressions, run commands safely, and verify targets before deletion.

Linux mv Command: Move and Rename Files and Directories

Linux mv Command: Move and Rename Files and Directories

Learn how to move and rename files or directories with Linux mv, avoid unwanted overwrites, clarify destination paths, and handle cross-filesystem moves.

Linux sync Command: Flush Buffered Writes to Storage

Linux sync Command: Flush Buffered Writes to Storage

Learn how to flush Buffered Writes to Storage with the Linux sync command, including practical examples, key options, and important precautions.

Linux mkdir Command: Create Directories and Parent Paths

Linux mkdir Command: Create Directories and Parent Paths

Learn how to create directories with Linux mkdir, build missing parent paths, set permissions, understand umask behavior, and verify results in scripts.

Linux history Command: Review and Reuse Shell Command History

Linux history Command: Review and Reuse Shell Command History

Learn how to use the Linux history command to review, search, reuse, and manage shell command history, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux ss Command: Inspect Open Ports and Sockets

Linux ss Command: Inspect Open Ports and Sockets

Learn how to inspect Open Ports and Sockets with the Linux ss command, including practical examples, key options, and important precautions.

Linux scp Command: Copy Files over SSH

Linux scp Command: Copy Files over SSH

Learn how to copy Files over SSH with the Linux scp command, including practical examples, key options, and important precautions.

Linux man Command: Read Command Manual Pages

Linux man Command: Read Command Manual Pages

Learn how to use the Linux man command to find and read command manuals, sections, options, and related pages, with essential options, practical examples, output interpretation, and common troubleshooting tips.