Tag: questing quokka

  • Ubuntu Server CLI Cheatsheet

    Ubuntu Server CLI Cheatsheet

    The world’s most popular server OS – CLI essentials for daily administration
    Ubuntu Server 25.10 (Questing Quokka) released October 2025: Kernel 6.17, OpenJDK 25, Python 3.14 RC3, Golang 1.25, Rust 1.85. LTS: 24.04 (Noble Numbat) with 12 years support via Ubuntu Pro.
    Debian-based with apt package manager. All privileged commands require sudo. Access via SSH (port 22) or console.

    1. Installation & Initial Setup

    TaskCommand / Action
    Download ISOubuntu.com/download/server → 25.10 (latest) or 24.04 LTS
    Boot & InstallUSB boot → Language → Install Ubuntu Server → Set hostname, user, SSH key (recommended)
    Enable SSHDuring install: Check Install OpenSSH server Post-install: sudo apt install openssh-server
    Update systemsudo apt update && sudo apt upgrade -y
    Set timezonesudo timedatectl set-timezone America/New_York (or your region)
    Configure firewall (UFW)sudo ufw allow OpenSSH sudo ufw enable
    Add user to sudosudo usermod -aG sudo username

    Cloud Images: For AWS/GCP/Azure: Use official AMIs. Minimal install: ~300MB RAM. Pro Tip: Enable unattended upgrades: sudo apt install unattended-upgrades → sudo dpkg-reconfigure unattended-upgrades.

    2. Navigation & File Management

    TaskCommand
    Show current directorypwd
    List files (detailed)ls -la
    List by time (newest first)ls -lht
    List with human-readable sizesls -lh
    Change directorycd /var/www
    Go homecd ~
    Go up one levelcd ..
    Go to previous directorycd –
    Show directory treetree -L 2 (install: sudo apt install tree)

    3. Create, Copy, Move & Delete

    ActionCommand
    Create directorymkdir foldername
    Create nested directoriesmkdir -p /path/to/nested/folder
    Create empty filetouch filename.txt
    Create multiple filestouch file1.txt file2.txt file3.txt
    Edit/create with nanonano filename.txt (Ctrl+O save, Ctrl+X exit)
    Copy filecp file.txt /backup/
    Copy directory recursivelycp -r folder /backup/
    Move/rename filemv old.txt new.txt
    Move filemv file.txt /new/location/
    Delete filerm file.txt
    Delete directoryrm -r folder (empty) rm -rf folder (with contents, dangerous!) rm -ri folder (with prompts)

    4. Disk & Storage

    TaskCommand
    Disk usage (human-readable)df -h
    Detailed disk outputdf -h –output=source,fstype,size,used,avail,pcentused,target
    Folder sizedu -sh /path
    Current directory sizes (largest first)du -sh * | sort -hr
    List block deviceslsblk
    List all diskssudo fdisk -l
    Interactive disk explorerncdu / (install: sudo apt install ncdu)

    5. Search & Find

    TaskCommand
    Find files by namefind /var/www -name “*.log”
    Find large files (>100MB)find / -type f -size +100M 2>/dev/null
    Search text in filesgrep -r “search term” /var/www
    Case-insensitive filenames onlygrep -ril “text” /etc

    6. Permissions & Ownership

    ActionCommand
    Set file permissions (644)chmod 644 file.txt
    Make executable (755)chmod 755 script.sh
    Recursive permissionschmod -R 755 folder
    Change ownerchown www-data:www-data file.txt
    Recursive ownershipchown -R www-data:www-data /var/www
    Take ownershipchown -R $USER:$USER folder

    7. System Monitoring & Info

    TaskCommand
    Kernel & system infouname -a
    Ubuntu versionlsb_release -a
    Uptime & loaduptime
    Memory usagefree -h
    Process monitortop or htop (install: sudo apt install htop)
    Recent logsjournalctl -xe
    Kernel messagesdmesg | tail

    8. Package Management (APT)

    ActionCommand
    Update package listsudo apt update
    Upgrade packagessudo apt upgrade -y
    Full upgrade (with deps)sudo apt full-upgrade -y
    Remove unusedsudo apt autoremove
    Clean cachesudo apt clean
    Install toolssudo apt install tree htop ncdu
    Search packageapt search keyword
    Show package infoapt show package

    9. Networking & Users

    Networking

    TaskCommand
    Show IP addressesip a
    Listening portsss -tulnp
    Public IPcurl ifconfig.me
    Test connectivityping -c 4 google.com
    Firewall statussudo ufw status
    Allow SSHsudo ufw allow 22/tcp

    Users

    ActionCommand
    Add usersudo adduser username
    Add to sudo groupsudo usermod -aG sudo username
    Change passwordsudo passwd username
    Edit sudoerssudo visudo

    10. Troubleshooting

    IssueCommand
    Fix broken packagessudo apt install -f
    Check servicessudo systemctl status service
    View full logsjournalctl -u service -f
    Boot to recoveryGRUB → Advanced → Recovery Mode
    Clear old logssudo journalctl –vacuum-time=30d
    Reinstall packagesudo apt install –reinstall package

    11. One-Liners

    # Full update + clean

    sudo apt update && sudo apt full-upgrade -y && sudo apt autoremove && sudo apt clean

    # Clean disk view (hide snaps)

    df -h | grep -v snap

    # 10 largest items in current dir

    du -sh * | sort -hr | head -10

    # Delete logs older than 30 days

    find /var/log -type f -mtime +30 -delete

    # Newest files in /var/log

    ls -lht /var/log | head

    # Quick web server (Python)

    cd /var/www && python3 -m http.server 8000

    12. Useful Tools to Install

    sudo apt install htop tree ncdu curl wget vim git ufw unattended-upgrades

    13. Ubuntu Resources

    Official Docs: https://ubuntu.com/server/docs
    Ask Ubuntu: https://askubuntu.com
    Cloud/Server Guide: https://ubuntu.com/server

    # Check for updates offline

    apt list –upgradable