Linux Fundamentals
Linux is a multi-user operating system where everything is treated as a file. Understanding file permissions, directory structure, and basic commands is essential for any developer.System Directory Structure
Linux organizes everything under the root directory/. Key directories include:
/bin- Essential command binaries (ls, cat, etc.)/boot- Boot loader files and kernel images/dev- Device files/etc- System configuration files/home- User home directories/lib- Shared libraries/opt- Optional software packages/root- Root user home directory/tmp- Temporary files/usr- User programs and data/var- Variable data (logs, databases)
File Permissions
Linux file permissions consist of read (r), write (w), and execute (x) for three categories:- Owner (u) - File owner
- Group (g) - File group members
- Others (o) - Everyone else
ls -l:
d= directory-= regular filel= symbolic link
Permission Numbers
Permissions can be represented numerically:- Read (r) = 4
- Write (w) = 2
- Execute (x) = 1
Changing File Ownership
Essential Commands
File Operations
Viewing Files
Paging Through Files
Viewing File Portions
Directory Management
File and Directory Operations
Searching
Find Files
Search File Contents
Archive and Compression
-z- gzip compression-c- create archive-x- extract archive-v- verbose output-f- specify filename
System Information
CPU Information
System Load
Disk Usage
Process Management
Viewing Processes
Managing Processes
Link Management
Hard Links vs Symbolic Links
Hard Link: Multiple names for the same file (same inode) Symbolic Link: Shortcut pointing to another file (different inode)Network Commands
System Control
Shutdown and Reboot
Service Management (systemd)
Scheduled Tasks
Crontab
Cron format:minute hour day month weekday command
Shell Redirection
Environment Variables
Useful Tips
Command History
File Statistics
Text Processing
Best Practices
- Always use
syncbefore shutdown to ensure data is written to disk - Be careful with
rm -rf- there’s no undo - Use tab completion to avoid typos and speed up command entry
- Check current directory before running destructive commands
- Use
lessinstead ofcatfor large files - Quote file paths with spaces -
rm "my file.txt" - Test commands with
echobefore execution in scripts - Use
mancommand to read command documentation
Common Pitfalls
- Forgetting to use
sudofor privileged operations - Not backing up before modifying system files
- Using
kill -9as first resort instead of graceful shutdown - Not checking if a process is still running before restart
- Editing files directly in
/etcwithout backups