🌟 Fundamentals of Linux: A Non-IT Friendly Guide 🐧


🌟 Fundamentals of Linux: A Non-IT Friendly Guide 🐧


Linux might sound complex, but it’s all around us! From powering websites to your Android phone, Linux is everywhere. Let’s break it down in simple terms with step-by-step details for beginners.



 πŸ‘€ What is Linux?

Linux is an operating system (OS) that acts like the brain of a computer. It connects hardware (like your keyboard or mouse) with software (like a browser or app) to make everything work together seamlessly.

    Why is Linux Unique?

πŸ’‘ Open-Source:  Free to use, modify, and share.

🌍 Community-Driven:  Developed and improved by people worldwide.

πŸ”’ Secure:  Reliable and trusted for personal and professional use.

πŸ›  User Management: Working with Linux Users

  •  Switching Users

    To become the root user (admin with all permissions):  

      sudo su

    To exit root mode:  

     Exit

  • Adding a New User

1. Create a new user with a home directory:

    sudo useradd -M <username>

2. Set a password for the user:

    sudo passwd <username>

3. Switch to the new user:

    su  <username>

4. Confirm the user with:

    Whoami

  • Viewing All User's

To see all users on the system:

    cat /etc/passwd

  • Resetting Passwords

To reset a user’s password:

    sudo passwd <username>

  • Delete user

    sudo userdel <username>

  • Group add

 create manually –

    sudo groupadd devops create users user 1 user 2 user 3

    sudo gpasswd –a user 1 user name devops -a add user

    cat /etc/group  ( check group )

    check the user add on group


    πŸ“‚ File Permissions & Ownership

    Understanding File Permissions

    Each file or folder has three types of permissions:

    πŸ“– Read (r): View the contents of a file.

    ✏️ Write (w): Edit or modify a file.

    ⚙️ Execute (x): Run a file as a program.

Example Permission Structure:

    -rw-r--r--

    -   Owner: Can read and write.

    -   Group: Can only read.

    -   Others: Can only read.


Changing File Permissions

Use the chmod command to modify permissions. Each permission is represented by a number:

  •  ( Owner Read-only, Group Write-only, Others Execute-only )

    -   Read (r):  4

    -   Write (w):  2

    -   Execute (x):  1

πŸ’ͺAdd the numbers to set permissions:

  •  ( Full Access for Owner, Read/Write for Group, Read/Execute for Others )

-   7  = Read + Write + Execute

-   6  = Read + Write

-   5  = Read + Execute

  • ( Read-only for the Owner )

sudo chmod 400 <filename>

Chmod table

    Directory Format

drwxrwxr-x ( d stands for- directory )

    To change the owner of a file:

sudo chown <username> <filename>

πŸ”Ž Finding Files and Searching in Linux

1. Finding Files

  • To locate a file:

find <directory> -name <filename>

Example: Find all .txt files in the home directory:

find /home -name *.txt

  • Searching Within Files

1. To search for specific words inside a file:

grep <word> <file>

Example: Find all lines containing “error” in a log file:

grep error logfile.log

  • Case-Insensitive Search

Use the -i flag to ignore case:

grep -i <word> <file>

πŸ…Editing Text with sed

The sed command is a stream editor used to modify files.

Replacing Text To replace all instances of a word:

sed -i 's/oldword/newword/g' <filename>

Example: Replace “password123” with “****” in passwords.txt:

sed -i 's/password123/****/g' passwords.txt

πŸ”¬Bonus Commands

1. Downloading Files with wget

To download a file from the internet:

wget <URL>

2. Viewing Logs

To read and filter log files:

grep <word> logfile.log

3. Using awk for Data Processing

The awk command helps extract specific data from files.

-   To print the first column of a file:

awk '{print $1}' <filename>

-   To filter by a keyword and print specific columns:

awk '/<keyword>/ {print $1, $2}' <filename>

  


The Mighty Text Editor: Vim

Vim is a highly configurable, efficient text editor that is particularly loved by developers and system admins. Reason being, whether it be a config file or code that you're editing, allows you to do so would meshed up in a way as you've never used, so allows you to edit and create in a rapid fire way, which is why a lot of developers use Vim, because of its speed. πŸ› ️

πŸ“‹Key Features of Vim

πŸ–Š️ Modes:

Normal Mode: Navigate and manipulate text.

Insert Mode:  Add text.

Visual Mode:  Select and edit blocks of text.

πŸ”„Undo and Redo: Easily fix mistakes.

Undo: u

Redo: Ctrl + r

πŸ”Search and Replace:

Search: /search_term

Replace: :%s/old/new/g

πŸ’» Usage of Vim

Starting Vim --> Open a file --> vim filename --> Open without a file --> vim

    Navigating in Vim

    Move cursor:  

    h:Left

    l: Right

    k: Up

    j: Down

    Jump to line:

    gg: First line

    G:  Last line

    :n:  Go to line number n

    Editing Text

    1. Enter Insert Mode:  

    i: Before the cursor

    a: After the cursor

    2. Delete:  

    x: Delete character

    dd: Delete line

   Saving and Exiting

    :w  -Save

    :wq -Save and Exit: 

    :q! -Exit without saving: 
🌟Benefits of Vim

πŸ’¨ Speed: Designed for fast editing with minimal keystrokes.

🧠 Lightweight: Uses very little system resources.

πŸ› ️ Customizable: Supports plugins, themes, and key mappings.

πŸ”’ Always Available: Pre-installed on most Linux/Unix systems.

🌐 Remote Editing: Perfect for editing files over SSH.

πŸ€” Why Choose Vim?

If you want a powerful, keyboard-driven text editor that improves productivity with practice, Vim is your go-to tool!

So,

Why Learn Linux?

Linux is:

-   ✅ Free and open-source.

-   ⚖️ Secure and reliable.

-   πŸ“Š Essential for understanding modern tech.

Try Linux Today!

-   Use a cloud service like AWS to launch an Ubuntu instance.

-   Experiment with commands and explore its features.

Conclusion

Linux is powerful yet simple when you take it step by step. Whether you’re managing users, searching files, or connecting to servers, Linux opens up endless possibilities. Dive in and discover the magic of Linux today! 🌐

Post a Comment

Previous Post Next Post