Linux command line essentials
Most servers on the internet and in the cloud run Linux, and the command line is the fastest way to work with them. This guide covers the commands you will use every day. Try each one in a virtual machine or a test system as you read.
Finding your way around
pwdprints the directory you are in.ls -lalists files, including hidden ones, with permissions, owners and sizes.cd /etcmoves to a directory;cd ..goes up one level andcd ~goes to your home directory.
Linux paths start at the root /. Configuration usually lives in /etc, logs in /var/log, and user files in /home.
Working with files
mkdir projectscreates a directory.cp file.txt backup.txtcopies a file; add-rto copy a directory.mv old.txt new.txtmoves or renames.rm file.txtdeletes a file. There is no recycle bin, so check before you delete, and be especially careful withrm -r.catprints a short file,lesslets you scroll through a long one, andheadandtailshow the beginning and end.tail -f /var/log/syslogfollows a log as new lines arrive (on some distributions the system log is read withjournalctlinstead).
Searching
grep "error" app.logshows the lines that contain a word.grep -rsearches a whole directory andgrep -iignores case.find /var/log -name "*.log"finds files by name.
Pipes and redirection
The real power of the command line is combining small tools. A pipe | sends the output of one command to the next: grep "Failed password" /var/log/auth.log | tail -n 20 shows the last twenty failed logins (the file name varies by distribution). Redirection saves output: > writes to a file, replacing its content, and >> appends.
Users, permissions and sudo
Every file has an owner, a group, and permissions for the owner, the group and everyone else. ls -l shows them as letters, for example rwxr-xr-x: r is read, w is write and x is execute.
chmod 644 notes.txtgives the owner read and write, and everyone else read only.chmod 755 script.shmakes a script executable by everyone and writable only by its owner.chown alice:staff report.txtchanges the owner and group.
Administrative commands need elevated rights. sudo runs a single command as the administrator. Use it only when needed, and read a command carefully before you add sudo to it.
Installing software
Distributions use package managers to install and update software from trusted repositories. On Debian and Ubuntu: sudo apt update then sudo apt install nginx. On Red Hat-based systems such as Fedora, Rocky Linux and AlmaLinux: sudo dnf install nginx. Keep systems updated regularly; most security fixes arrive this way.
Processes and services
ps auxlists running processes, andtopshows them live, sorted by resource use. Press q to quit.kill 1234asks the process with ID 1234 to stop.- On most modern distributions, services are managed by systemd:
systemctl status nginxshows whether a service is running,sudo systemctl restart nginxrestarts it, andsudo systemctl enable nginxstarts it at boot. journalctl -u nginxshows the logs of a single service.
Disk and network
df -hshows free space on each file system, anddu -sh *shows how much space each item in a directory uses.ip ashows network interfaces and addresses, andss -tulpnshows which ports are listening.
Getting help
You do not need to memorise options. man ls opens the manual for a command, and most commands accept --help for a short summary. Reading manuals is a skill in itself, and it is one that experienced administrators use every day.
Practise
Create a virtual machine with a free Linux distribution and give yourself small tasks: create a user, set permissions on a shared directory, install a web server, find its logs, and restart it. The LPI Linux Essentials course is the first step in both the IT support and cloud engineer paths, and it covers these topics in a structured order.