Most Linux commands follow a familiar pattern: the command name, options that change its behaviour, and arguments such as filenames or service names. This guide covers common file, directory, permission, networking, and service commands, with examples you can adapt to your system.
Basic commands often transfer between distributions, while package managers and network configuration tools vary. Before using an example in a development environment on a VPS or on a production server, check the installed tool's help and replace the example paths, names, and addresses.
The foundation: GNU core utilities
GNU Coreutils provides familiar tools such as ls, cp, mv, rm, cat, chmod, and chown. Many Linux distributions ship GNU implementations, though minimal systems and containers may use alternatives such as BusyBox.
POSIX standards define a shared baseline for many command behaviours. Extensions, defaults, versions, locale, and aliases can still change the output or available options. Check those differences when a script needs to run on several systems.
Use man command-name or the tool's supported help option to check syntax on the machine where you will run it.
Quick command reference
| Category | Commands | Purpose |
|---|---|---|
| Navigation |
cd, pwd, ls
|
Moving through directories |
| File operations |
touch, cp, mv, rm
|
Creating and managing files |
| Directory operations |
mkdir, rmdir
|
Managing directories |
| View content |
cat, head, tail
|
Reading file contents |
| Permissions |
chmod, chown
|
Security and ownership |
| Text processing |
grep, sed, awk
|
Searching and editing text |
| Networking |
ping, ss, ip
|
Testing and configuring the network |
Essential navigation and file commands
Moving around your system
The cd command changes your current directory. Running it without arguments takes you straight home.
cd /var/log
cd
The pwd command shows your current location.
pwd
The ls command lists directory contents. Add flags for detailed information.
ls -lah
This shows a long format with human-readable sizes and includes hidden files.
Working with files
Creating an empty file or updating its timestamp uses touch.
touch filename.txt
Copying files requires specifying the source and destination.
cp source.txt destination.txt
Moving or renaming uses mv with the same syntax.
mv oldname.txt newname.txt
The rm command removes files without sending them to a desktop trash folder. Practise on a disposable file and check the path before confirming deletion.
rm -i filename.txt
The -i option asks for confirmation. Recursive removal uses -r; -f suppresses prompts and ignores missing files. Combining them can remove an entire directory tree, so use those options only when that is the intended operation.
Managing directories
Creating directories uses mkdir.
mkdir new_directory
Removing empty directories uses rmdir. It fails safely if the directory contains files.
rmdir empty_directory
Reading file contents
The cat command displays the entire contents of a file at once.
cat filename.txt
The head command shows the first lines. Specify how many lines you want.
head -n 10 filename.txt
The tail command displays the last lines. Add the following flag to watch files for updates in real time. This is essential for real-time log monitoring.
tail -f /var/log/nginx/access.log
For system logs on Fedora and Arch, use journalctl -f instead, as these distributions primarily use systemd's journal for logging.
File permissions and ownership
The chmod command sets permissions using numeric modes. Each digit represents user, group, and other permissions, respectively.
chmod 755 script.sh
This sets rwxr-xr-x permissions: the owner can read, write, and execute; the group and others can read and execute. Use a more restrictive mode when the file should not be readable by everyone.
The chown command changes file ownership.
sudo chown username:groupname filename
Text processing tools
The grep command searches for patterns in files.
grep 'error' /var/log/syslog
The sed command performs stream editing. The in-place flag edits files directly. The global flag replaces all occurrences on each line.
sed -i 's/old/new/g' filename.txt
The awk command processes structured data.
awk '/pattern/ {print $1}' filename.txt
Syntax notation guide
When reading command documentation, you'll encounter standardized notation patterns.
Square brackets indicate optional parameters. You can include or omit them based on your needs.
command [optional_parameter]
Angle brackets commonly mark a required value in explanatory examples. Replace the entire placeholder, including the brackets, before running a real command; shells also use angle brackets for redirection.
command <required_argument>
Three dots indicate repeatable parameters. You can specify multiple values.
command <argument> ...
Package management: where distributions differ
Package managers use different commands to perform similar tasks. Choose the commands for the installed distribution, and review proposed changes before upgrading a working server.
Debian and Ubuntu systems
Ubuntu and Debian systems use APT. Commands require root privileges. The double ampersand chains commands together. The second command only runs if the first succeeds with exit code 0.
sudo apt update && sudo apt install package-name
sudo apt upgrade
Systems using DNF
Red Hat-based distributions use DNF. The syntax shifts, but concepts remain similar. DNF uses cached repository metadata by default, though you can configure it to check for updates automatically.
sudo dnf install package-name
sudo dnf upgrade
Arch Linux systems
Arch uses Pacman with compact single-letter flags. When combined as -Syu, the -S flag syncs or installs from repositories, the -y flag refreshes the package database, and the -u flag upgrades all installed packages.
sudo pacman -S package-name
sudo pacman -Syu
Network management: modern tools replace legacy commands
Network configuration showcases both the evolution of Linux tools and the challenges of legacy compatibility. You'll encounter both approaches in production environments.
Note: These network management skills are essential when configuring VPS infrastructure or managing dedicated servers.
Modern standard: iproute2
The iproute2 suite includes ip for interface and route management, and ss for socket inspection. Start with read-only commands to understand the current network before applying changes.
Viewing your network interfaces and addresses uses ip addr.
ip addr show
Bringing an interface online uses ip link.
sudo ip link set eth0 up
Configuring routing uses ip route.
sudo ip route add default via 192.168.1.1
The ss command replaced the older netstat tool for viewing network connections.
ss -tuln
This displays TCP and UDP listening ports with numeric addresses.
Legacy commands
Older guides may use ifconfig from the net-tools package. It remains available on some systems, but ip is the usual choice for current Linux network administration. The following example changes an interface address; adapt it only in an environment where you can recover from a lost connection.
ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up
Distribution-specific tools
Ubuntu uses Netplan with YAML configuration files. Applying network changes uses netplan apply.
sudo netplan apply
Fedora and Red Hat rely on NetworkManager controlled through nmcli.
sudo nmcli con up eth0
On Arch Linux, persistent configuration depends on the network manager you selected, such as NetworkManager or systemd-networkd. A temporary ip command does not automatically update that manager's configuration.