Linux Directory Structure
/ - Root (base) directory 🌳
/root - Home directory for root user 👑
/home - User home directories (/home/username) 🏠
/bin - Symlink to /usr/bin (user command binaries) ⚙️
/sbin - Symlink to /usr/sbin (system admin binaries) 🛠️
/usr/bin - Actual location of user binaries (ls, cat, docker) 📦
/usr/sbin - System administration binaries (useradd, nginx) 🔧
/usr/local/bin - Manually installed binaries (not managed by package manager) 📥
/lib - Essential system libraries for /bin and /sbin 📚
/opt - Third-party/commercial software packages (self-contained) 🧩
/var - Runtime data, logs, application state (Docker, Jenkins) 📊
/etc - Configuration files (editable text configs) 📝
/tmp - Temporary files (cleared on reboot) ⏳
/proc - Virtual filesystem with process/system information 🔍
/sys - Virtual filesystem with hardware/kernel information 🖥️
/boot - Boot loader files and kernel 🚀
/dev - Device files (hardware interfaces) 🔌
/mnt - Manual mount point for filesystems 💽
/media - Auto-mount point for removable devices 📀
/run - Runtime process data (PIDs, sockets) 🏃
The PATH Variable
The PATH variable in Linux is an environment variable that specifies a list of directories where executable programs are located. When you run a command in the terminal, the system searches through these directories to find the executable file corresponding to that command.
Format of the PATH Variable
The PATH variable consists of a colon (:) separated list of directories. Here's an example:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
Example of Setting the PATH Variable
To include a new directory, such as where you have installed Terraform, you can modify the PATH variable as follows:
export PATH=$PATH:/usr/local/terraform
After editing the file, you can apply the changes immediately by sourcing the file:
source ~/.bashrc
Linux Commands
Gaining Root User Access
sudo su -
logout
Finding path
which
Piping Commands
# Use the output of the first command as input for the second
|
Debugging Commands
# Print command in debug mode
set -x
Error Handling in Scripts
# Exit the script when there is an error
set -e
# Exit the script when there is a pipe failure
set -o pipefail
Disk and Memory Usage
# Disk usage in human-readable format
df -h
# Memory usage
free
# Number of processing units
nproc
Real-Time Performance Monitoring
# Monitor performance in real-time
top
# All processes running in the background
ps -ef
Filtering Output
# Basic filtering command
grep
# Powerful filtering and text processing
awk
Retrieving and Downloading Information from the Internet
# Retrieve information from the internet
curl
# Download files from the internet
wget
Searching for Files
# Search for the location of a file
find / -name test.sh
Trapping Signals in Linux
trap
Working with Processes
# List all processes
ps -ef
# Print errors from remote logs
curl ... | grep ...
String Manipulation
# Write number of occurrences of 's' in the word 'missi'
x=missi
grep -o "s" <<<"$x" | wc -l
Scheduling Tasks with Crontab
# Crontab in Linux
Alarm
Editing Files
# Open a file in read-only mode
vim -r test.txt
Soft Links vs. Hard Links
Soft Link
Acts as a shortcut reference to the original file
The link can be broken if the original file is deleted or moved
Hard Link
Acts as a copy
Deleting the original file does not affect the hard link
Network Troubleshooting Utilities
Traceroute
Tracepath
Managing Large Log Files
Logrotate
Filtering JSON Data
# Filter data from JSON
jq
Filtering YAML Data
# Filter data from YAML
yq
Feel free to share and spread the knowledge! 🌟😊 Enjoy Learning! 😊

SOCIAL SHARE CARD GENERATOR