ARTICLE

Beginner’s Guide to Linux Basic Commands for DevOps

Beginner’s Guide to Linux Basic Commands for DevOps

 



When you step into the world of DevOps, cloud computing, or software development, the graphical user interface (GUI) takes a backseat. The terminal becomes your primary steering wheel, and Linux commands are the fuel.

Navigating a terminal can feel like learning a foreign language at first, but it boils down to a core set of foundational commands. Let's break down the essential Linux commands you need to master, grouped by what they actually do.

1. Navigation & File Management

pwd (Print Working Directory)

Shows you exactly which folder you are currently standing in.

$ pwd
/home/ubuntu/devops_project

ls (List)

Lists files and folders. Use -la to show detailed information and hidden files (files starting with a dot).

# Basic list
$ ls
app.py  config.ini  logs

# Detailed list (shows permissions, size, owner)
$ ls -la
drwxr-xr-x  3 ubuntu ubuntu 4096 Jul 16 10:00 .
-rw-r--r--  1 ubuntu ubuntu  245 Jul 16 10:05 app.py
-rw-r--r--  1 ubuntu ubuntu 1024 Jul 16 10:02 .env

cd (Change Directory)

Moves you around the file system.

# Move into a folder
$ cd logs

# Move up one level (backwards)
$ cd ..

# Jump straight to your user's home directory
$ cd ~

mkdir (Make Directory)

Creates a new folder. Use -p to create nested parent folders at once.

# Create a single folder
$ mkdir scripts

# Create nested folders (e.g., source/assets/images)
$ mkdir -p src/assets/images

rm (Remove)

Deletes files or directories. Be careful: Linux doesn't have a recycle bin!

# Delete a single file
$ rm temp.log

# Force delete an entire folder and everything inside it safely (-r recursive, -f force)
$ rm -rf old_project/

cp (Copy)

Copies files or directories. Use -r to copy folders.

# Copy a file and give it a new name
$ cp config.yaml config.yaml.bak

# Copy an entire folder to a backup destination
$ cp -r src/ src_backup/

mv (Move / Rename)

Moves a file to another location, or renames it if kept in the same folder.

# Rename a file
$ mv deployment.txt live-deployment.yaml

# Move a file into a specific directory
$ mv script.sh scripts/


2. Reading & Inspecting Files

cat (Concatenate)

Dumps the entire content of a file into the terminal screen.

$ cat version.txt
v2.4.1-build-882

less

Opens large files interactively without breaking your terminal page or clogging system memory.

$ less system.log
# [Opens an interactive view. Press the Arrow keys to scroll up/down, press 'q' to exit]

head

Shows the very top (first 10 lines) of a file.

$ head configuration.conf
# Displaying the first 10 lines of the file...
server {
    listen 80;
    server_name localhost;

tail

Shows the bottom (last 10 lines) of a file. Use -f to watch logs update in real time.

# Show last 10 lines
$ tail application.log

# Live stream incoming logs (ideal for debugging running applications)
$ tail -f application.log


3. Finding Files & Binaries

find

Walks through directories to find specific files based on criteria like names or extensions

# Search for all files ending in ".json" inside the current folder (".")
$ find . -name "*.json"
./package.json
./config/settings.json

locate

Finds files instantly using a pre-indexed background database (much faster than find).

$ locate nginx.conf
/etc/nginx/nginx.conf
/usr/share/doc/nginx/nginx.conf

which

Tells you the exact system path of an executable/binary program you are running.

$ which docker
/usr/bin/docker


4. Text Processing & Data Manipulation

grep (Global Regular Expression Print)

Searches for a specific word or pattern inside a text stream or file.

# Find all lines containing the word "CRITICAL" inside an application log
$ grep "CRITICAL" application.log
2026-07-16 12:00:05 [CRITICAL] Database connection lost!

awk

Slices structured text outputs into columns. By default, it uses spaces to separate columns.

# Imagine running a command that outputs columns, and you only want the 2nd column ($2)
$ echo "John 25 Engineer" | awk '{print $2}'
25

sed (Stream Editor)

Finds and replaces text inside a file instantly without opening an editor.

# Replace "localhost" with "10.0.0.5" inside settings.txt
$ sed -i 's/localhost/10.0.0.5/g' settings.txt

sort & uniq

sort arranges lines alphabetically/numerically. uniq filters out identical consecutive lines. They are almost always used together.

# Suppose names.txt contains: Charlie, Alpha, Charlie
$ sort names.txt
Alpha
Charlie
Charlie

# Sort them and extract only the unique values
$ sort names.txt | uniq
Alpha
Charlie

cut

Slices out specific parts of lines based on a delimiter character.

# Split by a hyphen (-) delimiter (-d) and take the first field (-f1)
$ echo "prod-web-server-01" | cut -d'-' -f1
prod

xargs

Takes the output of a command and loops it into another command as arguments.

# Find all files ending in ".tmp" and delete them using xargs
$ find . -name "*.tmp" | xargs rm


Comments