๐Ÿ“˜ Linux Summary Guide

 ๐Ÿ“˜ Linux Summary Guide

I. What is Linux?

Linux is an open-source, Unix-like operating system kernel used widely in servers, desktops, embedded systems, and cloud environments. Popular Linux distributions include Ubuntu, CentOS, RHEL, Debian, Fedora, and Alpine.


II. Linux Architecture Overview

  1. Kernel

    • The core of the OS that manages hardware, processes, memory, I/O, file systems, and system calls.

  2. System Libraries

    • Provide functions for programs to interact with the kernel (e.g., GNU C Library glibc).

  3. System Utilities

    • Basic tools for managing the system (ls, cat, mkdir, etc.).

  4. Shell

    • Command interpreter (e.g., Bash, Zsh) used to interact with the system.

  5. User Applications

    • Programs installed by users (e.g., Vim, Docker, Firefox).


III. File System Hierarchy


DirectoryDescription
/Root directory
/binEssential binary commands
/sbinSystem binaries
/etcConfiguration files
/homeUser home directories
/varVariable data (logs, spool files)
/usrUser programs and data
/tmpTemporary files
/devDevice files
/procKernel and process info (virtual FS)
/bootBoot loader and kernel files

IV. Basic Linux Commands

Navigation

bash

pwd # Show current directory cd /path # Change directory ls -l # List directory contents

File Management

bash

touch file.txt # Create file mkdir dir/ # Create directory cp file1 file2 # Copy file mv file1 /path/ # Move/rename rm file.txt # Delete file

Viewing & Searching

bash

cat file.txt # View file less file.txt # Scroll through file grep "text" file.txt # Search text in file find / -name "*.log" # Search by name

V. User and Permission Management

Users & Groups

bash

adduser user1 # Add user passwd user1 # Set password usermod -aG sudo user1 # Add to sudo group id user1 # View user info

Permissions

bash

chmod 755 file.sh # Set file permissions chown user:group file.txt # Change owner ls -l # View permissions
SymbolMeaning
rRead
wWrite
xExecute

VI. Process Management

bash

ps aux # List processes top # Real-time process view kill <pid> # Kill process htop # Interactive process viewer nice/renice # Adjust process priority

VII. Package Management

Debian/Ubuntu

bash

apt update && apt upgrade apt install nginx apt remove nginx

RHEL/CentOS

bash

yum install nginx yum remove nginx dnf update

VIII. System Services (Systemd)

bash

systemctl status nginx systemctl start nginx systemctl stop nginx systemctl restart nginx systemctl enable nginx # Start on boot

IX. Networking

bash

ip a # View IP addresses ip r # View routing table ping google.com # Check connectivity netstat -tuln # Show open ports ss -tuln # Faster alternative hostnamectl # View/modify hostname

X. Disk and File Systems

bash

df -h # Disk usage du -sh * # Directory size lsblk # Block devices mount /dev/sdb1 /mnt # Mount drive umount /mnt # Unmount fdisk -l # Partition info

XI. Logs and Monitoring


journalctl bash-xe # View logs (systemd)
tail -f /var/log/syslog # Live log view uptime # System uptime free -h # Memory usage top/htop # CPU, memory, processes

XII. Shell Scripting Basics

bash

#!/bin/bash echo "Hello, $USER" date

Run:

bash

chmod +x script.sh ./script.sh

XIII. Crontab (Scheduled Tasks)

bash

crontab -e # Edit user's cron crontab -l # List crons

Cron syntax:

Bash

* * * * * /path/to/script.sh │ │ │ │ │ │ │ │ │ └─ Day of week (0-6) │ │ │ └─── Month (1-12) │ │ └───── Day of month (1-31) │ └─────── Hour (0-23) └───────── Minute (0-59)

XIV. Linux Best Practices

  1. Use SSH keys instead of passwords for secure access.

  2. Regularly update packages and monitor logs.

  3. Limit root access; use sudo for admin tasks.

  4. Automate tasks using cron or systemd timers.

  5. Maintain backups and versioned configurations.

  6. Use SELinux/AppArmor for enhanced security (if applicable).

  7. Monitor disk, CPU, memory to prevent outages.



Comments

Popular posts from this blog

SAVE TAX ๐Ÿ’ต

LIFE A JOURNEY

๐ŸฆŸ The Truth About Mosquitoes: More Than Just an Itchy Bite