70+ Essential Linux Commands

File and Directory Commands

  1. ls (Windows: dir) Lists files/directories.

# Basic: List files with details
ls -la
# Advanced: List recursively with file sizes
ls -lR --human-readable

2. cd (Windows: cd)

Changes directory

# Basic: Navigate to a folder
cd /home/user
# Advanced: Switch to path with spaces
cd "/usr/local/share"
  1. mkdir (Windows: mkdir/md) Creates a directory.

# Basic: Create a single folder
mkdir data
# Advanced: Create nested folders
mkdir -p parent/child/grandchild
  1. rmdir (Windows: rmdir/rd) Deletes an empty directory.

# Basic: Remove empty folder
rmdir data
# Advanced: Remove non-empty folder
rm -r data
  1. rm (Windows: del) Deletes files.

  1. cp (Windows: copy) Copies files.

  1. cp -r (Windows: xcopy) Copies directories recursively.

  1. mv (Windows: move) Moves/renames files.

  1. chmod (Windows: attrib) Changes file permissions.

  1. mv (Windows: ren) Renames files/directories.

System Information Commands

  1. uname -a (Windows: systeminfo) Shows system information.

  1. hostname (Windows: hostname) Shows the system hostname.

  1. cat /etc/os-release (Windows: ver) Shows Debian version.

  1. env (Windows: set) Manages environment variables.

  1. lscpu/lspci (Windows: wmic) Queries hardware details.

  1. whoami (Windows: whoami) Shows the current user.

  1. ps aux (Windows: tasklist) Lists running processes.

Network Commands

  1. ip addr (Windows: ipconfig) Shows network configuration.

  1. ping (Windows: ping) Test network connectivity.

  1. traceroute (Windows: tracert) Traces the route to a host.

  1. ss (Windows: netstat) Shows network connections/ports.

  1. dig (Windows: nslookup) Queries DNS (install via sudo apt install dnsutils).

  1. ip neigh (Windows: arp) Manages ARP cache.

  1. ip route (Windows: route) Manages the routing table.

  1. mount (Windows: net use) Mounts network filesystems.

  1. ss -tuln (Windows: netstat -an) Shows connections numerically.

  1. nmcli (Windows: netsh) Configures network (install via sudo apt install network-manager).

Disk and Drive Commands

  1. fsck (Windows: chkdsk) Checks/repairs filesystem errors.

  1. parted (Windows: diskpart) Manages disks/partitions (install via sudo apt install parted).

  1. mkfs (Windows: format) Formats a filesystem.

  1. e2label (Windows: label) Sets volume label.

  1. blkid (Windows: vol) Shows volume information.

  1. tune2fs (Windows: fsutil) Manages ext filesystem properties.

Task and Process Management Commands

  1. kill/pkill (Windows: taskkill) Terminates processes.

  • Investigation Context: Monitor process termination with auditd (install via sudo apt install auditd). Example rule to log kill actions:

Check logs with: sudo ausearch -k process_kill.

  1. crontab (Windows: schtasks) Manages scheduled tasks.

  1. systemctl (Windows: sc) Controls systemd services.

  1. shutdown (Windows: shutdown) Performs shutdown/restart.

  1. xdg-open (Windows: start) Opens files/programs.

  1. read (Windows: pause) Pauses script for input.

  1. sleep (Windows: timeout) Adds delay in scripts.

User and Security Commands

  1. useradd/usermod (Windows: net user) Manages user accounts.

  1. groupadd/usermod (Windows: net localgroup) Manages group memberships.

  1. sudo -u (Windows: runas) Runs command as another user.

  1. chmod (Windows: cacls) Modifies file permissions.

  1. chown (Windows: icacls) Changes file ownership.

  1. loginctl lock-session (Windows: lock) Locks user session.

  1. update-rc.d (Windows: gpupdate) Manages system services (Debian-specific).

  1. apparmor (Windows: secedit) Applies security profiles (install via sudo apt install apparmor).

Power and Shutdown Commands

  1. upower (Windows: powercfg) Manages power settings (install via sudo apt install upower).

  1. shutdown -h now (Windows: shutdown /s /t 0) Immediate shutdown.

  1. reboot (Windows: shutdown /r /t 0) Immediate restart.

  1. loginctl terminate-session (Windows: shutdown /l) Logs off user.

Troubleshooting Commands

  1. fsck (Windows: sfc /scannow) Repairs filesystem.

  1. dpkg --configure (Windows: DISM) Repairs package configurations.

  1. df/du (Windows: cleanmgr) Manages disk space.

  1. journalctl (Windows: eventvwr) Views system logs.

  1. lscpu/lsmem (Windows: msinfo32) Shows system info.

Advanced and Miscellaneous Commands

  1. tree (Windows: tree) Displays folder structure (install via sudo apt install tree).

  1. echo (Windows: echo) Displays messages or writes to files.

  1. clear (Windows: cls) Clears terminal screen.

  1. title (Windows: title) Sets terminal title (bash-specific).

  1. tput (Windows: color) Changes terminal colors.

  1. exit (Windows: exit) Closes terminal.

  1. PS1 (Windows: prompt) Changes shell prompt.

  1. man (Windows: help) Shows command help.

Scripting and Shell Commands

  1. if (Windows: if) Conditional logic in scripts.

  1. for (Windows: for) Loops through values.

  1. function (Windows: goto) Defines functions for script flow.

  1. source/. (Windows: call) Calls another script/function.

  1. local (Windows: setlocal/endlocal) Manages variable scope.

Bonus Useful Commands

  1. tee (Windows: clip) Redirects to file and stdout.

  1. grep (Windows: find) Searches text in files.

  1. file (Windows: assoc) Shows file type.

  1. lsmod (Windows: driverquery) Lists kernel modules.

  1. wmctrl (Windows: taskview) Manages windows/desktops (install via sudo apt install wmctrl).

Last updated