DEV Community

Arpit Mungone
Arpit Mungone

Posted on

🐧 Linux for DevOps #2: Mastering Users, File Permissions & Process Management

Welcome back to Part 2 of my Linux for DevOps series.

In my previous blog, I covered Linux fundamentals, the file system, and essential commands that every beginner should know. If there's one thing I've learned so far, it's that Linux isn't just about memorizing commandsβ€”it's about understanding how the operating system works.

This week, I explored three of the most important Linux administration concepts that every DevOps Engineer should master:

πŸ‘€ User & Group Management
πŸ” File Permissions
βš™οΈ Process Management

These concepts are used every day by system administrators and DevOps engineers to manage servers securely and efficiently.

Let's dive in!

πŸ‘€ User & Group Management

Linux is a multi-user operating system, meaning multiple users can access the same system while maintaining their own files, permissions, and settings.

Managing users correctly is essential for maintaining both security and organization.

Types of Users
Root User

The root user has unrestricted access to the entire system. It can install software, modify system files, create users, and perform administrative tasks.

Because it has complete control over the system, it's recommended to avoid logging in as root for everyday work.

Regular User

A regular user has limited permissions and cannot make system-wide changes unless granted administrative privileges using sudo.

This follows the Principle of Least Privilege, which is a security best practice.

System Users

System users are created automatically by Linux for running services like Nginx, MySQL, Docker, and other background processes.

Important Files

Linux stores user and group information in a few important files.

/etc/passwd

Stores basic information about every user.

/etc/shadow

Stores encrypted passwords and password-related information.

/etc/group

Stores information about all user groups.

Understanding these files helps you troubleshoot authentication and permission issues more effectively.

Common User Management Commands

Create a new user:

sudo useradd arpit

Set a password:

sudo passwd arpit

Switch to another user:

su arpit

Check the current user:

whoami

Display user information:

id arpit

Create a group:

sudo groupadd developers

Add a user to a group:

sudo usermod -aG developers arpit

Delete a user:

sudo userdel arpit
DevOps Use Case

Imagine a development team deploying applications to a production server.

Instead of giving everyone root access, each developer gets their own account and is added to a deployment group with only the permissions they need.

This improves security, accountability, and makes auditing much easier.

πŸ” Linux File Permissions

Permissions are one of Linux's strongest security features.

Every file and directory has permissions that determine who can read, write, or execute it.

You can view permissions using:

ls -l

Example output:

-rwxr-xr--

Let's break it down.

Owner β†’ rwx
Group β†’ r-x
Others β†’ r--
Understanding Permissions
Read (r)

Allows viewing the contents of a file.

Write (w)

Allows modifying or deleting a file.

Execute (x)

Allows executing a file or entering a directory.

Numeric Permissions

Linux also represents permissions using numbers.

Number Permission
7 Read + Write + Execute
6 Read + Write
5 Read + Execute
4 Read Only
0 No Permission

Examples:

chmod 755 script.sh
chmod 644 file.txt
chmod 600 private_key.pem
Changing Ownership

Change the owner of a file:

sudo chown arpit file.txt

Change the group:

sudo chgrp developers file.txt
Why You Should Avoid chmod 777

One of the biggest mistakes beginners make is giving every user full permissions.

chmod 777 file.txt

Although it solves permission issues quickly, it creates serious security risks because anyone can modify or delete the file.

A better approach is to assign only the permissions that are actually required.

DevOps Use Case

When connecting to an AWS EC2 instance using SSH, the private key must have secure permissions.

chmod 400 my-key.pem

If the permissions are too open, SSH will refuse the connection to protect your credentials.

βš™οΈ Linux Process Management

Whenever you run an application, Linux creates a process.

Every running process has a unique Process ID (PID).

Understanding processes is essential because applications, web servers, databases, and containers all run as processes.

View Running Processes
ps -ef

This command displays all running processes.

Monitor Processes
top

This provides a real-time view of CPU usage, memory usage, and running processes.

For a more user-friendly interface, you can use:

htop
Stop a Process

Kill a process using its PID:

kill 1234

Forcefully terminate it:

kill -9 1234
Run a Process in the Background
command &

View background jobs:

jobs

Bring a process back to the foreground:

fg
Keep a Process Running After Logout
nohup python app.py &

This is especially useful when running applications on remote Linux servers.

DevOps Use Case

Suppose your Nginx server becomes unresponsive.

The first step is to identify the running process.

ps -ef | grep nginx

If necessary, restart the service.

sudo systemctl restart nginx

Being able to inspect and manage processes quickly is an essential troubleshooting skill for DevOps engineers.

Common Mistakes Beginners Make

Here are a few mistakes I encountered while learning:

Logging in as the root user for everything.
Using chmod 777 without understanding the security risks.
Forgetting to use sudo when administrative privileges are required.
Killing the wrong process by mistake.
Not checking file ownership before changing permissions.

Learning from these mistakes helped me better understand how Linux manages security and system resources.

Quick Command Cheat Sheet
User Management
whoami
id
useradd
passwd
usermod
userdel
groupadd
groups
File Permissions
ls -l
chmod
chown
chgrp
Process Management
ps -ef
top
htop
kill
kill -9
jobs
bg
fg
nohup
Key Takeaways

This week helped me understand that Linux administration isn't just about knowing commandsβ€”it's about managing systems securely and efficiently.

Here's what I learned:

How Linux manages users and groups.
Why file permissions are critical for security.
How ownership affects file access.
How to monitor and manage running processes.
Why following security best practices is essential in DevOps.

Every concept I learned this week is directly applicable to real-world cloud environments and production servers.

Thanks for reading!

If you're also learning Linux or DevOps, I'd love to hear about your journey. Feel free to share your thoughts, suggestions, or favorite Linux commands in the comments.

Happy Learning! πŸš€

linux #devops #aws #beginners #cloud

Top comments (0)