π₯οΈ Advanced Linux Commands

Tech enthusiast | Code craftsman | DevOps explorer | Turning bugs into features one line at a time π
Advanced Linux commands for System Management
1. π Advanced File Permissions & Ownership
File Permissions in Linux:
r: Read (4) π
w: Write (2) βοΈ
x: Execute (1) βΆοΈ
Permissions are added together to set them.
π§ Modify File Permissions (chmod)
β Give full permission to the owner, read-execute to others:
Copy
chmod 755 script.sh7 β Owner permission: Read (4) + Write (2) + Execute (1) = 7
5 β Group permission: Read (4) + Execute (1) = 5
5 β Others permission: Read (4) + Execute (1) = 5
β Make a file read-only for everyone:
Copy
chmod 444 important.txt- π No one can modify the file because Write (2) is removed.
π« Remove execute permission from a file:
Copy
chmod -x file.sh- The
-xremoves execute permission from the file.
- The
π€ Change File Ownership (chown & chgrp)
π€ Change the file owner:
Copy
sudo chown newuser file.txtnewuserbecomes the owner offile.txt.
π₯ Change both owner and group:
Copy
sudo chown newuser:newgroup file.txtnewuseris the new owner.newgroupis the new group.
2. π Network Monitoring & Troubleshooting
π Check Open Network Connections (netstat, ss)
πΆ List all open ports and services:
Copy
netstat -tulnpt: Shows TCP connections.
u: Shows UDP connections.
l: Shows listening ports.
n: Displays numeric addresses.
p: Shows process ID (PID).
π Check listening ports (alternative to netstat):
Copy
ss -tulnp- β‘ Faster alternative to
netstat.
- β‘ Faster alternative to
π οΈ Network Diagnostics (ping, nslookup, traceroute)
π Test network connectivity:
Copy
ping google.com- Sends ICMP echo requests to check if
google.comis reachable.
- Sends ICMP echo requests to check if
π Get DNS information of a domain:
Copy
nslookup google.com- Resolves the IP address of
google.comusing DNS lookup.
- Resolves the IP address of
π Trace the route packets take to a destination:
Copy
traceroute google.com- Shows each hop (router) a packet takes to reach
google.com.
- Shows each hop (router) a packet takes to reach
3. π½ Transfer Files Over SSH (scp)
π Copy a file to a remote server:
Copy
scp file.txt user@remote:/path/- Securely copies
file.txtfrom your local machine to/path/on the remote server.
- Securely copies
4. π SSH Command for Remote Access
π Access a remote server using SSH:
Copy
ssh user@remotessh: Securely logs you into a remote server.user: Replace with the username on the remote server.remote: Replace with the server's IP address or hostname (e.g.,192.168.1.10).
5. β³ Automation & Scheduling Tasks (cron)
β Schedule Jobs with Cron
π Edit the cron table:
Copy
crontab -e- Opens the cron job editor.
πΎ Schedule a backup every day at midnight:
Copy
0 * * * * /home/user/backup.sh- This cron job will run
/home/user/backup.shat the start of every hour.
- This cron job will run



