DEV Community

Cover image for Linux Fundamentals for DevOps
Samia Khan for AWS Community Builders

Posted on • Edited on

Linux Fundamentals for DevOps

[Updating this post as I go. Last updated: 7/7/25]

I decided to go back to basics and refresh my Linux knowledge. Here I'm recapping everything I've learnt. Useful notes here

I created a docker container running Ubuntu to practice using:

docker run -dit --name linux-learning --hostname ubuntu-dev --restart unless-stopped --cpus="2" --memory="4g" --mount type=bind,source="C:/ubuntu-data",target=/data -v /var/run/docker.sock:/var/run/docker.sock -p 2222:22 -p 8080:80 --env TZ=Europe/London --env LANG=en_GB.UTF-8 ubuntu:latest /bin/bash
Enter fullscreen mode Exit fullscreen mode

Some important directories

/sbin -> System binaries for administrative commands
/bin -> Essential user binaries
/lib -> Shared libraries and kernel modules
/boot -> Stores files needed for booting the system
/usr -> Contains most user-installed applications and libraries.
/var -> Stores logs, caches, and temporary files that change frequently.
/etc -> Stores system configuration files.
/opt -> Used for installing optional third-party software

Understanding User Management

Creating users

There are 2 ways you can create a new user: useradd or adduser
useradd-> Directly modifies system files like /etc/passwd, /etc/shadow, and /etc/group to create a new user but you need to specify all options manually and by default it doesn't create a home directory unless you specify the -m flag. You also have to manually set the password for the new user using the passwd command after creating the user. Useful when writing scripts as it doesn't prompt for additional details.

adduser-> It provides a user-friendly, interactive experience by prompting you to enter a password and additional user details like full name, phone, etc. It automatically creates the home directory and uses configuration from /etc/adduser.conf for defaults.

In my case this command wasn't available by default and I had to install it using apt install adduser. You can check if you have it installed in /sbin

To see which users have been created you can check the /etc/passwd file.
User passwords are encrypted and stored in the etc/shadow file. Passwords cant be decrypted once created but can be reset using sudo passwd username.

Switching users

When switching to another user you can use either su username or su - username.
su username allows you to become that user but keep your current environment such as paths and variables and is useful for quick command execution.
su - username means you fully switch to the other user's environment including their paths, shell settings and any startup scripts.

Groups

Groups are used to organise users and manage permissions their collectively.
groupadd-> to create a new group
cat /etc/group -> to view groups
usermod -aG groupname username -> to add a user to a group
gpasswd -d username groupname -> to remove a user from a group

Understanding File Management

File Navigation

h – Move left
l – Move right
j – Move down
k – Move up
0 – Move to the beginning of the line
^ – Move to the first non-blank character of the line
$ – Move to the end of the line
w – Move to the next word
b – Move to the previous word
gg – Move to the start of the file
G – Move to the end of the file
:n – Move to line number n

Editing Text

x – Delete a character
X – Delete a character before cursor
dw – Delete a word
dd – Delete a line
d$ – Delete from cursor to end of line
d0 – Delete from cursor to beginning of line
D – Delete from cursor to end of line
u – Undo last action
Ctrl + r – Redo an undone change
yy – Copy (yank) a line
yw – Copy (yank) a word
p – Paste after the cursor
P – Paste before the cursor

Working with Multiple Files

:e filename – Open a new file
:w – Save file
:wq – Save and exit
:q! – Quit without saving
:split filename – Split screen horizontally and open another file
:vsplit filename – Split screen vertically
Ctrl + w + w – Switch between split screens

File Permissions

Change file permissions with chmod for users, groups and others.
r = 4
w = 2
x = 1

Change ownership using chown
Change user: chown user filename
Change user and group: chown user:group filename
Change group: chown :group filename or chgrp newgroup filename

ITRS image

Monitor Multi-Step User Journeys – Receive Immediate Alerts – Free 30-Day Trial

Get early warnings when logins, checkouts, or payments fail. Monitor from 360+ global locations using real ISP connections. Set up your first monitor in under 2 minutes.

Start Free Trial

Top comments (0)

👋 Kindness is contagious

Delve into this thought-provoking piece, celebrated by the DEV Community. Coders from every walk are invited to share their insights and strengthen our collective intelligence.

A heartfelt “thank you” can transform someone’s day—leave yours in the comments!

On DEV, knowledge sharing paves our journey and forges strong connections. Found this helpful? A simple thanks to the author means so much.

Get Started