Essential Linux Commands: A Practical Reference for Beginners
What are the essential Linux commands?
Essential Linux commands are the small set of shell tools you use daily to move around the filesystem, manage files, read logs, search text, control processes, check the network and install software. They include pwd, ls, cd, cp, mv, rm, cat, less, tail, grep, find, ps, kill, ip, ping, ss, curl, apt or dnf, and sudo, combined with pipes and redirection.
The shell, commands and getting help
A shell such as Bash reads what you type and runs programs. A command line has a command, options (usually starting with - or --) and arguments, as in ls -l /etc. Linux is case-sensitive, so File.txt and file.txt are different files.
Two shell features save a great deal of typing. Press Tab to complete a command, file or directory name, and press it twice to list the possible matches. Press the up arrow to recall earlier commands, or run history to see the list. Paths can be absolute, starting from the root /, or relative to the directory you are in, where . means the current directory and .. means its parent.
You never need to memorise every option. man ls opens the manual page (press q to quit and / to search), and ls --help prints a short summary. For background on the filesystem layout and users, read Linux for network engineers.
Navigating and managing files
pwd # print the current directory
ls -lah # list all files, long format, readable sizes
cd /var/log # change directory (absolute path)
cd .. # go up one level
cd ~ # go to your home directory
mkdir -p projects/lab1 # create directories, including parents
touch notes.txt # create an empty file or update its timestamp
cp notes.txt backup.txt # copy a file
cp -r projects/ old/ # copy a directory recursively
mv backup.txt archive/ # move or rename
rm old.txt # delete a file (no recycle bin)
rm -r old/ # delete a directory and its contents Viewing files and searching text
cat /etc/hostname # print a short file
less /var/log/syslog # page through a long file (q to quit)
head -n 20 access.log # first 20 lines
tail -n 50 access.log # last 50 lines
tail -f /var/log/syslog # follow new lines as they arrive (Ctrl+C to stop)
grep "Failed password" /var/log/auth.log # lines containing text
grep -rin "listen" /etc/nginx/ # recursive, case-insensitive, with line numbers
find /etc -name "*.conf" # files by name
find /var/log -type f -mtime -1 # files modified in the last dayLog file names vary: Debian and Ubuntu use /var/log/syslog and /var/log/auth.log, while many systems also keep logs in the systemd journal, read with journalctl -f. Reading authentication logs is a core defensive skill described in our cybersecurity basics guide.
Permissions, sudo and packages
Each file has an owner, a group and read, write and execute permissions for the owner, the group and everyone else. ls -l shows them as a string such as -rw-r-----. A dedicated guide on permissions is planned; the two commands to know now are:
chmod 640 report.txt # owner read/write, group read, others nothing
chmod +x backup.sh # make a script executable
sudo chown alice:staff report.txt # change owner and groupsudo runs one command with administrator rights after checking that your account is allowed to. Use it only for the command that needs it, never as a habit. Software is installed with the distribution package manager:
sudo apt update && sudo apt upgrade # Debian, Ubuntu
sudo apt install nmap
sudo dnf upgrade # Fedora, RHEL, Rocky, AlmaLinux
sudo dnf install nmap Processes and networking commands
ps aux # every running process
top # live view of CPU and memory (q to quit)
kill 1234 # ask process 1234 to stop (SIGTERM)
kill -9 1234 # force it to stop (SIGKILL), only as a last resort
ip a # interfaces and IP addresses
ip route # routing table and default gateway
ping -c 4 192.168.1.1 # four echo requests to the gateway
ss -tulpn # listening TCP/UDP ports and their processes
curl -I https://example.com # fetch only the HTTP response headersThese networking tools tie directly to IP addressing and DNS lookups: ip a shows your address, ping tests reachability and ss shows which services are exposed, which matters when hardening a server.
Pipes and redirection: combining commands
A pipe (|) sends the output of one command into the next. Redirection sends output to a file: > overwrites, >> appends and 2> captures errors.
ps aux | grep nginx # find a process
grep "Failed password" /var/log/auth.log | wc -l # count failed logins
ss -tulpn > ports.txt # save output to a file
echo "checked $(date)" >> audit.log # append a line
find / -name "*.bak" 2> /dev/null # hide permission errorsBuilding a habit, step by step
- Open a terminal on a virtual machine or test system you own.
- Check where you are with
pwdbefore changing anything. - Read the manual page for any new command and try it on a copy of your data.
- Combine two commands with a pipe and save the result with a redirect.
- Keep a personal notes file of commands that solved real problems.
Practical exercise: build a mini server report
On a Linux virtual machine you control, write a single text file called report.txt using only the commands in this guide.
- Create a
labdirectory in your home folder and move into it. - Append the hostname, the output of
ip aand the default route toreport.txt. - Append the list of listening ports from
ss -tulpn. - Append the top five processes by memory using
ps aux --sort=-%mem | head -n 6. - Count failed SSH logins in the authentication log and append the number.
- Set the file permissions to
600and confirm withls -l.
You are done when report.txt contains all five sections, only you can read it, and you can explain what each command did. Hands-on Linux labs are part of the Networking Foundation course.
Common mistakes
- Running
rm -rfwith a variable or wildcard path without first checking what it expands to. - Using
>when you meant>>, which overwrites a file instead of appending. - Prefixing every command with
sudo, which hides permission problems and increases the damage from mistakes. - Reaching for
kill -9first, which stops a process without letting it clean up. - Using
chmod 777to fix an access error, which lets every user modify the file.
Frequently asked questions
Are these commands the same on every Linux distribution?
The core commands are the same everywhere. The main differences are the package manager (apt on Debian and Ubuntu, dnf on Fedora and the Red Hat family) and some log file locations.
How do I stop a command that is still running?
Press Ctrl+C to interrupt the foreground command, which works for ping, tail -f and most other tools. Interactive programs such as less, top and man usually quit when you press q.
Can I practise Linux commands on Windows?
Yes. Windows Subsystem for Linux (WSL) runs a real Linux distribution on Windows, or you can use a free virtual machine with a distribution such as Ubuntu.
What is the difference between ifconfig and ip?
ifconfig comes from the older net-tools package, which many distributions no longer install by default. ip from iproute2 is the current tool for addresses, routes and links, as shown in the TCP/IP fundamentals guide.