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.
Service management with systemd
Systemd serves as the init system for most major distributions, including Ubuntu, Fedora, Arch, Debian, and RHEL. The systemctl command manages all system services.
Starting a service brings it online immediately.
sudo systemctl start nginx
Stopping a service shuts it down cleanly.
sudo systemctl stop nginx
Restarting combines stop and start, useful after configuration changes.
sudo systemctl restart nginx
Enabling a service configures automatic startup at boot.
sudo systemctl enable nginx
Disabling prevents automatic startup while leaving the service available for manual control.
sudo systemctl disable nginx
Checking service status reveals whether it's running, recent log entries, and resource usage.
systemctl status nginx
These systemctl commands are critical for managing services on production Linux servers, ensuring reliable service deployment and monitoring.
Distribution comparison
Installation defaults affect which tools are available and which configuration files they own.
Arch Linux follows a do-it-yourself approach:
Its base installation leaves many configuration choices to the administrator. Packages use pacman; networking and services depend on the components you install and enable.
Ubuntu provides a pre-configured experience:
It supplies defaults for its supported installation types and uses apt for packages. Network configuration may involve Netplan and a backend such as NetworkManager or systemd-networkd.
Inspect the actual installation before choosing a command. Distribution names alone do not describe every image, container, or administrator's configuration.
Cross-distribution configuration challenges
Network configuration depends on the active management tool. Examples include /etc/network/interfaces for ifupdown and /etc/netplan for Netplan; older Red Hat-family setups may use /etc/sysconfig/network-scripts. Do not assume that a file mentioned in an older guide still controls the installed system.
Firewall management differs significantly. Ubuntu defaults to ufw for simple command-line control. Fedora and Red Hat use firewalld with firewall-cmd for more granular management. The underlying technology might match, but the interfaces diverge substantially.
Portable shell logic can often be retained when moving a script between distributions. Review package commands, package names, paths, service names, and available options, then test the affected operations on each target system.
Creating command aliases
Command aliases reduce repetitive typing and potential errors. You define shortcuts in your shell configuration file.
Open your .bashrc file and add custom commands. This example creates an update alias that refreshes repositories and upgrades packages in one step.
alias update='sudo apt update && sudo apt upgrade -y'
alias ll='ls -lah'
alias docs='cd ~/Documents'
After saving your aliases, reload the configuration to activate them.
source ~/.bashrc
Your custom shortcuts now work immediately.
Practical network testing
Connectivity tools help distinguish address, routing, and service problems. Their options and output can vary by implementation, and firewalls may prevent some probes from receiving a response.
The ping command sends ICMP echo requests. Replies confirm that this traffic reached the destination and returned; missing replies do not by themselves prove the host or an application is unavailable.
ping google.com
Press Ctrl+C to stop the continuous ping and view statistics.
The ip addr command provides a complete picture of all network interfaces and their configurations.
ip addr
This shows interface names, IP addresses, subnet masks, and interface status.
Conclusion
Learn the common command structure, then check the tools installed on your system. Practise file operations on disposable data and review network or service changes before applying them remotely. The same approach helps when maintaining a local machine or cloud-based VPS infrastructure.