Understanding Linux and Operating Systems

Table of contents
- What is an Operating System?
- Key Functions:
- The Linux Kernel: Heart of the OS
- Popular Linux Distributions (Distros)
- Linux Filesystem Structure
- User Management in Linux
- File Permissions and Ownership in Linux
- Installing Software in Linux
- Networking in Linux
- Remote Access to Linux Using SSH
- Transferring Files Remotely
- Linux Security Best Practices
- Must-Know Linux Commands
- Conclusion

What is an Operating System?
An Operating System (OS) is essential software that manages computer hardware and enables applications to run. It acts as a bridge between apps (like a browser) and hardware (like CPU or RAM).
Key Functions:
Process Management: Allocates CPU time, supports multitasking.
Memory Management: Manages RAM usage.
File Management: Organizes files/folders.
Device Management: Interfaces with hardware.
Security & Networking: Controls access and manages network traffic.
The Linux Kernel: Heart of the OS
The Linux kernel is the core of all Linux systems. It manages resources and hardware interaction.
Most Linux systems offer:
Graphical User Interface (GUI) – Beginner-friendly.
Command Line Interface (CLI) – Powerful for professionals.
Popular Linux Distributions (Distros)
Linux has multiple flavors:
Debian-based | Red Hat-based |
Ubuntu | RHEL |
Linux Mint | CentOS |
Pop!_OS | Fedora |
Each uses a package manager:
APT: Ubuntu/Debian
YUM/DNF: RHEL/CentOS
Linux Filesystem Structure
All files reside under the root /
directory.
Directory | Purpose |
/bin | Essential command binaries |
/etc | Configuration files |
/home | User directories |
/var/log | System logs |
/dev | Device files |
User Management in Linux
Types of users:
Root – Superuser with all access.
Regular Users – Limited permissions.
Service Accounts – Used by system services.
Common user commands:
sudo useradd -m alice # Create a new user 'alice' with a home directory
sudo passwd alice # Set a password for user 'alice'
sudo usermod -aG sudo alice # Add 'alice' to the sudo (admin) group
File Permissions and Ownership in Linux
Linux uses permissions to control who can read, write, or execute files.
Permission Types:
r
– Readw
– Writex
– Execute
Changing Permissions with chmod
Symbolic Method:
chmod u+x script.sh # Add execute permission for the user(owner)
chmod g-w file.txt # Remove write permission from the group
chmod o=r file.txt # Set read-only permission for others
Numeric Method:
chmod 755 script.sh # Set permissions rwxr-xr-x (user=7, group=5, others=5)
chmod 640 config.txt # Set permissions rw-r----- (user=6, group=4, others=0)
Tip: 4 = read, 2 = write, 1 = execute → add them (e.g : 7 = rwx)
Changing Ownership with chown
sudo chown bob file.txt # Change file owner to 'bob'
sudo chown bob:devs file.txt # Change owner to 'bob' and group to 'devs'
Changing Group with chgrp
sudo chgrp devops report.log # Change the group of the file to 'devops'
Installing Software in Linux
Ubuntu/Debian:
sudo apt update # Update the package list from repositories
sudo apt install nginx # Install the nginx web server package
RHEL/CentOS:
sudo yum update # Update installed packages to latest versions
sudo yum install nginx # Install the nginx web server package
Networking in Linux
ip a # Show all network interfaces and their IP addresses
ping google.com # Send ICMP packets to check connectivity to Google
ss -tuln # Display all listening TCP/UDP ports and services
Remote Access to Linux Using SSH
Step 1: Install SSH Server
sudo apt install openssh-server -y # Install SSH server on Ubuntu/Debian
sudo yum install openssh-server -y # Install SSH server on RHEL/CentOS
sudo systemctl start ssh # Start SSH service
sudo systemctl enable ssh # Enable SSH to start at boot
Step 2: Check IP Address of Server
ip a # Show IP address(es) assigned to the server
Step 3: Connect From Your Local Machine
ssh alice@192.168.1.100 # Connect via SSH to user 'alice' on remote server
Step 4: SSH Key Authentication (Optional but Recommended)
ssh-keygen -t rsa -b 4096 # Generate an RSA SSH key pair
ssh-copy-id alice@192.168.1.100 # Copy your public key to remote user
ssh alice@192.168.1.100 # Connect without password using keys
Step 5: Disable Password Authentication
sudo nano /etc/ssh/sshd_config # Edit SSH server config
# Set the following options:
PasswordAuthentication no # Disable password logins
PermitRootLogin no # Disable root user SSH login
sudo systemctl restart ssh # Restart SSH service for changes to take effect
Transferring Files Remotely
Using scp:
scp file.txt alice@192.168.1.100:/home/alice/ # Copy local file to remote directory
scp -r myfolder/ alice@192.168.1.100:/home/alice/ # Copy entire folder recursively
scp alice@192.168.1.100:/var/log/syslog ./ # Copy remote file to local machine
Using rsync:
rsync -avz myproject/ alice@192.168.1.100:/home/alice/myproject/ # Sync folder to remote with compression
rsync -avz alice@192.168.1.100:/home/alice/backups/ ./backups/ # Sync remote folder to local
Linux Security Best Practices
Use SSH keys instead of passwords for secure login
Disable root login over SSH to reduce attack surface
Keep system packages up to date
Use firewall tools like
ufw
orfirewalld
Regularly monitor system logs in
/var/log/
Must-Know Linux Commands
File & Directory Management
pwd # Print current working directory path
ls -l # List files with detailed info (permissions, owner, size)
ls -a # List all files including hidden ones (dotfiles)
cd /path/to/dir # Change current directory to specified path
mkdir mydir # Create a new directory named 'mydir'
mkdir -p a/b/c # Create nested directories a, b inside a, and c inside b
touch file.txt # Create an empty file named file.txt or update its timestamp
cp file1.txt file2.txt # Copy file1.txt to file2.txt
cp -r src/ dest/ # Copy directory src and its contents recursively to dest/
mv file.txt newname.txt # Rename or move file.txt to newname.txt
rm file.txt # Remove/delete file.txt
rm -rf folder/ # Remove directory 'folder' and all its contents recursively and forcefully
find . -name "*.log" # Search current directory tree for files ending with .log
stat file.txt # Display detailed status info about file.txt (size, ownership, timestamps)
basename /path/file.txt # Extract filename (file.txt) from full path
dirname /path/file.txt # Extract directory path (/path) from full file path
File Viewing & Text Processing
cat file.txt # Display entire contents of file.txt
tac file.txt # Display contents of file.txt in reverse line order
more file.txt # View file content one page at a time (forward only)
less file.txt # View file content with scrolling (forward and backward)
head -n 10 file.txt # Show first 10 lines of file.txt
tail -n 20 file.txt # Show last 20 lines of file.txt
tail -f logfile # Follow live appended output of logfile (e.g. live logs)
cut -d':' -f1 /etc/passwd # Extract first field of each line using ':' delimiter from passwd file
awk '{print $1}' file.txt # Print first column of each line in file.txt
sed 's/old/new/g' file.txt # Replace all occurrences of 'old' with 'new' in file.txt
tr a-z A-Z # Translate lowercase letters to uppercase from stdin
sort file.txt # Sort lines alphabetically from file.txt
uniq -c # Count number of consecutive duplicate lines from input
wc -l file.txt # Count number of lines in file.txt
diff file1 file2 # Show line differences between file1 and file2
cmp file1 file2 # Compare file1 and file2 byte by byte
Permissions & Ownership
chmod 755 script.sh # Set permissions rwxr-xr-x on script.sh (full for user, read/execute others)
chmod +x script.sh # Add execute permission for user/group/others on script.sh
chown bob file.txt # Change owner of file.txt to 'bob'
chown bob:devs file.txt # Change owner to 'bob' and group to 'devs' for file.txt
chgrp devs file.txt # Change group ownership of file.txt to 'devs'
umask # Show default permission mask applied to newly created files
Package Management
Debian/Ubuntu:
sudo apt update # Refresh package repository metadata
sudo apt upgrade # Upgrade all installed packages to latest versions
sudo apt install nginx # Install nginx package
sudo apt remove nginx # Remove nginx package
dpkg -l # List all installed packages via dpkg
RHEL/CentOS:
sudo yum update # Update all packages to latest available versions
sudo yum install httpd # Install Apache web server package
sudo yum remove httpd # Remove Apache package
rpm -qa # Query all installed RPM packages
rpm -qf /bin/bash # Find which package owns the /bin/bash file
System Monitoring & Resource Usage
top # Interactive display of current processes and system usage
htop # Improved version of top with better interface and controls
vmstat # Report virtual memory, processes, CPU activity stats
free -h # Show memory usage in human-readable format
df -h # Display disk usage of filesystems in human-readable form
du -sh /var/log # Show total size of /var/log directory
iostat # Displays CPU and input/output statistics to help monitor system performance and identify bottlenecks
Conclusion
Linux is essential for servers and DevOps. Knowing its core commands and security practices enables efficient system management and automation.
Subscribe to my newsletter
Read articles from Syed Farooq directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Syed Farooq
Syed Farooq
Software engineer specializing in cloud technologies, focused on streamlining operations and enhancing software delivery through automation and continuous integration. Dedicated to driving innovation and efficiency in tech environments.