1.
File and Directory Management
ls – List files in a directory (ls -l for detailed view, ls -a for hidden files).
cd <directory> – Change directory.
pwd – Print current working directory.
mkdir <directory> – Create a new directory.
rmdir <directory> – Remove an empty directory.
rm -rf <directory> – Remove a directory and its contents.
cp <source> <destination> – Copy files or directories.
mv <source> <destination> – Move or rename files.
find /path -name "filename" – Search for a file by name.
locate filename – Find a file using the mlocate database.
tree – Display directories as trees.
2. File Permissions and Ownership
chmod 777 file – Change file permissions (rwx for owner, group, others).
chown user:group file – Change ownership of a file.
ls -l – View file permissions.
umask 022 – Set default permissions for newly created files.
3. Process Management
ps aux – View running processes.
top – Show active processes dynamically.
htop – Enhanced process viewer (if installed).
kill <PID> – Kill a process by ID.
pkill <name> – Kill a process by name.
killall <process_name> – Kill all processes of the same name.
jobs – View background jobs.
fg %1 – Bring a background job to the foreground.
bg %1 – Resume a background job.
4. User Management
whoami – Display the current user.
id – Show user ID and group ID.
who – Show logged-in users.
w – Show detailed user information.
useradd <username> – Add a new user.
passwd <username> – Change a user's password.
usermod -aG <group> <username> – Add a user to a group.
groups <username> – Show groups of a user.
deluser <username> – Remove a user.
chage -l <username> – Show password aging information.
5. Disk and File System
df -h – Show disk space usage.
du -sh <directory> – Show directory size.
mount /dev/sdb1 /mnt – Mount a device.
umount /mnt – Unmount a device.
fsck /dev/sda1 – Check and repair filesystem errors.
mkfs.ext4 /dev/sdb1 – Format a partition with ext4.
blkid – Display UUIDs of partitions.
6. Networking Commands
ip a – Show IP addresses.
ifconfig – Show network interfaces (deprecated, use ip a).
ping <host> – Check connectivity.
netstat -tulnp – Show open ports and listening services.
ss -tulnp – Alternative to netstat.
nslookup <domain> – Query DNS.
dig <domain> – Advanced DNS lookup.
traceroute <host> – Trace network path to a host.
wget <URL> – Download a file from a URL.
curl -O <URL> – Download a file.
7. Package Management
Debian-based (Ubuntu, Debian)
apt update – Update package list.
apt upgrade – Upgrade installed packages.
apt install <package> – Install a package.
apt remove <package> – Remove a package.
dpkg -i <package>.deb – Install a .deb file.
RHEL-based (AlmaLinux, CentOS, Fedora)
dnf update – Update all packages.
dnf install <package> – Install a package.
dnf remove <package> – Remove a package.
rpm -ivh <package>.rpm – Install an .rpm file.
8. Log Management
journalctl -xe – View system logs.
tail -f /var/log/syslog – Monitor syslog in real-time.
tail -f /var/log/messages – Monitor system messages.
dmesg | less – View boot and hardware logs.
9. Compression and Archiving
tar -cvf archive.tar file – Create a tar archive.
tar -xvf archive.tar – Extract a tar archive.
tar -czvf archive.tar.gz file – Create a compressed archive.
tar -xzvf archive.tar.gz – Extract a compressed archive.
zip -r archive.zip directory – Compress a directory into a zip file.
unzip archive.zip – Extract a zip file.
10. System Performance and Monitoring
uptime – Show system uptime.
free -h – Show memory usage.
vmstat 1 – Show system performance.
sar -u 1 5 – Show CPU usage over time.
iostat – Show I/O statistics.
mpstat – Show CPU usage per core.
11. Scheduling and Automation
crontab -e – Edit cron jobs.
crontab -l – List cron jobs.
at 14:00 – Schedule a command to run at 2:00 PM.
12. Security and Firewall
ufw enable – Enable firewall (Ubuntu).
ufw allow 22/tcp – Allow SSH port.
firewall-cmd --permanent --add-port=80/tcp – Open a port in RHEL-based distros.
firewall-cmd --reload – Apply firewall changes.
semanage port -l – List SELinux port labels.
Few more Commands to review
sudo chmod +t,g+s /admins