Arch Linux: A Beginner's Command-Line Cheat Sheet
Arch Linux offers unparalleled control but can feel daunting for newcomers. This cheat sheet provides essential commands to confidently manage your system.
- System Information & Updates
These commands provide vital system details and keep your system secure:
-
System Information:
-
uname -a
: Displays kernel version, architecture, and more. Example:Linux hostname 6.10.9-arch1-2 #1 SMP PREEMPT_DYNAMIC ... x86_64 GNU/Linux
-
lscpu
: Detailed CPU information (cores, architecture, model, speed). -
free -h
: Human-readable memory usage (RAM, swap).
-
-
System Update:
-
sudo pacman -Syu
: Synchronizes package databases and upgrades all packages.
-
-
Power Management:
-
sudo poweroff
: Shuts down the system. -
sudo reboot
: Reboots the system. -
logout
: Logs out of the current user session.
-
- File Management
Essential commands for navigating, creating, and manipulating files and directories:
-
Navigation:
-
cd /path/to/directory
: Changes the current directory. -
cd ~
: Returns to the home directory. -
ls
: Lists files and directories. -
ls -l
: Lists files with details (permissions, size, modification time). -
ls -a
: Shows hidden files.
-
-
File Manipulation:
-
touch filename.txt
: Creates an empty file. -
mkdir new_folder
: Creates a new directory. -
mv oldname.txt newname.txt
: Renames a file. -
mv file.txt /path/to/destination/
: Moves a file. -
cp file.txt /path/to/destination/
: Copies a file. -
cp -r folder /path/to/destination/
: Recursively copies a directory. -
rm filename.txt
: Deletes a file. -
rm -r foldername
: Recursively deletes a directory (use with caution!).
-
-
File Viewing:
-
cat file.txt
: Displays file contents. -
less file.txt
: Displays large files page by page (quit with 'q'). -
head file.txt
: Displays the first 10 lines of a file. -
tail file.txt
: Displays the last 10 lines of a file.
-
- User Management
Commands for adding, managing, and switching users:
-
sudo useradd -m username
: Adds a new user with a home directory. -
sudo passwd username
: Sets a password for a user. -
sudo userdel username
: Deletes a user account. -
su - username
: Switches to another user's account. -
who
: Lists currently logged-in users.
- Software Installation & Management
Using Pacman and AUR helpers:
-
Pacman:
-
sudo pacman -S packagename
: Installs a package. -
sudo pacman -R packagename
: Removes a package. -
sudo pacman -Ss keyword
: Searches for packages. -
pacman -Q
: Lists installed packages. -
pacman -Qi packagename
: Shows package information.
-
-
AUR Helper (yay):
-
yay -S packagename
: Installs a package from the AUR. -
yay -Syu
: Updates all packages (official repos and AUR).
-
- Networking
Essential commands for managing network connections:
-
ip addr
: Shows network interface information. -
ping -c 4 google.com
: Tests internet connectivity. -
nmcli dev wifi connect "SSID" password "your_password"
: Connects to a Wi-Fi network. -
netstat -tuln
: Shows active network connections. -
ip route
: Displays routing table.
- Disk Management
Commands for checking disk usage, partitioning, and managing storage:
-
df -h
: Shows disk space usage. -
du -sh /path/to/directory
: Shows disk usage of a directory. -
sudo mount /dev/sdX1 /mnt
: Mounts a partition. -
sudo umount /mnt
: Unmounts a partition. -
lsblk
: Lists block devices. -
sudo fdisk /dev/sdX
: Partitions a disk. -
sudo mkfs.ext4 /dev/sdX1
: Formats a partition with ext4. -
sudo smartctl -a /dev/sdX
: Checks disk health. -
sudo dd if=/dev/zero of=/swapfile bs=1M count=1024; sudo chmod 600 /swapfile; sudo mkswap /swapfile; sudo swapon /swapfile
: Creates a swap file. -
sudo swapoff /swapfile; sudo rm /swapfile
: Removes a swap file.
- Process Management
Commands for viewing and controlling running processes:
-
ps aux
: Shows running processes. -
top
: Displays real-time process information. -
htop
: Interactive process viewer (install withsudo pacman -S htop
). -
kill PID
: Stops a process. -
kill -9 PID
: Forcefully stops a process. -
pgrep processname
: Finds the PID of a process. -
nice -n 10 command
: Runs a command with adjusted priority. -
sudo renice -n 10 -p PID
: Changes the priority of a running process.
- Permissions & Ownership
Commands for managing file permissions and ownership:
-
chmod 644 filename
: Sets file permissions (numeric mode). -
chmod u x filename
: Adds execute permission for the owner (symbolic mode). -
sudo chown username:groupname filename
: Changes file ownership. -
sudo chown -R username:groupname directory
: Recursively changes ownership of a directory. -
sudo chgrp groupname filename
: Changes file group ownership.
- System Logs & Monitoring
Commands for viewing system logs:
-
journalctl
: Views system logs. -
journalctl -u servicename
: Views logs for a specific service. -
journalctl --since "YYYY-MM-DD"
: Views logs since a specific date.
- Troubleshooting
Commands for resolving common issues:
-
systemctl rescue
: Enters rescue mode. -
sudo pacman -Sc
: Cleans the package cache. -
sudo pacman -S packagename
: Reinstalls a package. -
sudo fsck /dev/sdX
: Checks and repairs a filesystem. -
sudo pacman -Syyu
: Fixes package dependencies. -
sudo pacman -S $(pacman -Qdtq)
: Reinstalls orphaned dependencies.
- Advanced Tips
-
Aliases: Create shortcuts for commands in your
.bashrc
file (e.g.,alias ll='ls -la'
). -
Backup/Restore (tar):
tar -cvzf backup.tar.gz /path/to/directory
(backup),tar -xvzf backup.tar.gz
(restore). -
Man Pages: Use
man commandname
to get detailed help for any command.
This cheat sheet provides a foundation for navigating Arch Linux. Remember to consult the Arch Wiki for more comprehensive information.
The above is the detailed content of Arch Linux Cheat Sheet: Essential Commands for Beginners. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

LXD is described as the next-generation container and virtual machine manager that offers an immersive for Linux systems running inside containers or as virtual machines. It provides images for an inordinate number of Linux distributions with support

When encountering DNS problems, first check the /etc/resolv.conf file to see if the correct nameserver is configured; secondly, you can manually add public DNS such as 8.8.8.8 for testing; then use nslookup and dig commands to verify whether DNS resolution is normal. If these tools are not installed, you can first install the dnsutils or bind-utils package; then check the systemd-resolved service status and configuration file /etc/systemd/resolved.conf, and set DNS and FallbackDNS as needed and restart the service; finally check the network interface status and firewall rules, confirm that port 53 is not

If you find that the server is running slowly or the memory usage is too high, you should check the cause before operating. First, you need to check the system resource usage, use top, htop, free-h, iostat, ss-antp and other commands to check CPU, memory, disk I/O and network connections; secondly, analyze specific process problems, and track the behavior of high-occupancy processes through tools such as ps, jstack, strace; then check logs and monitoring data, view OOM records, exception requests, slow queries and other clues; finally, targeted processing is carried out based on common reasons such as memory leaks, connection pool exhaustion, cache failure storms, and timing task conflicts, optimize code logic, set up a timeout retry mechanism, add current limit fuses, and regularly pressure measurement and evaluation resources.

As a system administrator, you may find yourself (today or in the future) working in an environment where Windows and Linux coexist. It is no secret that some big companies prefer (or have to) run some of their production services in Windows boxes an

Frankly speaking, I cannot recall the last time I used a PC with a CD/DVD drive. This is thanks to the ever-evolving tech industry which has seen optical disks replaced by USB drives and other smaller and compact storage media that offer more storage

In Linux systems, 1. Use ipa or hostname-I command to view private IP; 2. Use curlifconfig.me or curlipinfo.io/ip to obtain public IP; 3. The desktop version can view private IP through system settings, and the browser can access specific websites to view public IP; 4. Common commands can be set as aliases for quick call. These methods are simple and practical, suitable for IP viewing needs in different scenarios.

Built on Chrome’s V8 engine, Node.JS is an open-source, event-driven JavaScript runtime environment crafted for building scalable applications and backend APIs. NodeJS is known for being lightweight and efficient due to its non-blocking I/O model and

Data replication is the process of copying your data across multiple servers to improve data availability and enhance the reliability and performance of an application. In MySQL replication, data is copied from a database from the master server to ot
