Linux Fundamentals for DevOps Beginners: Complete Guide
Linux is one of the most important skills for anyone beginning a career in DevOps. Most cloud servers, containers, automation platforms and DevOps tools operate in Linux-based environments.
A DevOps engineer frequently uses Linux to configure servers, install software, manage users, troubleshoot applications, inspect logs, automate tasks and monitor system resources.
This beginner-friendly guide introduces the Linux fundamentals you should learn before moving to Docker, CI/CD, Terraform and Kubernetes.
If you are following a complete learning path, begin with our DevOps roadmap for beginners before continuing with this guide.
What Is Linux?
Linux is an open-source operating system kernel used by many operating-system distributions. A Linux distribution combines the Linux kernel with system utilities, package managers and other software.
Popular Linux distributions include:
- Ubuntu
- Debian
- Red Hat Enterprise Linux
- Rocky Linux
- AlmaLinux
- Fedora
- Amazon Linux
Ubuntu is a suitable starting point for beginners because it has extensive documentation, a large community and broad support across cloud platforms.
Why DevOps Engineers Need Linux
Applications must run somewhere after developers create them. In many organizations, they run on Linux servers, containers or cloud services.
A DevOps engineer may use Linux to:
- Configure development and production servers.
- Install application dependencies.
- Deploy frontend and backend applications.
- Manage users and permissions.
- Configure Nginx or Apache.
- Run Docker containers.
- Execute CI/CD jobs.
- Monitor processes and resource usage.
- Examine application and system logs.
- Write automation scripts.
- Troubleshoot deployment failures.
You do not need to memorize every Linux command. You should understand how the operating system works and know how to find the correct command when required.
Understanding the Linux File System
Linux organizes files and directories in a hierarchical structure beginning with the root directory:
/
Important directories include:
/home— Personal directories for regular users./root— Home directory of the root user./etc— System and application configuration files./var— Logs, caches and frequently changing data./var/log— System and application log files./usr— Programs, libraries and shared resources./bin— Essential command-line programs./tmp— Temporary files./opt— Optional third-party software./srv— Data used by services./proc— Information about processes and the system.
Understanding these directories helps you locate configurations, applications and logs when troubleshooting a server.
Essential File and Directory Commands
Start by practising these commands:
pwd
ls
cd
mkdir
touch
cp
mv
rm
find
Examples:
pwd
Displays your current directory.
ls -la
Lists files, including hidden files, with permissions and ownership information.
mkdir devops-project
cd devops-project
Creates a directory and enters it.
touch deployment.txt
Creates an empty file.
cp deployment.txt deployment-backup.txt
Copies a file.
mv deployment.txt deployment-guide.txt
Moves or renames a file.
Be careful when using rm, especially with recursive options. Deleted files may not be easily recoverable.
Reading and Editing Files
DevOps engineers regularly inspect configuration and log files.
Useful commands include:
cat filename
less filename
head filename
tail filename
nano filename
To monitor new lines being written to a log file, use:
tail -f /var/log/syslog
This is useful when watching an application or service while reproducing a problem.
You can use Nano as a beginner-friendly terminal editor. Later, you can learn Vim if required.
Linux Users and Groups
Linux supports multiple users. Each user can have different permissions and can belong to one or more groups.
Important commands include:
whoami
id
groups
sudo
useradd
usermod
passwd
For example:
whoami
Displays the currently logged-in user.
id
Shows the user ID, primary group and additional groups.
The sudo command allows an authorized user to execute administrative commands. Use it only when administrative permission is genuinely required.
Avoid working permanently as the root user. A normal user with carefully controlled sudo access is generally safer.
File Permissions
Every Linux file and directory has permissions for:
- Owner
- Group
- Others
The primary permissions are:
r— Readw— Writex— Execute
Use the following command to inspect permissions:
ls -l
An example permission value is:
-rwxr-xr--
Permissions can be changed with chmod:
chmod u+x deploy.sh
This adds execute permission for the file owner.
Ownership can be changed with chown:
sudo chown khwaja:developers deploy.sh
Grant only the permissions that a user or service actually requires. Avoid using chmod 777 as a general solution because it gives everyone complete access.
Package Management
A package manager installs, updates and removes software.
Ubuntu and Debian use the APT package manager:
sudo apt update
sudo apt install nginx
sudo apt upgrade
sudo apt remove nginx
apt update refreshes the package information. It does not upgrade installed packages by itself.
Red Hat-based distributions commonly use DNF:
sudo dnf install nginx
Always identify the Linux distribution before using distribution-specific package commands:
cat /etc/os-release
Processes and System Resources
A process is a running program. DevOps engineers must know how to inspect applications and identify processes consuming too many resources.
Useful commands include:
ps
top
htop
free
df
du
uptime
kill
Examples:
ps aux
Displays running processes.
free -h
Shows memory usage in a human-readable format.
df -h
Displays filesystem disk usage.
du -sh /var/log
Shows the total size of the /var/log directory.
Before stopping a process, identify what it is and whether another service depends on it.
Managing Linux Services
Modern Linux distributions commonly use systemd to manage background services.
The main command is:
systemctl
Examples:
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
sudo systemctl status nginx
sudo systemctl enable nginx
enable configures the service to start automatically during system startup. It does not necessarily start the service immediately.
If a service fails, first check its status and then inspect its logs.
Understanding Linux Logs
Logs record information about system activity, applications and errors. They are essential for troubleshooting.
Common log locations include:
/var/log/syslog
/var/log/auth.log
/var/log/nginx/
/var/log/apache2/
For services managed by systemd, use journalctl:
journalctl
journalctl -u nginx
journalctl -u nginx --since today
When an application fails, check:
- The service status.
- Application logs.
- System logs.
- File permissions.
- Environment variables.
- Port availability.
- Network and firewall configuration.
This structured approach is more effective than changing several settings randomly.
Basic Linux Networking Commands
DevOps engineers use networking commands to confirm whether a server, domain, port or service is reachable.
Important commands include:
ip addr
ping
curl
wget
ss
dig
nslookup
ssh
Examples:
ip addr
Displays network interfaces and IP addresses.
curl -I https://example.com
Retrieves the response headers from a website.
ss -tulpn
Displays listening TCP and UDP ports.
ssh username@server-ip
Connects securely to a remote server.
A successful ping does not always mean an application is working. The application port, firewall, web server and DNS configuration must also be checked.
Environment Variables
Environment variables store values used by the operating system and applications.
Display current variables with:
printenv
Display a particular variable:
echo "$PATH"
Create a temporary variable:
export APP_ENV=development
The variable normally remains available only during the current shell session unless you add it to an appropriate shell configuration file or service configuration.
Never place passwords, access keys or other secrets inside public repositories.
Shell Scripting for Automation
Shell scripts allow DevOps engineers to combine commands and automate repetitive operations.
A basic Bash script looks like this:
#!/usr/bin/env bash
set -e
echo "Starting deployment"
sudo systemctl restart nginx
sudo systemctl status nginx
echo "Deployment completed"
Save it as:
deploy.sh
Add execute permission:
chmod u+x deploy.sh
Run it:
./deploy.sh
Start with small scripts for backups, health checks, software installation and log collection. Add error handling before using scripts in production.
A Practical Linux Project
Create an Ubuntu virtual machine or cloud server and complete these tasks:
- Create a non-root user.
- Configure SSH access.
- Update system packages.
- Install Nginx.
- Create a basic HTML page.
- Configure Nginx to serve the page.
- Start and enable the Nginx service.
- Check the listening ports.
- Inspect the Nginx logs.
- Create a small script that checks whether Nginx is running.
Document every command and explain why you used it. This project will give you practical experience with users, permissions, packages, services, networking and logs.
Common Linux Mistakes to Avoid
Beginners should avoid:
- Running every command with
sudo. - Working permanently as the root user.
- Assigning
777permissions to solve access problems. - Deleting files without confirming the path.
- Copying commands without understanding them.
- Ignoring application and system logs.
- Storing passwords inside shell scripts.
- Making production changes without a backup.
- Exposing unnecessary network ports.
Understanding the reason behind every command is more important than memorizing a long list of commands.
Frequently Asked Questions
Which Linux distribution is best for DevOps beginners?
Ubuntu is a practical choice for beginners because it is widely documented and commonly used on servers and cloud platforms. The fundamental Linux concepts you learn can also be applied to other distributions.
Is Linux mandatory for DevOps?
You can perform some DevOps tasks on other operating systems, but strong Linux knowledge is extremely valuable because many servers, containers and cloud workloads use Linux.
Do I need to memorize Linux commands?
No. Learn the purpose of common commands and practise using them. With experience, the commands you use regularly will become familiar.
What should I learn after Linux?
After becoming comfortable with Linux fundamentals, continue with networking, Git, shell scripting, Docker and CI/CD.
Conclusion
Linux forms the foundation of many DevOps tools and workflows. Start with files, directories, permissions, users, packages, processes, services, networking and logs. Practise each concept on a real or virtual Linux system.
Do not try to learn Linux only by reading commands. Build a small server project, make mistakes in a safe environment and practise troubleshooting them.
Explore our DevOps, Linux and technology articles for the next guide in this learning series.
Leave a Reply