Part 1: Introduction and Essential Linux Commands
Linux is a powerful operating system that's the backbone of many modern infrastructures, especially in the DevOps world. If you're a budding DevOps engineer, mastering Linux and its commands is essential. In this series, we’ll explore Linux basics and the commands you’ll use regularly.
I’m following a YouTube playlist titled "Linux for DevOps Engineer" by TrainWithShubham as a guide. For this part, we’ll focus on basic commands in Linux to get started.
What is Linux?
Linux is an open-source operating system that runs on a kernel. It’s popular in DevOps because it’s:
Free and community-driven.
Highly customizable.
Widely used in server environments.
In these blogs, we’ll work with Ubuntu, one of the most user-friendly Linux distributions.
Understanding the Bash/Terminal
The bash shell or terminal is where all the magic happens. It’s an interface where you type commands to interact with the operating system.
Basic Linux Commands
Here are some fundamental commands to get you started:
User and Session Commands
$ whoami
: Displays the current user.
Example Output:ubuntu
$ sudo su -
: Switch to the root user (administrator privileges).$ exit
: Log out from the current user session.
Date and Time
$ date
: Shows the current date and time.
Example Output:Sun Dec 08 05:32:10 UTC 2024
Working with Directories
$ mkdir dir_name
: Creates a new directory (folder).$ cd dir_name
: Changes the working directory todir_name
.$ cd ..
: Navigates back to the parent directory.$ pwd
: Prints the current working directory path.$ rmdir dir_name
: Removes an empty directory.
Managing Files
$ touch file.txt
: Creates a new file namedfile.txt
.$ nano file.txt
or$ vi file.txt
: Opensfile.txt
in a text editor.$ rm file.txt
: Deletes the file namedfile.txt
.$ mv source destination
: Moves a file from the source to the destination.
Viewing and Listing Files
$ ls
: Displays the list of files and directories in the current directory.$ ls -la
: Shows detailed information about files, including hidden ones.
Echo and History
$ echo "Hello World"
: PrintsHello World
on the terminal.$ history
: Displays a list of previously entered commands.
Example Session
Here’s a quick example of how these commands might look in action:
$ whoami
ubuntu
$ mkdir projects
$ cd projects
$ touch readme.txt
$ ls
readme.txt
$ nano readme.txt
# Edit and save the file using nano.
$ pwd
/home/ubuntu/projects
$ cd ..
$ rmdir projects
Key Takeaways
Linux is foundational for DevOps engineers.
The bash terminal is your gateway to interacting with the system.
Practice these commands to build confidence and familiarity.
In the next part, we’ll dive deeper into file permissions, process management, and other essential topics. Stay tuned!