๐ File Management
-
ls โ List directory contents
-
cd โ Change directory
-
pwd โ Print current directory path
-
cp file1 file2 โ Copy file1 to file2
-
mv old new โ Move or rename files
-
rm file โ Remove file
-
mkdir folder โ Create directory
-
rmdir folder โ Delete empty directory
-
touch file โ Create empty file
-
stat file โ Show file info (size, timestamps,
permissions)
-
basename path โ Get filename from path
-
dirname path โ Get directory name from path
๐ง System Information
-
uname -a โ Show complete system info (kernel,
architecture, hostname)
-
hostname โ Display current system hostname
-
uptime โ Show how long the system has been
running
-
top โ Display real-time CPU and memory
usage
-
htop โ Enhanced interactive process viewer (if
installed)
-
df -h โ Disk space usage (human-readable)
-
du -sh * โ Folder sizes in current
directory
-
free -m โ Show memory usage in MB
-
lscpu โ CPU architecture and info
-
lsblk โ List block devices (disks and
partitions)
-
dmesg โ Show system boot and hardware
messages
๐ค User Management
-
whoami โ Show current logged-in user
-
id โ Show UID, GID, and groups of user
-
users โ Show all users currently logged in
-
adduser username โ Add a new user
-
passwd username โ Set/change user password
-
usermod -aG group username โ Add user to
group
-
groups username โ Show groups a user belongs
to
-
deluser username โ Delete a user
-
who โ Show who is logged in and from where
-
su - username โ Switch to another user
account
๐ Networking
-
ping google.com โ Check if host is
reachable
-
ip a โ Show IP addresses and interfaces
-
ifconfig โ Old tool for network interfaces (still
used)
-
netstat -tulnp โ List listening ports and
services
-
ss -tuln โ Faster replacement for netstat
-
curl ifconfig.me โ Get public IP address
-
traceroute domain.com โ Show route packets
take
-
dig example.com โ DNS lookup
-
nslookup example.com โ Query name servers
-
nmap 192.168.1.1 โ Scan ports on a target
(requires install)
๐ฆ Package Management (Debian/Ubuntu)
-
apt update โ Refresh package lists
-
apt upgrade โ Upgrade all installed
packages
-
apt install <package> โ Install a
package
-
apt remove <package> โ Remove a
package
-
apt search <package> โ Search for
packages
-
dpkg -i <file.deb> โ Install .deb package
file manually
-
apt autoremove โ Remove unused dependencies
-
apt clean โ Clear local repository of retrieved
package files
๐ Processes & Services
-
ps aux โ Show all running processes
-
top โ Interactive real-time process viewer
-
htop โ Enhanced process viewer (if
installed)
-
kill <PID> โ Terminate process by PID
-
killall <process_name> โ Terminate all
processes with name
-
systemctl status <service> โ Show service
status (systemd)
-
systemctl start <service> โ Start a
service
-
systemctl stop <service> โ Stop a
service
-
systemctl restart <service> โ Restart a
service
-
service <service> start|stop|restart โ
Control services (SysV init)
๐งช Disk & Filesystems
-
df -h โ Show disk space usage in human-readable
format
-
du -sh <directory> โ Show total size of
directory
-
mount | umount โ Mount or unmount
filesystems
-
lsblk โ List block devices (disks and
partitions)
-
fdisk -l โ Show partition tables
-
blkid โ Show block device attributes like UUID and
type
-
tune2fs โ Adjust ext2/3/4 filesystem
parameters
-
fsck /dev/sdX โ Filesystem consistency check and
repair
๐ Permissions & Ownership
-
chmod 755 file โ Set file permissions
(rwxr-xr-x)
-
chown user:group file โ Change owner and
group
-
ls -l file โ List file with permissions and
ownership
-
umask โ Show default permission mask for new
files
-
getfacl file โ Get extended ACL permissions
-
setfacl -m u:user:rwx file โ Set extended ACL
permissions
๐ Search & Filters
-
grep 'pattern' file โ Search text in files
-
find /path -name 'file' โ Find files by
name
-
locate file โ Quickly find file by name (updatedb
index)
-
awk '{print $1}' file โ Pattern scanning and
processing
-
sed 's/old/new/g' file โ Stream editor for text
substitution
-
cut -d',' -f1 file โ Extract columns from
file
-
sort file โ Sort lines alphabetically or
numerically
-
uniq file โ Filter duplicate lines
๐ ๏ธ Bash & Scripting
-
echo "Hello World" โ Print text to terminal
-
#!/bin/bash โ Shebang to specify script
interpreter
-
chmod +x script.sh โ Make script executable
-
./script.sh โ Run executable script
-
if [ condition ]; then ... fi โ Basic if
statement
-
for i in {1..5}; do ... done โ For loop
-
while [ condition ]; do ... done โ While
loop
-
read variable โ Read input from user
-
$? โ Exit status of last command
-
export VAR=value โ Set environment variable