Skip to content

Latest commit

 

History

History
333 lines (223 loc) · 9.61 KB

CheatSheet.md

File metadata and controls

333 lines (223 loc) · 9.61 KB

Linux Preparation Guide

This guide provides a structured approach to mastering Linux by focusing on key concepts, hands-on practice, and troubleshooting skills.


1. Focus on Core Topics

Divide Linux into manageable topics and study systematically. Key areas include:

File System

  • ls, cd, pwd, find, du, df, mount, umount

Permissions

  • chmod, chown, chgrp
  • Understand rwx and octal notation

Process Management

  • ps, top, kill, nice, renice, jobs, bg, fg

Package Management

  • RHEL: yum, dnf, rpm
  • Debian: apt, dpkg

Networking

  • ifconfig, ip, ping, netstat, ss, nc, ssh, scp

System Logs

  • /var/log, journalctl, rsyslog

System Performance

  • vmstat, iostat, sar, free, uptime

Shell Scripting

  • Basic scripts (bash, loops, conditionals)

User Management

  • useradd, usermod, passwd, groups, sudo

Disk Management

  • fdisk, parted, lsblk, mkfs, mount, LVM commands

Services

  • systemctl, service, chkconfig, systemd concepts

Tip: Create a cheat sheet with commands and their flags for quick review.


2. Practice Hands-On

  • Use a home lab or virtual machines (e.g., VirtualBox, VMware, or cloud providers like Azure or AWS).
  • Perform daily exercises like creating users, configuring networking, writing scripts, and troubleshooting services.

Example Task:

  • Set up a cron job
  • Check disk usage
  • Configure permissions on a folder

Tip: Use platforms like TryHackMe, Hack The Box, or cloud sandboxes for practice.


3. Master Troubleshooting

Practice these common troubleshooting scenarios:

  • System won’t boot: Analyze GRUB, fstab, or rescue mode.
  • Disk space issues: Use df, du, find, and lsof.
  • Services fail to start: Check logs (systemctl status, journalctl).
  • Network issues: Use ping, traceroute, netstat, ss, iptables.

Tip: Document solutions to problems you encounter during practice.


4. Learn by Association (Mnemonics & Logic)

  • Permissions Mnemonic: "RWX = Read, Write, eXecute"
    • Octal mapping: 4 = Read, 2 = Write, 1 = Execute7 = rwx
  • Systemctl Commands: Remember the sequence “start, stop, status, enable, disable, restart”.
  • File System Hierarchy: Use associations like "bin = binaries," "etc = configuration files".

5. Explain Concepts Out Loud

  • Practice explaining concepts like boot process, file permissions, and LVM as if teaching someone.
  • Simulate scenarios with a friend or use tools like ChatGPT for mock Q&A.

6. Memorize Key Files and Locations

Familiarize yourself with important files:

  • /etc/passwd, /etc/shadow, /etc/group → User and password management
  • /etc/fstab → File system table
  • /var/log/ → System logs
  • /etc/crontab → Cron jobs
  • /proc/ → Kernel and process information

Tip: Remember these with a mental map of Linux directory structures.


7. Revisit Notes and Cheat Sheets

  • Summarize concepts and commands into small, quick-reference cheat sheets.
  • Use flashcards (physical or apps like Anki) for repetitive practice.

8. Stay Calm and Logical

  • If you don’t know a solution immediately, focus on expressing your thought process:
    • “I would start by checking logs using journalctl and verifying the service status with systemctl status.”
  • A logical approach is often more important than memorization.

9. Learn by Real-Life Scenarios

Relate tasks to real-world problems:

  • How would you recover from a corrupted file system?
  • How do you troubleshoot a failed SSH connection?
  • How do you monitor CPU or memory usage?

10. Repetition Is Key

The more you practice, the more confident and fluent you become. Repetition builds muscle memory for commands and processes.


Feel free to contribute with additional tips, examples, or real-life scenarios!

Linux Preparation Guide

This guide provides a structured approach to mastering Linux by focusing on key concepts, hands-on practice, and troubleshooting skills.


1. Focus on Core Topics

Divide Linux into manageable topics and study systematically. Key areas include:

File System

  • ls, cd, pwd, find, du, df, mount, umount

Permissions

  • chmod, chown, chgrp
  • Understand rwx and octal notation

Process Management

  • ps, top, kill, nice, renice, jobs, bg, fg

Package Management

  • RHEL: yum, dnf, rpm
  • Debian: apt, dpkg

Networking

  • ifconfig, ip, ping, netstat, ss, nc, ssh, scp

System Logs

  • /var/log, journalctl, rsyslog

System Performance

  • vmstat, iostat, sar, free, uptime

Shell Scripting

  • Basic scripts (bash, loops, conditionals)

User Management

  • useradd, usermod, passwd, groups, sudo

Disk Management

  • fdisk, parted, lsblk, mkfs, mount, LVM commands

Services

  • systemctl, service, chkconfig, systemd concepts

2. Command Reference and Details

File System Commands

  • ls: List directory contents. Use flags like -l (long format) and -a (show hidden files).
    Example: ls -la

  • cd: Change the current directory.
    Example: cd /home/user

  • pwd: Print the current working directory.
    Example: pwd

  • find: Search for files and directories based on name, size, or other criteria.
    Example: find / -name "file.txt"

  • du: Estimate disk usage of files and directories.
    Example: du -sh /home/user

  • df: Show available disk space on mounted filesystems.
    Example: df -h

  • mount: Mount a filesystem to a directory.
    Example: mount /dev/sda1 /mnt

  • umount: Unmount a mounted filesystem.
    Example: umount /mnt


Permission Commands

  • chmod: Change file permissions. Use symbolic (u+x) or octal (755) modes.
    Example: chmod 755 file.txt

  • chown: Change file owner and group.
    Example: chown user:group file.txt

  • chgrp: Change group ownership of a file.
    Example: chgrp groupname file.txt


Process Management Commands

  • ps: Display information about active processes.
    Example: ps aux

  • top: Monitor real-time system processes and resource usage.

  • kill: Terminate a process using its PID.
    Example: kill 1234

  • nice: Run a process with a specified priority.
    Example: nice -n 10 command

  • renice: Change the priority of an already running process.
    Example: renice -n 5 -p 1234

  • jobs: List active background jobs.

  • bg: Resume a job in the background.
    Example: bg %1

  • fg: Resume a job in the foreground.
    Example: fg %1


Package Management Commands

RHEL-Based Systems:

  • yum: Install, update, and manage packages.
    Example: yum install httpd

  • dnf: Modern package manager for RHEL systems.
    Example: dnf update

  • rpm: Directly manage RPM packages.
    Example: rpm -ivh package.rpm

Debian-Based Systems:

  • apt: Install and manage packages on Debian systems.
    Example: apt install nginx

  • dpkg: Low-level package manager for .deb files.
    Example: dpkg -i package.deb


Networking Commands

  • ifconfig: Display or configure network interfaces.
    Example: ifconfig eth0

  • ip: Manage network interfaces and routing.
    Example: ip addr show

  • ping: Test connectivity to a host.
    Example: ping google.com

  • netstat: Display network connections and routing tables.
    Example: netstat -tuln

  • ss: Modern alternative to netstat for network statistics.
    Example: ss -tuln

  • nc: Network troubleshooting tool.
    Example: nc -zv google.com 80

  • ssh: Connect to a remote server via SSH.
    Example: ssh user@host

  • scp: Copy files over SSH.
    Example: scp file.txt user@host:/path


System Logs

  • journalctl: View system logs.
    Example: journalctl -u sshd

  • /var/log: Central directory for log files. Check logs like /var/log/syslog or /var/log/messages.


Disk Management Commands

  • fdisk: Partition a disk.
    Example: fdisk /dev/sda

  • parted: Manage disk partitions interactively.

  • lsblk: Display information about block devices.
    Example: lsblk

  • mkfs: Create a filesystem on a partition.
    Example: mkfs.ext4 /dev/sda1

  • mount: Mount a filesystem to a directory.

  • LVM Commands: Manage logical volumes.
    Example:

    • Create a physical volume: pvcreate /dev/sda1
    • Create a volume group: vgcreate vg_name /dev/sda1
    • Create a logical volume: lvcreate -L 10G -n lv_name vg_name

Service Management Commands

  • systemctl: Manage services and systemd.
    Example: systemctl start httpd

  • service: Legacy tool for managing services.
    Example: service httpd restart

  • chkconfig: Manage services on boot (legacy systems).
    Example: chkconfig httpd on


3. Repetition Is Key

The more you practice, the more confident and fluent you become. Repetition builds muscle memory for commands and processes.


Feel free to contribute with additional command explanations, examples, or tips!