Skip to content

Latest commit

 

History

History
122 lines (114 loc) · 1.95 KB

File metadata and controls

122 lines (114 loc) · 1.95 KB

Ubuntu Command Reference

Package Management (APT)

  • Update package lists:
    sudo apt update
  • Upgrade installed packages:
    sudo apt upgrade -y
  • Full distribution upgrade:
    sudo apt full-upgrade -y
  • Install a package:
    sudo apt install <package-name>
  • Remove a package:
    sudo apt remove <package-name>
  • Search for a package:
    apt search <keyword>

System Information

  • Show OS release info:
    lsb_release -a
  • Kernel version:
    uname -r
  • CPU info:
    lscpu
  • Memory usage:
    free -h

Disk Management

  • List block devices:
    lsblk
  • Check disk usage:
    df -h
  • Partition tool (cfdisk):
    sudo cfdisk /dev/sda

Service Management (systemd)

  • List running services:
    systemctl list-units --type=service --state=running
  • Start a service:
    sudo systemctl start <service>
  • Enable service at boot:
    sudo systemctl enable <service>
  • Check service status:
    systemctl status <service>

Networking

  • Show IP addresses:
    ip addr show
  • Test connectivity:
    ping -c 4 8.8.8.8
  • Modify /etc/hosts:
    sudo nano /etc/hosts

User Management

  • Add a new user:
    sudo adduser <username>
  • Add user to sudo group:
    sudo usermod -aG sudo <username>
  • Delete a user:
    sudo deluser <username>

Miscellaneous

  • Search file contents:
    grep -r "search_term" /path/to/search
  • Find files by name:
    find / -name "*.conf" 2>/dev/null
  • Archive/Extract tarballs:
    tar -czvf archive.tar.gz /path/to/dir   # create
    tar -xzvf archive.tar.gz                # extract

Tip: Use apt-get and apt interchangeably, but apt provides a more user‑friendly output.