Day 6 of 100 Days of DevOps: Exploring Essential Linux Commands 🐧
Welcome to Day 6! Today, we’re diving into core Linux commands that every DevOps professional should know. By the end of this post, you’ll have practiced file management, system navigation, and even some basic troubleshooting.
Ready? Let's get started! 💪
Part 1: File & Directory Management 📁
Where am I?
Usepwd
to print your current working directory. This helps you know where you are in the Linux filesystem:pwd
See it All!
List everything (including hidden files) withls -a
. Hidden files can contain configurations or settings:ls -a
Create Nested Directories
Need to set up a folder structure? CreateA/B/C/D/E
in one go with the-p
flag. Try it out:mkdir -p A/B/C/D/E
Change Directories
Move to a directory usingcd
. Let’s navigate toA/B/C
:cd A/B/C
Make and Break a Directory
First, create a folder calledTestDir
:mkdir TestDir
Then remove it using
rmdir
(only works if empty):rmdir TestDir
Create a File
Usetouch
to make an empty file namedexample.txt
. This is handy for setting up new files or updating timestamps:touch example.txt
Copy and Move Files
Copyexample.txt
to a new file namedexample_copy.txt
:cp example.txt example_copy.txt
Then rename it using
mv
:mv example_copy.txt example_moved.txt
Finally, delete it:
rm example_moved.txt
Part 2: File Viewing & Editing 📄
View File Content
Usecat
to display everything inexample.txt
:cat example.txt
Need to Scroll?
For larger files,less
lets you scroll through content one page at a time:less example.txt
Get a Sneak Peek
Usehead
to show the first 10 lines ortail
for the last 10:head example.txt tail example.txt
Editing Time!
Openexample.txt
withnano
orvim
, two popular text editors. You’ll get familiar with both over time:nano example.txt vim example.txt
Part 3: Permissions & Ownership 🔐
Adjust Permissions
Want to set permissions?chmod 744
gives the owner read, write, and execute permissions, and read-only for others:chmod 744 example.txt
Change Owner
Usechown
to assign a new owner and group:chown user:group example.txt
Detailed Listing
Check out file permissions and ownership withls -l
:ls -l
Part 4: System Monitoring & Management 📊
What’s Running?
Thetop
command shows live processes, sorted by usage. Useq
to quit:top
Detailed Process List
ps aux
provides more detailed info about all running processes:ps aux
Disk and Directory Usage
Check available disk space withdf -h
:df -h
And use
du -sh .
to see the size of your current directory:du -sh .
Memory and Uptime
free -h
shows memory usage in a human-readable format:free -h
uptime
lets you know how long the system has been running:uptime
Additional Handy Commands 🛠️
Here are a few more must-know commands to boost your productivity:
Command Shortcuts
Make shortcuts withalias
. For example, turnls -la
into a quickll
:alias ll='ls -la'
Search Within Files
Look for specific text inside files usinggrep
:grep "search_term" example.txt
Find Files
Locate files by name withfind
:find /path/to/search -name "filename"
Archive Files
Compress a directory withtar
. This example creates a.tar.gz
archive:tar -czvf archive.tar.gz /path/to/directory
Download Files
Grab files from the internet withwget
:wget http://example.com/file.zip
Data Transfer
Fetch a file usingcurl
:curl -O http://example.com/file.zip
Get Help
Not sure about a command? Check the manual withman
:man ls
Conclusion
These commands are the backbone of Linux system management. Practicing them regularly will make you comfortable with navigating and managing your environment.
Keep sharing your progress and questions in the comments, and let’s continue learning together. Happy learning!