Basic Linux Commands
🐧 Linux Basic Commands — Quick Reference
A comprehensive yet compact beginner's guide to Linux file system, commands, permissions, networking, users, and more.
📘 Why Learn Linux?
Linux powers everything from servers and clouds to IoT devices. Whether you’re a developer, sysadmin, or cloud engineer, Linux skills are essential.
- Works seamlessly with Windows and macOS.
- Hosts most cloud workloads and containers.
- Open source, modular, and secure.
📂 1. Linux File System Hierarchy
/ ├── bin ├── boot ├── dev ├── etc ├── home │ ├── alice │ ├── bob │ └── eve ├── root ├── run ├── sbin ├── tmp ├── usr │ ├── bin │ ├── local │ │ ├── bin │ │ ├── sbin │ └── sbin └── var
- /boot – Kernel & bootloader files
- /etc – System configuration
- /home – User directories
- /usr – Installed software
- /var – Logs, spools
- /tmp – Temporary data
📁 2. File Management & Navigation
Absolute vs Relative Paths
- Absolute:
/var/log/syslog - Relative:
log/syslog(from /var)
pwd # Print working directory ls # List files cd /etc # Change directory mkdir ProjectX # Create folder cp file1 file2 # Copy mv file target/ # Move rm file.txt # Delete
📝 3. Create, View, and Edit Text Files (Vim)
Launch Vim: vim file.txt
- Modes: Normal, Insert (
i), Visual (v), Command (:) - Save & Exit:
:wq,:q! - Edit:
dddelete line,yycopy,ppaste - Search:
/word,nnext
Tip: Addset numberandsyntax onin ~/.vimrc for better coding experience.
👤 4. UID & GID (User & Group IDs)
- UID → User ID, GID → Group ID
- Root = 0, System = 1–999, Normal = 1000+
id username cat /etc/passwd groups user
👥 5. Manage Users and Groups
User Commands:
sudo adduser user1 sudo passwd user1 sudo usermod -aG sudo user1 sudo deluser user1 --remove-home
Group Commands:
sudo addgroup devteam sudo usermod -aG devteam user1 sudo delgroup devteam
🔐 6. File Permissions & Ownership
-rwxr-xr-- u=rwx (owner) g=rx (group) o=r (others)
Change permissions:
chmod 755 script.sh chown user:group file.txt
Sticky bit (t): Only file owner can delete (used in /tmp)
⚙️ 7. Process Management
ps aux # List processes top / htop # Monitor kill -9 PID # Kill nice -n 10 cmd # Start with priority pstree # View process tree jobs, fg, bg # Manage background jobs
🧩 8. Manage Services (systemctl)
systemctl start nginx systemctl enable nginx systemctl status nginx systemctl list-units --type=service
Check logs with: journalctl -u nginx
🔑 9. Configure and Secure SSH
sudo apt install openssh-server sudo systemctl enable --now ssh sudo nano /etc/ssh/sshd_config
Important settings:
- PermitRootLogin no
- PasswordAuthentication no
- AllowUsers youruser
📜 10. Log Analysis & Monitoring
cat /var/log/syslog journalctl -b grep "error" /var/log/auth.log sudo logrotate -f /etc/logrotate.conf
Use logwatch or goaccess for analysis.
🌐 11. Manage Networking
ip a # Show interfaces ip route # View routes ping google.com # Test connectivity sudo nano /etc/resolv.conf nameserver 8.8.8.8
Use nmcli for NetworkManager-managed systems.
📦 12. Archive & Transfer Files
tar -czvf backup.tar.gz folder/ scp file user@ip:/path/ rsync -av --delete src/ dest/ sftp user@ip
🧰 13. Package Management
APT (Ubuntu/Debian)
sudo apt update sudo apt install nginx sudo apt remove nginx
DNF/YUM (RHEL/Fedora)
sudo dnf install httpd sudo dnf remove httpd
💾 14. Access Linux File Systems
df -h lsblk -f sudo mount /dev/sdb1 /mnt sudo umount /mnt sudo fsck /dev/sdb1
Auto-mount: edit /etc/fstab carefully.
© 2025 • Linux Quick Guide • Designed for Blogger ✨
Comments
Post a Comment