Linux
Arch
I run Arch as my daily driver on my laptop. This section will contain general notes about my experience.
Package Management
Full Upgrade:
$ pacman -Syu
Install a package:
pacman -S {package}
Remove package:
$ pacman -R {package}
Remove package and dependencies:
$ pacman -Rns {package}
List AUR packages:
$ pacman -Qm
Root Directory Out of Space
One day my root directory was suddenly full. I have 20GB allocated for my root partition.
This prevented me from being able to update my system.
First, I ran the following to clear up some of my pacman package cache.
$ paccache -r
This only removed 1.62 GiB worth of data.
I then ran the following to remove an additional 4 GiB:
$ sudo pacman -Sc
I was also experimenting with docker to test out different applications. Docker images were taking up a lot of space so I had to use docker system prune to make more space. This gave me another 1.5 GB back.
Later I discovered that I could configure the docker daemon data directory away from the default root partition. I recommend this change if you don’t want to run [system, image] prune
all the time.
If you want a report for which directories under root have built up, I found the following command useful from this post.
On my system I found /var
and /usr
to be taking up the most space.
# Searching through root
sudo du -hsx /* | sort -rh | head -n 40
# Examine usr and var directories
sudo du -hsx /usr/* | sort -rh | head -n 40
sudo du -hsx /var/* | sort -rh | head -n 40
Bonus: Clean old journals and logs, courtesy of rabcor.
sudo journalctl --flush --vacuum-files=5
General
This section contains general linux notes.
Add System Users
These commands are run when you only have a root
user account on any linux system. This might happen on fresh installations of various operating systems.
It’s a good idea to create a separate account that does not have root privileges by default. Instead, add the user to the sudo
group to allow it to run higher privilege commands when they are needed.
Shell
# Add User
adduser username
# Add User to sudo group
usermod -a -G sudo username
adduser
is a wrapper for useradd
.
Nano
Select All & Delete
How to delete everything from a file using Nano:
- Position cursor at line 1, column 1.
- Start Mark: Control + 6
- Mark to End: Alt + /
- Delete Line (Marked lines): Control + K