Arch Linux for Beginners: Essential Commands You Should Know

    If you’ve decided to dive into the world of Arch Linux, congratulations! Arch is a lightweight, flexible, and powerful Linux distribution beloved by users who prefer to build their systems from the ground up. However, with great power comes a bit of a learning curve. This guide is designed to help beginners by introducing essential commands you’ll frequently use on Arch Linux.

    Table of Contents

    Introduction to Arch Linux

    Arch Linux is a rolling-release distribution, meaning you install it once and update it continuously, rather than reinstalling periodically. It adheres to the KISS principle (Keep It Simple, Stupid), giving users total control over their system.

    Unlike distributions like Ubuntu or Fedora, Arch doesn’t come with a graphical installer or pre-configured environment, which is why command-line knowledge is crucial.

    Getting Started with the Terminal

    The terminal is your best friend on Arch Linux. Here are some general commands to get you started:

    # Display current directory
    pwd
    
    # List contents of a directory
    ls -l
    
    # Change directory
    cd /path/to/directory
    
    # Create a new directory
    mkdir new_folder
    
    # Remove a file or directory
    rm file.txt
    rm -r directory/
    
    # Copy or move files
    cp file1.txt file2.txt
    mv oldname.txt newname.txt
    

    Package Management with pacman

    pacman is the default package manager for Arch Linux. It is extremely powerful and efficient.

    Installing, Updating, and Removing Packages

    # Sync and update all packages
    sudo pacman -Syu
    
    # Install a new package
    sudo pacman -S package_name
    
    # Remove a package
    sudo pacman -R package_name
    
    # Remove a package and its dependencies
    sudo pacman -Rs package_name
    
    # Search for a package
    pacman -Ss keyword
    
    # List installed packages
    pacman -Q
    
    # Get information about a package
    pacman -Qi package_name
    

    System Information and Management

    Useful commands to understand your system better:

    # View CPU architecture
    lscpu
    
    # Memory usage
    free -h
    
    # Disk usage
    df -h
    
    # View block devices
    lsblk
    
    # Kernel information
    uname -r
    
    # Check system uptime
    uptime
    

    Managing Services with systemctl

    systemctl is used to manage systemd services on Arch.

    # Start a service
    sudo systemctl start service_name
    
    # Stop a service
    sudo systemctl stop service_name
    
    # Enable a service to start at boot
    sudo systemctl enable service_name
    
    # Disable a service
    sudo systemctl disable service_name
    
    # Check status of a service
    systemctl status service_name
    
    # List all services
    systemctl list-units --type=service
    

    Examples:

    sudo systemctl enable NetworkManager
    sudo systemctl start sshd
    

    Working with Files and Directories

    Familiarity with file management is essential.

    # View file contents
    cat file.txt
    less file.txt
    more file.txt
    
    # Edit files with nano
    nano file.txt
    
    # Change file permissions
    chmod 755 script.sh
    
    # Change file ownership
    sudo chown user:group file.txt
    

    Understanding permission notation:

    r = read

    w = write

    x = execute

    755 = owner can read/write/execute; group and others can read and execute

    Networking Essentials

    Arch doesn’t come with a full network stack out of the box. Networking tools are vital.

    # Check IP address
    ip a
    
    # Ping a server
    ping archlinux.org
    
    # Check active connections
    ss -tuln
    
    # Restart NetworkManager
    sudo systemctl restart NetworkManager
    
    # Connect to a Wi-Fi network with nmcli
    nmcli device wifi list
    nmcli device wifi connect SSID_NAME password PASSWORD
    

    User and Permission Management

    User and group management on Arch is similar to other Linux distributions:

    # Add a new user
    sudo useradd -m username
    
    # Set a password
    sudo passwd username
    
    # Add user to a group
    sudo usermod -aG groupname username
    
    # Create a group
    sudo groupadd groupname
    
    # Switch user
    su - username
    
    # View groups
    groups
    

    Giving a user sudo access:

    
    # Edit sudoers file safely
    sudo visudo
    # Add line: username ALL=(ALL) ALL
    

    Advanced Tips and Resources

    Enable Multilib Repository (for 32-bit support)

    sudo nano /etc/pacman.conf
    # Uncomment:
    #[multilib]
    #Include = /etc/pacman.d/mirrorlist
    sudo pacman -Sy
    

    Install AUR Helper (e.g., yay)

    Arch has a rich community repository known as the AUR (Arch User Repository). An AUR helper simplifies installing packages from it.

    # Clone yay from AUR and build it
    git clone https://aur.archlinux.org/yay.git
    cd yay
    makepkg -si
    Use yay like pacman:
    
    yay -S google-chrome
    yay -R package_name
    

    Useful Resources

    Conclusion

    Arch Linux is not just a distribution—it’s a philosophy. By learning these basic and essential commands, you’re equipping yourself with the tools to master your system and mold it to your exact preferences. The learning curve might seem steep, but the freedom and performance Arch offers make the effort worthwhile.

    Happy Arch-ing! 🐧