Linux Basics Explained: From OS Concepts to Essential Commands

Table of contents
- π§ What is Linux?
- π‘ What is an Operating System?
- π§° Types of OS (Operating Systems)
- π Linux Distributions
- π§ History of Linux
- π§© Kernel & Shell
- π₯οΈ Terminal and User Privileges
- π§ Essential Linux Commands
- πΉ Processes
- π Hardware Commands
- π§ Linux File and Folder Commands
- π Editing Files with Vim Editor
- π€ User, Group, and Text Commands
- Whenever we created a user, Automatically group also created
- π Using grep to Search
- π File Ownership and Permissions
- π Searching Files & Folders
- βοΈ Terminal Productivity Tips
- π Conclusion

Whether you're a DevOps enthusiast, a developer, or a curious beginner, understanding Linux is crucial in todayβs tech world. In this post, weβll walk through the foundational concepts of Linux, its history, distributions, and key commands every user should know.
π§ What is Linux?
Linux is a free and open-source operating system (OS) known for its high security and multitasking capabilities. It's widely used in:
Servers
Embedded systems
Supercomputers
Smartphones
IoT devices
π‘ What is an Operating System?
An Operating System acts as an interface between hardware and the user. Every application β like web browsers, notepads, or games β needs an OS to run.
π§° Types of OS (Operating Systems)
Single-user OS
Multi-user OS
Distributed OS
Real-time OS
Mobile OS
π Linux Distributions
Different communities and companies have customized Linux and released them as distributions (distros):
Ubuntu
RedHat
Debian
CentOS
Fedora
OpenSUSE
Kali Linux
Rocky Linux
Amazon Linux
Each has its own package manager and default settings but shares the same Linux kernel.
π§ History of Linux
In 1991, a Finnish student named Linus Torvalds created the Linux Kernel as a personal project. Initially named "Freax", it was later renamed to Linux.
Today, Linux powers everything from smartphones and web servers to washing machines and cars.
π§© Kernel & Shell
πΈ Kernel
The kernel is the heart of the OS. It manages hardware, memory, and process control.
πΈ Shell
The shell is the interface that interprets user commands. There are two types:
CLI (Command Line Interface) β terminal-based
GUI (Graphical User Interface) β mouse and window-based
π₯οΈ Terminal and User Privileges
By default, users operate as a standard user like ec2-user
. To perform admin actions, switch to root user using:
sudo -i # Switch to root user
exit # Exit back to regular user
π§ Essential Linux Commands
πΉ System Commands
uname # Show OS type
uname -r # Show kernel version
uname -a # Show all OS info
clear # Clear terminal
uptime # Show system uptime
hostname # Display system DNS name
hostnamectl # Change system hostname
πΉ IP and Network
ip addr # Show IP addresses
ip route # Show routing table
ifconfig # Alternative for ip addr
πΉ Time and Date
date # Show current date and time
timedatectl # View timezone info
timedatectl set-timezone Asia/Kolkata # Set timezone
You can also use date +
with various options to format output:
date +"%d-%m-%Y" # Custom date format
date +"%A" # Day of the week
ποΈ Formatted date
Command Options in Linux
| Command | Description |
|---------------------|--------------------------------------------------------|
| `date` | Shows system date and timestamp |
| `date +"%d"` | Prints day of the month (01β31) |
| `date +"%m"` | Prints the month of the year (01β12) |
| `date +"%y"` | Prints the last two digits of the year |
| `date +"%H"` | Prints the hour (00β23) |
| `date +"%M"` | Prints the minute of the hour (00β59) |
| `date +"%S"` | Prints the seconds count in the minute (00β60) |
| `date +"%D"` | Prints the date in MM/DD/YY format |
| `date +"%F"` | Prints the full date as YYYY-MM-DD |
| `date +"%A"` | Prints the day of the week (e.g., Monday) |
| `date +"%B"` | Prints the full month name (e.g., JanuaryβDecember) |
| `who` | Prints info about the default user in the system |
πΉ User Info
who # See logged-in users
whoami # See current user
πΉ Processes
ps # View running processes
kill -9 PID # Kill a process by ID
π Hardware Commands
lscpu # CPU info
lsblk -a # Block devices info
free -m # Memory in MB
df -h # Disk usage
Command | Description | Example Usage |
lscpu | Displays detailed CPU architecture information (cores, threads, model). | `lscpu |
lsblk -a | Lists all block devices (disks, partitions) with tree-like hierarchy. | `lsblk -a |
free | Shows RAM usage in kilobytes (KB) (total, used, free, cache). | `free |
free -m | Displays RAM usage in megabytes (MB) (easier to read). | free -m |
df -h | Reports disk space usage in human-readable format (GB/MB). | `df -h |
π§ Linux File and Folder Commands
π 1. Creating Files
Use the touch
command to create one or multiple files:
touch filename
touch aws azure gcp
touch linux{1..5} # Creates linux1, linux2, ..., linux5
β 2. Deleting Files
Remove files using rm
. Be cautious β deleted files don't go to a recycle bin!
rm filename # Prompts before deleting
rm -f filename # Force delete (no prompt)
rm -f aws azure gcp # Delete multiple files
rm -f linux{1..5} # Delete linux1 to linux5
rm -f *.txt # Delete all .txt files
rm -f a* # Delete files starting with 'a'
rm -f * # Delete all files in current directory
π 3. Creating Folders
To create directories (folders), use mkdir
:
mkdir foldername
mkdir git maven jenkins
mkdir docker{1..5} # docker1 to docker5
Create nested directories with the -p
option:
mkdir -p aws/azure/gcp/ccit
ποΈ 4. Deleting Folders
Use rmdir
to remove empty folders:
rmdir foldername
rmdir git maven jenkins
rmdir docker{1..5}
rmdir * # Remove all empty folders
To remove folders and their contents, use:
rm -rf foldername
rm -rf * # β οΈ DANGEROUS: Deletes all files & folders
π 5. Changing Directories
Navigate through your file system:
cd foldername # Enter a folder
cd # Go to home directory
cd - # Go to previous directory
cd ../ # Go one directory up
cd ../../ # Go two directories up
ποΈ 6. Listing Files and Folders
To see whatβs inside your directory:
ls # Lists names only
ll # Lists detailed info (permissions, size, etc.)
Check contents of a specific folder:
ll foldername
π 7. Copying Files
The cp
command is used to copy files:
cp file1 file2 # Overwrites file2 with contents of file1
To append content instead of overwriting, use:
cat file1 >> file2 # Appends content of file1 to file2
π 8. Moving or Renaming Files
The mv
command can move or rename:
mv file1 file2 # Renames file1 to file2 or moves it
π§ Pro Tip: Use Brace Expansion to Save Time
Linux supports brace expansion for patterns:
mkdir project{1..3} # Creates project1, project2, project3
touch test{A..C}.txt # Creates testA.txt, testB.txt, testC.txt
π Final Thought for Linux File and Folder Commands
The Linux command line can be intimidating at first, but once you get comfortable with file and folder operations, everything else becomes easier. Try these commands in your terminal, and you'll quickly gain confidence in managing your system efficiently.
π¬ Do you use any Linux shortcuts that save you time? Share them in the comments below!
π Editing Files with Vim Editor
The vim
(or vi
) editor is built into most Linux systems and is incredibly powerful once you learn the basics.
πΉ Opening βvimβ Files
vim filename
π― Vim Modes
Command Mode β Default (copy, delete, move, search)
Insert Mode β Type and edit text
Save & Quit Mode β Save changes and exit
πΉ Navigating Inside Vim
gg # Go to first line
G # Go to last line
M # Middle of the file
4gg # Go to line 4
:set number # Show line numbers
πΉ Insert Mode
i # Start inserting at cursor
A # Insert at end of line
I # Insert at start of line
o # New line below
O # New line above
πΉ Command Mode Actions
yy # Copy current line
4yy # Copy 4 lines
p # Paste copied content
10p # Paste 10 times
dd # Delete current line
5dd # Delete 5 lines
u # Undo
Ctrl + r # Redo
/word # Search forward
?word # Search backward
:%s/old/new/ # Replace all occurrences
πΉ Save & Exit
:w # Save
:q # Quit
:q! # Quit without saving
:wq # Save and quit
:wq! # Force save and quit
π§ Bonus Tip: When to Use cat
cat filename # View file content
cat > filename # Overwrite file content
cat >> filename # Append content to file
β οΈ The
cat
command canβt edit content. For edits, always use Vim or Nano.
β¨ Final Words Vim
Linux is a powerful tool β and knowing your way around the file system and text editors like Vim gives you superpowers. From managing files to editing configuration files, this guide gives you a solid foundation.
Got stuck? Want a Vim cheat sheet? Drop a comment or share your favorite Linux trick!
π€ User, Group, and Text Commands
π₯ User Management
cat /etc/passwd # List users
or
getent passwd # List users
id username #find particular user is available or not
useradd username # Add user (creates home dir + group)
useradd -M username # Add user without home folder
userdel username # Delete user (keeps folder)
userdel -r username # Delete user + folder
passwd username # Set user password
su - username # Switch to user
Whenever we created a user, Automatically group also created
πͺ Group Management
cat /etc/group # List groups
or
getent group #list group
groupadd groupname # Add group
groupdel groupname # Delete group
usermod -aG groupname username # Add user to group
β οΈ Donβt forget the
-a
flag withusermod
. Without it, existing group memberships are removed.
π Advanced File Reading
cat filename # View file
cat -n filename # View with line numbers
head filename # Top 10 lines
tail filename # Last 10 lines
head -n 15 filename # First 15 lines
tail -n 20 filename # Last 20 lines
sed -n '15,30p' filename # Print lines 15β30
π Using grep to Search
grep full form βglobal regular expression printβ : It is used to search for a word in a file
grep "word" filename # Search for word
grep -n "word" filename # With line numbers
grep -c "word" filename # Count occurrences
grep -i "word" filename # Case-insensitive
grep -in -e "word" -e "word" filename #searching for multiple words with line numbers
π File Ownership and Permissions
Basic knowing knowledge of file permissions
r = read ----> 4
w = write ----> 2
x = execute ----> 1
- = nothing ----> 0
-----------------------------------------------------------------------------------------------------------------------------
for example1 : -(rw-)(r--)(r--) = {644} is the default permission
| | |
user group others
user : rw- = [4+2+0=6]
group : r-- = [4+0+0=4]
other : r-- = [4+0+0=4]
for example2 : -(rwx)(--x)(-w-) = {712} is the file permission
| | |
user group others
user : rwx = [4+2+1=7]
group : --x = [0+0+1=1]
other : -w- = [0+2+0=2]
π€ Change File Owner
chown user filename
chgrp group filename
chown user:group filename
chown user:group file1 file2 file3
chown user:group folder # Folder only
chown user:group folder/* # Files only
chown -R user:group folder # Files + folders recursively
π Change File Permissions
chmod 754 filename
chmod 777 file1 file2 file3
chmod 654 folder # Folder only
chmod 567 folder/* # Files only
chmod -R 123 folder # Files + folders recursively
π Searching Files & Folders
π Using find
find path -name filename
find . -name file # In current directory
find /proc/ -name filename # In /proc
find . -type d -name folder # Find folder
find . -type f -name file1.txt # Find file
find . -type f -perm 777 # Files with 777 permission
find . -type f ! -perm 777 # Files NOT with 777 permission
find / -user username # Files owned by user
find / -group groupname # Files owned by group
π Using locate
sudo updatedb # Update database first
locate filename
π
find
vslocate
:
find
searches live in paths you specify
locate
searches a cached database (faster, less precise)
βοΈ Terminal Productivity Tips
Task | Shortcut |
Delete entire command | Ctrl + U |
Cut after cursor | Ctrl + K |
Go to beginning | Ctrl + A |
Go to end | Ctrl + E |
Reverse search history | Ctrl + R |
Show command history | history |
[Download the Linux Cheat Sheet PDF](https://drive.google.com/file/d/1vIbY23HLPY51dRI1muc6yrX62E7BNyDr/view?usp=sharing)
- Alternatively, embed the PDF using an iframe (if supported by your hosting service):
<iframe src="https://drive.google.com/file/d/1vIbY23HLPY51dRI1muc6yrX62E7BNyDr/view?usp=sharing" width="100%" height="500px"></iframe>
π Conclusion
Linux is more than just an OS β it's a powerful ecosystem that empowers developers, system admins, and organizations worldwide. Whether you're managing a server or developing an app, mastering the Linux basics and commands is your first step to unlocking its full potential.
β Follow me for more Linux & DevOps content!
π Leave a comment if you found this helpful or want more command deep-dives!
Subscribe to my newsletter
Read articles from Shanmukh Karra directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Shanmukh Karra
Shanmukh Karra
Hi there! π I'm Shanmukh Karra, a passionate DevOps Engineer with a strong foundation in modern infrastructure automation, CI/CD, and cloud technologies. As a fresher, I am eager to apply my skills in Git, Linux, Jenkins, Maven, Docker, Kubernetes, Terraform, AWS Cloud, Prometheus, and Grafana to build scalable, efficient, and resilient systems. I thrive in environments that encourage automation, continuous improvement, and collaboration between development and operations teams. My goal is to streamline software delivery pipelines, optimize cloud infrastructure, and ensure high availability through Infrastructure as Code (IaC), monitoring, and DevOps best practices. What I Bring to the Table: β Version Control & CI/CD: Proficient in Git, Jenkins, and Maven for seamless code integration and deployment. β Containerization & Orchestration: Hands-on experience with Docker and Kubernetes for scalable microservices. β Infrastructure as Code (IaC): Skilled in Terraform for provisioning and managing cloud resources. β Cloud & Monitoring: Familiar with AWS Cloud, along with Prometheus & Grafana for observability and performance tracking. β Linux & Scripting: Strong command over Linux environments and scripting for automation. I'm constantly learning and experimenting with new tools to stay ahead in the ever-evolving DevOps landscape. Let's connect and build something amazing together! π