Online admissions open for the SEO, PHP web development and networking & cybersecurity courses. Enquire for the next batch.

Essential Linux Commands: A Practical Reference for Beginners

5 min read Updated By the SkillNewton team

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.

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 day

Log 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 group

sudo 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 headers

These 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 errors

Building a habit, step by step

  1. Open a terminal on a virtual machine or test system you own.
  2. Check where you are with pwd before changing anything.
  3. Read the manual page for any new command and try it on a copy of your data.
  4. Combine two commands with a pipe and save the result with a redirect.
  5. 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.

  1. Create a lab directory in your home folder and move into it.
  2. Append the hostname, the output of ip a and the default route to report.txt.
  3. Append the list of listening ports from ss -tulpn.
  4. Append the top five processes by memory using ps aux --sort=-%mem | head -n 6.
  5. Count failed SSH logins in the authentication log and append the number.
  6. Set the file permissions to 600 and confirm with ls -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 -rf with 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 -9 first, which stops a process without letting it clean up.
  • Using chmod 777 to 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.

Want to Learn This Properly?

The Networking & Cybersecurity: Foundation & Practical Implementation (Online) turns guides like this into practised skills, with projects on real websites.

WhatsApp Call Us Now

Free counselling

Send an Enquiry

Tell us which course you are interested in. We reply by email or phone with the next batch and how to enrol.

We reply by email or phone within working hours. No spam.