Tag: ubuntu users

  • 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

  • Ubuntu Linux Cheatsheet

    Ubuntu Linux Cheatsheet

    The world’s most popular desktop & server Linux
    Uses apt (Debian-based). All privileged commands require sudo.
    Covers Ubuntu Desktop, Server, LTS, and Snaps.


    1. Installation (Live USB / Server ISO)

    TaskCommand / Action
    Boot Live USBTry Ubuntu → Install Ubuntu
    Disk setupUse Eraser or Something Else (manual: /, /boot, swap)
    Server installBoot ISO → Language → Minimal or Standard
    Enable SSH (server)sudo apt install openssh-server
    Update on first bootsudo apt update && sudo apt upgrade -y

    2. APT (Package Management)

    ActionCommand
    Update package listssudo apt update
    Upgrade all packagessudo apt upgrade -y
    Full upgrade (new deps)sudo apt full-upgrade -y
    Install packagesudo apt install package
    Remove packagesudo apt remove package
    Purge (with config)sudo apt purge package
    Autoremove unusedsudo apt autoremove
    Clean cachesudo apt clean
    Search packageapt search keyword
    List installeddpkg -l | grep ^ii
    Show infoapt show package
    Fix broken installssudo apt install -f
    Which package owns filedpkg -S /path/to/file

    3. Snaps (Universal Packages)

    ActionCommand
    Install snapsudo snap install package
    Update all snapssudo snap refresh
    List installedsnap list
    Remove snapsudo snap remove package
    Classic confinementsudo snap install --classic code
    Find in storesnap find keyword

    Common Snaps: code, discord, spotify, slack, postman, chromium


    4. System Administration

    TaskCommand
    List servicessystemctl list-unit-files --type=service
    Enable servicesudo systemctl enable service
    Start servicesudo systemctl start service
    Statussystemctl status service
    View logsjournalctl -u service
    Rebootsudo reboot
    Shutdownsudo poweroff
    Disk usagedf -h
    Memoryfree -h
    Processeshtop or top
    Kill processkill PID or pkill name
    Check Ubuntu versionlsb_release -a or cat /etc/os-release

    5. Users & Permissions

    ActionCommand
    Add usersudo adduser username
    Add to sudo groupsudo usermod -aG sudo username
    Change passwordsudo passwd username
    Change ownersudo chown user:group file
    Change permissionschmod 755 file
    Switch usersu - username

    6. Networking

    TaskCommand
    Check IPip a or nmcli device show
    List Wi-Finmcli device wifi list
    Connect Wi-Finmcli device wifi connect SSID password "pass"
    Restart NetworkManagersudo systemctl restart NetworkManager
    Check DNScat /etc/resolv.conf
    Test connectionping -c 4 google.com
    Firewall (UFW)sudo ufw status
    sudo ufw allow 22/tcp
    sudo ufw enable

    7. Filesystem & Storage

    TaskCommand
    Mount USBsudo mount /dev/sdb1 /mnt/usb
    Unmountsudo umount /mnt/usb
    Format ext4sudo mkfs.ext4 /dev/sdX1
    Check disksudo fsck /dev/sdX1
    Find large filesdu -ah / | sort -rh | head -n 20
    Search filesfind / -name "filename" 2>/dev/null
    Disk analyzer (GUI)baobab

    8. Server-Specific

    ServiceInstall & Enable
    LAMP Stacksudo apt install apache2 mysql-server php libapache2-mod-php
    Nginx + PHPsudo apt install nginx php-fpm
    Dockersudo apt install docker.io
    sudo usermod -aG docker $USER
    Node.jscurl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
    sudo apt install nodejs
    PostgreSQLsudo apt install postgresql

    9. Troubleshooting

    IssueCommand
    Boot to recoveryGRUB → Advanced → Recovery Mode
    Fix broken packagessudo dpkg --configure -a
    sudo apt install -f
    Reinstall GRUB (UEFI)sudo grub-install /dev/sdX
    sudo update-grub
    Clear journal logssudo journalctl --vacuum-time=2weeks
    Boot errorsjournalctl -b -p err
    Regenerate initramfssudo update-initramfs -u
    Check hardwarelscpu, lsblk, lspci, lsusb

    10. Useful Tools to Install

    sudo apt install \
        vim htop git curl wget unzip tree \
        net-tools ufw gnome-tweaks \
        build-essential dkms linux-headers-$(uname -r)

    11. One-Liners

    # Full system update + clean
    sudo apt update && sudo apt full-upgrade -y && sudo apt autoremove && sudo apt clean
    
    # Enable UFW with SSH allowed
    sudo ufw allow OpenSSH && sudo ufw enable
    
    # Show Ubuntu version
    lsb_release -a
    
    # Update snaps
    sudo snap refresh
    
    # Backup apt sources
    cp /etc/apt/sources.list ~/sources.list.bak
    
    # List all PPAs
    grep ^deb /etc/apt/sources.list /etc/apt/sources.list.d/*
    
    # Reboot into recovery
    sudo systemctl reboot --firmware-setup  # (UEFI)

    12. Ubuntu Flavors & Resources

    FlavorCommand / Note
    Ubuntu ServerMinimal CLI install
    Ubuntu DesktopFull GNOME experience
    KubuntuKDE Plasma
    XubuntuXFCE (lightweight)
    LubuntuLXQt
    Ubuntu MATEClassic desktop

    Official Docs: https://ubuntu.com/tutorials
    Ask Ubuntu: https://askubuntu.com


    13. Pro Tips

    • Use ubuntu-drivers autoinstall for NVIDIA/AMD drivers
    • Enable Minimized Updates in Software & Updates
    • Use apt-mark hold package to prevent updates
    • Backup with deja-dup (GUI) or rsync
    • Enable Firewall: sudo ufw enable
    # Auto-accept reboots after updates (server)
    sudo needrestart -a