Author: Trix Cyrus
[Try My], Waymap Pentesting tool: Click Here
[Follow] TrixSec Github: Click Here
[Join] TrixSec Telegram: Click Here
In Part 1, we covered the basics of Arch Linux commands, focusing on pacman
, system management, and AUR tools. In this follow-up, we’ll explore more advanced commands and techniques to help you master Arch Linux like a pro.
1. Pacman Power Features
Arch’s package manager, pacman
, has some powerful but lesser-known features that can save you time and effort.
1.1 Backup and Restore Packages
- Backup installed packages: Save a list of currently installed packages for reinstallation later:
pacman -Qqen > pkglist.txt
- Restore packages: Use the backup list to reinstall packages on a fresh system:
sudo pacman -S $(<pkglist.txt)
1.2 Downgrade a Package
Sometimes an update can break functionality. Downgrade a package by specifying a version:
sudo pacman -U /var/cache/pacman/pkg/package_name-version.pkg.tar.zst
1.3 View Detailed Package Information
Get detailed information about a package (dependencies, conflicts, etc.):
pacman -Qi package_name
1.4 List Orphans
List packages installed as dependencies but no longer required:
sudo pacman -Qdt
1.5 Remove Orphans
Clear out unnecessary packages:
sudo pacman -Rns $(pacman -Qdtq)
2. System Maintenance Commands
Keeping your Arch Linux system clean and optimized requires regular maintenance.
2.1 Cleaning the Package Cache
The package cache can grow over time. Clear old or unused packages to free up space:
- Remove all old versions except the latest two:
sudo paccache -r
- Clear the entire cache:
sudo pacman -Scc
2.2 Kernel Management
Arch Linux often keeps multiple kernel versions for safety. To manage them:
- List installed kernels:
pacman -Q | grep linux
- Remove an old kernel:
sudo pacman -R linux-old-kernel-name
2.3 Check for Outdated Configurations
Use the find
command to locate old configuration files:
find /etc -name "*.pacnew" -or -name "*.pacsave"
Merge or remove them as needed.
3. User Management
Arch Linux provides fine-grained control over user accounts.
3.1 Add a New User
Create a new user and assign them a home directory:
sudo useradd -m -G wheel username
3.2 Set User Password
sudo passwd username
3.3 Grant Sudo Privileges
Edit the sudoers file to give the new user administrative rights:
sudo visudo
Uncomment the line:
%wheel ALL=(ALL:ALL) ALL
3.4 Delete a User
Remove a user and their home directory:
sudo userdel -r username
4. Disk and Filesystem Management
Mastering disk management is crucial for efficient Arch Linux use.
4.1 View Disk Partitions
Use lsblk
or fdisk
to check your partitions:
lsblk
4.2 Resize a Partition
Unmount the partition before resizing:
sudo umount /dev/sdX1
sudo resize2fs /dev/sdX1
4.3 Mount Partitions Automatically
Edit the fstab
file to mount partitions at boot:
sudo nano /etc/fstab
Add a line like:
/dev/sda1 /mnt/data ext4 defaults 0 2
5. Networking Commands
Managing networks effectively is essential for system administration.
5.1 Check Network Status
View active network interfaces and IP addresses:
ip a
5.2 Connect to Wi-Fi
For command-line Wi-Fi management, use iwctl
(if using iwd
):
sudo iwctl
# Then inside iwctl
station wlan0 connect SSID
5.3 Test Network Connectivity
- Ping a website:
ping -c 4 google.com
- Trace the network route:
traceroute google.com
6. Advanced File Operations
6.1 Recursive File Searches
Find files by name:
find /path/to/search -name "filename"
6.2 Archiving and Compression
- Create a compressed archive:
tar -czvf archive.tar.gz /path/to/directory
- Extract an archive:
tar -xzvf archive.tar.gz
6.3 File Permissions
- Change ownership:
sudo chown user:group file
- Change permissions:
chmod 755 file
7. Performance Monitoring
Keep your system running smoothly by monitoring its performance.
7.1 View Resource Usage
- Top processes:
htop
- CPU usage:
mpstat
- Disk I/O:
iostat
7.2 Monitor Logs
Check system logs for troubleshooting:
sudo journalctl -xe
8. System Recovery Commands
8.1 Boot Repair
Use chroot
from a live USB to fix boot issues:
mount /dev/sda1 /mnt
arch-chroot /mnt
8.2 Restore Pacman Keys
If your keyring is corrupted:
sudo pacman-key --init
sudo pacman-key --populate archlinux
8.3 Recover Lost GRUB
Reinstall GRUB if it’s missing:
grub-install /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg
Conclusion
These advanced commands and techniques give you the tools to manage, maintain, and troubleshoot your Arch Linux system with confidence. Mastery comes with practice, so don’t hesitate to experiment and explore. Remember, the Arch Wiki is your ultimate companion for all things Arch Linux.
What other commands do you use on Arch Linux? Share your tips in the comments below!
~Trixsec
Top comments (0)