Tag: arch cheatsheet

  • Arch Linux Cheatsheet

    Arch Linux Cheatsheet

    Essential commands for installation, package management, system administration, and troubleshooting
    Assumes pacman as primary package manager. All commands require sudo unless run as root.


    1. Installation (Live USB/ISO)

    TaskCommand
    Update keyring (critical first step)pacman -Sy archlinux-keyring --noconfirm
    Sync mirrors (fastest)reflector --latest 10 --sort rate --save /etc/pacman.d/mirrorlist
    List diskslsblk -f or fdisk -l
    Partition disk (example: UEFI + root)cfdisk /dev/sdX
    Format partitionsmkfs.fat -F32 /dev/sdX1 (EFI)
    mkfs.ext4 /dev/sdX2 (root)
    Mount partitionsmount /dev/sdX2 /mnt
    mkdir -p /mnt/boot && mount /dev/sdX1 /mnt/boot
    Install base systempacstrap /mnt base linux linux-firmware
    Generate fstabgenfstab -U /mnt >> /mnt/etc/fstab
    Chroot into systemarch-chroot /mnt
    Set timezoneln -sf /usr/share/zoneinfo/Region/City /etc/localtime
    hwclock --systohc
    Set localeEdit /etc/locale.gen → uncomment en_US.UTF-8 UTF-8
    locale-gen
    echo "LANG=en_US.UTF-8" > /etc/locale.conf
    Set hostnameecho "myhostname" > /etc/hostname
    Add to /etc/hosts127.0.0.1 localhost
    ::1 localhost
    127.0.1.1 myhostname.localdomain myhostname
    Set root passwordpasswd
    Install bootloader (GRUB UEFI)pacman -S grub efibootmgr
    grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
    grub-mkconfig -o /boot/grub/grub.cfg
    Enable network (systemd)pacman -S networkmanager
    systemctl enable NetworkManager
    Exit & rebootexit
    umount -R /mnt
    reboot

    2. Pacman (Package Management)

    ActionCommand
    Update systempacman -Syu
    Install packagepacman -S package
    Remove package (with deps)pacman -Rns package
    Search packagepacman -Ss keyword
    List installed packagespacman -Q
    List explicitly installedpacman -Qe
    Clean cache (keep last 3 versions)paccache -rk 3
    Remove untracked packagespacman -Rns $(pacman -Qdtq)
    View package infopacman -Qi package
    List files in packagepacman -Ql package
    Which package owns filepacman -Qo /path/to/file
    Sync databasepacman -Syy
    Force refreshpacman -Syyu

    AUR Helper (yay/paru)
    Install: pacman -S --needed git base-devel
    git clone https://aur.archlinux.org/yay.git && cd yay && makepkg -si
    Use: yay -S package (replaces pacman for AUR)


    3. System Administration

    TaskCommand
    List servicessystemctl list-unit-files --type=service
    Enable servicesystemctl enable service
    Start servicesystemctl start service
    Check statussystemctl status service
    View logsjournalctl -u service
    Rebootreboot
    Shutdownpoweroff
    View kernel messagesdmesg | less
    Check disk usagedf -h
    Check memoryfree -h
    List processeshtop or top
    Kill processkill PID or pkill name
    Edit config (nano/vim)nano /path/to/file
    Backup pacman databasecp -r /var/lib/pacman /backup/

    4. Users & Permissions

    ActionCommand
    Add useruseradd -m -G wheel username
    Set user passwordpasswd username
    Enable sudo for wheelEDITOR=nano visudo → uncomment %wheel ALL=(ALL) ALL
    Change file ownerchown user:group file
    Change permissionschmod 755 file

    5. Networking

    TaskCommand
    Check IPip a
    Test connectionping archlinux.org
    Wi-Fi (iwctl)iwctl → station wlan0 scan → connect SSID
    Enable Wi-Fisystemctl enable --now iwd
    Check DNScat /etc/resolv.conf
    Restart NetworkManagersystemctl restart NetworkManager

    6. Filesystem & Storage

    TaskCommand
    Mount USBmount /dev/sdb1 /mnt/usb
    Unmountumount /mnt/usb
    Format ext4mkfs.ext4 /dev/sdX1
    Check filesystemfsck /dev/sdX1
    Find large filesdu -ah / | sort -rh | head -n 20
    Search filesfind / -name "filename"

    7. Troubleshooting

    IssueCommand
    Boot into recoveryHold Shift at boot → GRUB → e → add systemd.unit=rescue.target
    Fix broken packagespacman -Dk (check deps)
    pacman -Syu --overwrite '*'
    Reinstall all packagespacman -Qnq | pacman -S -
    Clear journal logsjournalctl --vacuum-time=2weeks
    Check boot errorsjournalctl -b -p err
    Regenerate initramfsmkinitcpio -P
    Update GRUBgrub-mkconfig -o /boot/grub/grub.cfg

    8. Useful Tools to Install

    pacman -S vim htop git curl wget unzip tree reflector rsync

    9. One-Liners

    # Full system update + clean
    pacman -Syu && paccache -ruk0 && pacman -Rns $(pacman -Qdtq)
    
    # Mirrorlist (fastest 10 servers)
    reflector --latest 10 --sort rate --save /etc/pacman.d/mirrorlist && pacman -Syy
    
    # Show orphan packages
    pacman -Qdt
    
    # Rebuild AUR packages after upgrade
    yay -Syu --rebuildall

    10. Arch Wiki Shortcut

    Always check: https://wiki.archlinux.org

    # Search wiki offline (install arch-wiki-docs)
    pacman -S arch-wiki-docs
    wiki-search "query"

    Pro Tip: Keep archinstall script for automated installs:

    pacman -S archinstall
    archinstall