• Post author:Bhaskar Soni
  • Post published:
  • Post category:Linux
  • Post comments:3 Comments
  • Reading time:3 mins read

Linux runs most of the world’s servers, cloud workloads, containers and Android phones. Whether you want to work in DevOps, cyber security or system administration, you need to be comfortable on the Linux command line. This guide covers the Linux fundamentals and basic commands every beginner should know, with short examples you can try right away.

Linux fundamentals and basic commands

Why learn Linux?

  • It runs the internet: most web servers and cloud instances use Linux.
  • It is free and open source: you can install it anywhere and study how it works.
  • It is scriptable: almost every task can be automated from the shell.
  • It is essential for security work: tools like Kali Linux, Wazuh and most attack tools run on Linux.

The shell and the terminal

The terminal is the window where you type. The shell is the program that reads your commands and runs them. The most common shell is Bash, while Zsh is popular on desktops.

When you open a terminal, you see a prompt like this:

alice@server:~$

It shows the user, the host name, the current directory (~ means your home) and $ for a normal user. A # means you are root, so be careful.

Command structure

Most commands follow the same pattern:

command -options arguments
ls -l /etc

Options change how a command behaves, while arguments tell it what to work on.

Navigating the file system

Linux uses one tree that starts at / (root). Important directories include /home for users, /etc for configuration, /var/log for logs and /tmp for temporary files.

CommandWhat it does
pwdPrint the current directory
ls -laList all files with details
cd /var/logChange to a directory
cd ..Go up one level
cd ~Go to your home directory

An absolute path starts at /, such as /etc/hosts. A relative path starts from where you are, such as ../logs.

Working with files and directories

CommandWhat it does
mkdir -p projects/demoCreate directories
touch notes.txtCreate an empty file
cp notes.txt backup.txtCopy a file
mv backup.txt old/Move or rename
rm notes.txtDelete a file (there is no recycle bin)
rm -r old/Delete a directory and its contents

Be very careful with rm -r, especially with sudo.

Viewing and searching text

CommandWhat it does
cat filePrint a whole file
less fileScroll through a file
head -n 20 fileFirst 20 lines
tail -f /var/log/syslogFollow a log as it grows
grep -i error app.logFind lines containing a word
find / -name "*.conf"Find files by name
wc -l fileCount lines

You can chain commands with a pipe (|). For example, ps aux | grep nginx shows only Nginx processes.

Users, permissions and sudo

Every file has an owner, a group and permissions. View them with ls -l, and change them with chmod and chown. Run administrative commands with sudo. Read more in Linux file permissions and user and group management.

Processes and system information

CommandWhat it does
ps auxList processes
top or htopLive view of CPU and memory use
kill PIDStop a process
df -hDisk space
free -hMemory use
uname -aKernel and system information
ip addrNetwork addresses

Installing software

  • Debian and Ubuntu: sudo apt update && sudo apt install nginx
  • RHEL, Rocky and AlmaLinux: sudo dnf install nginx

Getting help

  • man ls opens the manual page for a command.
  • ls --help shows a short summary.
  • apropos network searches manual pages by keyword.

Next steps

Practise every day in a virtual machine or a cloud instance. Then test yourself with our Linux quiz, and prepare for jobs with Linux interview questions.

Sources

Running Linux servers in production? Our Linux server hardening & security audit checks configuration, patching, SSH and logging. You can also use our free Linux server hardening checklist, or contact us.

Post author avatar

Bhaskar Soni

Bhaskar Soni is a Security Engineer and the founder of Youngster Company, based in Ahmedabad, Gujarat. He works hands-on with Linux server hardening, vulnerability assessment and penetration testing (VAPT), ISO 27001 compliance and OSINT investigations. He writes practical, tested guides for IT professionals and Indian businesses, and every article on this site is written or reviewed by him.

This Post Has 3 Comments

Leave a Reply