Linux Basics Explained: From OS Concepts to Essential Commands

Shanmukh KarraShanmukh Karra
11 min read

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
CommandDescriptionExample Usage
lscpuDisplays detailed CPU architecture information (cores, threads, model).`lscpu
lsblk -aLists all block devices (disks, partitions) with tree-like hierarchy.`lsblk -a
freeShows RAM usage in kilobytes (KB) (total, used, free, cache).`free
free -mDisplays RAM usage in megabytes (MB) (easier to read).free -m
df -hReports 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

    1. Command Mode – Default (copy, delete, move, search)

      1. Insert Mode – Type and edit text

      2. 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 with usermod. 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

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 vs locate:

  • find searches live in paths you specify

  • locate searches a cached database (faster, less precise)

βš™οΈ Terminal Productivity Tips

TaskShortcut
Delete entire commandCtrl + U
Cut after cursorCtrl + K
Go to beginningCtrl + A
Go to endCtrl + E
Reverse search historyCtrl + R
Show command historyhistory

[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!

1
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! πŸš€