First Week in DevOps: Mastering Linux Basics

This week, I delved into the core of Linux, specifically on CentOS Stream 9, focusing on directories, files, and the fundamental idea that everything in Linux is a file. I worked through navigation commands, file management, process control, and more. Below, I’ll walk you through why Linux is crucial in DevOps, followed by a breakdown of some essential commands with code blocks and simple explanations.
🔍 Why Linux is Important for DevOps and System Administration
Linux is the backbone of most servers and DevOps environments. It’s open-source, highly customizable, and offers great control, making it a must-know for anyone in the DevOps field. Whether you're automating tasks, managing servers, or deploying applications, knowing Linux commands allows you to interact directly with the system, making it more efficient and powerful than relying on GUI-based tools.
Getting familiar with Linux interfaces is essential because you’ll work in environments that depend on the CLI (Command Line Interface). The commands will become second nature once you get the hang of it.
Essential Linux Commands with Code Blocks and Explanation
Navigation and File Management Basics
pwd– Print Working Directory: This command shows the current directory you're in. It's useful when you're navigating through the filesystem and want to check your current location.$ pwd /home/userExplanation: The terminal returns
/home/user, which is the directory you’re currently inside. It’s like checking your location on a map.ls– List Files: Lists all files and directories in the current directory. You can add flags like-lfor a detailed view or-ato include hidden files.$ ls Documents Downloads PicturesExplanation: This lists the contents of the current directory. Here, it shows three directories: Documents, Downloads, and Pictures.
cd <directory>– Change Directory: Allows you to navigate to another directory. For example,cd Documentswould take you into the Documents folder.$ cd Documents $ pwd /home/user/DocumentsExplanation: Here, you use
cdto go to the "Documents" directory, andpwdconfirms your new location inside it.mkdir <directory_name>– Make Directory: This command creates a new directory (folder).$ mkdir my_folder $ ls Documents Downloads my_folderExplanation: The
mkdircommand creates a folder calledmy_folderin the current directory. After runningls, you can see it listed.touch <file_name>– Create a New File: This command creates a new empty file.$ touch example.txt $ ls Documents Downloads example.txtExplanation: The
touchcommand creates a new file namedexample.txt. It doesn’t have any content at first; it’s just an empty file.cp <source> <destination>– Copy Files/Directories: This command copies a file or directory from one location to another.$ cp example.txt my_folder/ $ ls my_folder example.txtExplanation: This copies
example.txtintomy_folder. You can verify withlsto check that the file is now inside the folder.mv <source> <destination>– Move or Rename Files: This command either moves files from one place to another or renames them.$ mv example.txt renamed_example.txt $ ls renamed_example.txtExplanation: Here,
mvis used to renameexample.txttorenamed_example.txt.rm <file_name>– Remove Files: Deletes a file permanently.$ rm renamed_example.txt $ lsExplanation: The
rmcommand deletes the file. After executing it, you’ll no longer seerenamed_example.txtin the directory.
Viewing and Editing Files
cat <file_name>– Concatenate and Display File Content: Displays the contents of a file in the terminal.$ cat greetings.txt Hello, Linux!Explanation: The
catcommand outputs the content ofgreetings.txtto the terminal. In this case, it shows "Hello, Linux!"nano <file_name>– Text Editor: Opens the file in the nano text editor, allowing you to edit it.$ nano file.txt
Explanation:
nanoopens a file in the terminal editor. You can make changes, save, and exit with simple keyboard commands.echo "text" > <file_name>– Write Text to a File: Writes or overwrites text into a file. Use>>to append.$ echo "Hello, Linux!" > greetings.txt $ cat greetings.txt Hello, Linux!Explanation: The
echocommand writes "Hello, Linux!" into the filegreetings.txt. If the file already existed, it would overwrite its content.
Process Management Commands
ps– Show Running Processes: Displays a snapshot of the current processes running on your system.$ ps PID TTY TIME CMD 1234 pts/0 00:00:01 bash 2345 pts/0 00:00:00 psExplanation: This shows the current processes, with
PIDrepresenting the unique Process ID. You can use it to monitor running programs.top– Interactive Process Viewer: Provides real-time updates on processes, system resource usage (CPU, memory), and more.$ top # (Displays a real-time process list, press `q` to exit)
Explanation:
topgives an interactive list of processes sorted by resource usage. You can monitor how much memory and CPU different processes are using.kill <PID>– Kill a Process: Terminates a process using its PID (Process ID).$ kill 1234Explanation: The
killcommand is used to stop a process. In this case, it ends the process with PID 1234.
Package Management with DNF and RPM (CentOS Stream 9)
Since CentOS Stream 9 uses the DNF package manager, here are some commands to manage software packages.
dnf update– Update System: Updates all installed packages to the latest available versions.$ sudo dnf updateExplanation: This command checks for updates for all installed packages and applies them, ensuring your system is up to date.
dnf install <package>– Install a Package: Installs a new package from the CentOS repository.$ sudo dnf install nanoExplanation: Installs the
nanotext editor, allowing you to edit files from the terminal.rpm -ivh <package.rpm>– Install an RPM Package: Installs a package using its.rpmfile.$ sudo rpm -ivh example.rpmExplanation:
rpminstalls an RPM package manually. The-iflag installs,-vprovides verbose output, and-hshows hash marks to indicate progress.rpm -e <package>– Uninstall an RPM Package: Removes an installed RPM package.$ sudo rpm -e exampleExplanation: This command removes the package named
examplefrom your system.
This week’s journey has equipped me with a solid understanding of Linux commands. These fundamental tools are essential for anyone working in DevOps or system administration. As I continue to practice, Linux will become an even more powerful tool in my DevOps toolkit. 🐧



