Networking, Security & Cloud Knowledge

Friday, October 25, 2024

Linux bash command cheat sheet

Bash Command Cheat Sheet

Bash Command Cheat Sheet

File and Directory Commands

- List files:
  ls
- Change directory:
  cd 
- Print working directory:
  pwd
- Create a directory:
  mkdir 
- Remove a directory:
  rmdir 
- Remove a file:
  rm 
- Copy a file:
  cp  
- Move or rename a file:
  mv  
- Display file contents:
  cat 
- Display file contents page by page:
  less 

File Permissions

- Change file permissions:
  chmod  
- Change file owner:
  chown : 

Text Processing

- Search for a string in a file:
  grep  
- Count lines, words, and characters:
  wc 
- Sort lines in a file:
  sort 
- Display unique lines:
  uniq 
- Replace text in a file:
  sed 's/old_text/new_text/g' 

Networking

- Check network configuration:
  ifconfig
- Display current IP address:
  hostname -I
- Ping a host:
  ping 
- Check open ports:
  netstat -tuln
- Trace the route to a host:
  traceroute 

Process Management

- List running processes:
  ps aux
- Find a process by name:
  pgrep 
- Kill a process:
  kill 
- Kill a process by name:
  pkill 
- View system resource usage:
  top

System Information

- Show disk usage:
  df -h
- Show memory usage:
  free -h
- Show system uptime:
  uptime
- Show current users:
  who

Package Management (Debian/Ubuntu)

- Update package list:
  sudo apt update
- Upgrade installed packages:
  sudo apt upgrade
- Install a package:
  sudo apt install 
- Remove a package:
  sudo apt remove 

Miscellaneous

- Clear terminal screen:
  clear
- Display current date and time:
  date
- Get help for a command:
  man 
- Exit the terminal:
  exit