Skip to content

Latest commit

 

History

History
190 lines (165 loc) · 5.76 KB

File metadata and controls

190 lines (165 loc) · 5.76 KB

Arch & General Linux Commands Cheat Sheet

This guide serves as a complete offline reference containing Basic CLI commands, Arch Linux specific utilities (Pacman & AUR), and Advanced Linux System Administration commands.


1. Basic Linux Commands (Navigation & File Management)

These standard command-line utilities are universal to almost all Unix-based systems (Linux, macOS).

Command Syntax Description Example
ls ls [options] [path] Lists contents of a directory. ls -la (shows hidden files & details)
cd cd [directory] Changes current working directory. cd /etc/systemd/system
pwd pwd Prints the absolute path of the current directory. pwd
mkdir mkdir [options] <dir> Creates a new directory. mkdir -p docs/setup (creates parents)
cp cp <source> <dest> Copies files or directories. cp -r configs/ ~/.config/ (recursive copy)
mv mv <source> <dest> Moves or renames files or directories. mv hyprland.conf old_hyprland.conf
rm rm [options] <target> Removes files or directories. rm -rf tmp/ (deletes recursively & forces)
cat cat <file> Concatenates and displays file contents in the console. cat /etc/hostname
less less <file> Views text files interactively (allows scrolling). less /var/log/pacman.log
grep grep <pattern> <file> Searches for text matching a pattern inside files. grep "HOOKS" /etc/mkinitcpio.conf
nano / vim nano <file> Terminal-based text editors. nano /etc/fstab

2. Arch Linux Specific Commands (Pacman, AUR, and Mirrors)

These commands manage package states, software compilation, repositories, and keyring authorization on Arch systems.

Pacman Package Manager

pacman is the official package system manager on Arch. All commands require administrator (sudo) access.

  • Full System Sync & Upgrade:
    sudo pacman -Syu
  • Install Specific Packages:
    sudo pacman -S package_name1 package_name2
  • Search for Packages (in official databases):
    pacman -Ss query_word
  • Uninstall Packages (Safe - Keeps configs):
    sudo pacman -R package_name
  • Uninstall Packages (Thorough - Deletes configs & unused dependencies):
    sudo pacman -Rns package_name
  • List Installed Packages:
    pacman -Q
  • View Package Information:
    pacman -Qi package_name
  • Clean Downloaded Package Cache (Free disk space):
    sudo pacman -Sc

AUR Helpers (yay / paru)

The Arch User Repository (AUR) contains thousands of user-contributed packages. Tools like yay or paru automate downloading, compiling, and updating these.

  • Install an AUR package:
    # DO NOT use sudo when running yay/paru!
    yay -S google-chrome
  • Upgrade all official and AUR packages:
    yay
  • Search the AUR database:
    yay -Ss query

Arch Mirrorlist Optimization (reflector)

Update your repository configuration by finding the fastest active mirrors:

# Finds the 10 recently synchronized HTTPS mirrors in your country, sorts them by speed, and writes them to mirrorlist
sudo reflector --country 'United States' --latest 10 --protocol https --sort rate --save /etc/pacman.d/mirrorlist

3. Advanced Linux & System Administration Commands

These administrative utilities are essential for checking hardware resources, setting system privileges, configuring networks, and starting background processes.

Systemd Process Manager

Controls system booting processes, background service daemons, and system schedules.

  • Start a Service (Runs in background immediately):
    sudo systemctl start NetworkManager
  • Stop a Running Service:
    sudo systemctl stop sddm
  • Enable a Service (Auto-starts service on boot):
    sudo systemctl enable bluetooth
  • Disable an Enabled Service:
    sudo systemctl disable fstrim.timer
  • Check Service Status:
    systemctl status docker

Log Reviewing (journalctl)

Inspect system log alerts and boot records:

# View last boot logs only
journalctl -b

# Follow new log inputs live
journalctl -f

# View logs for a specific service
journalctl -u NetworkManager

Disk & Storage Diagnostics

  • Display Connected Partition Layouts:
    lsblk
  • Check Free Disk Space in Gigabytes:
    df -h
  • Show Partition Tables & Sizing:
    sudo fdisk -l

Hardware & Resource Performance

  • Show active memory usage (RAM/Swap):
    free -h
  • Show real-time CPU thread utilization:
    htop
  • Display detailed hardware configuration:
    neofetch     # Classic summary (requires installation)
    lscpu        # CPU info
    lspci        # PCI hardware controller cards

Network Configurations

  • Display Network Cards and IP Addresses:
    ip a
  • Ping Test Server:
    ping -c 4 google.com
  • Check Port Listening Connections:
    ss -tulnp

Privileges & User Management

  • Change File Read/Write/Execute Permission:
    chmod 755 script.sh    # Allows execution
  • Change File Owner and Group:
    sudo chown username:username /path/to/file
  • Switch to another User context:
    su - username