System admin
Date/time, locale, cron, kernel modules, tmpfiles.d, power, hostname, misc utilities.
Date & time
Show:
datedate +"%Y-%m-%d %H:%M:%S"date +%FUTC:
date -uStatus (tz, NTP, RTC):
timedatectlList timezones:
timedatectl list-timezones | grep -i europeSet timezone:
sudo timedatectl set-timezone Europe/ParisEnable NTP:
sudo timedatectl set-ntp trueNTP status:
timedatectl timesync-statusNTP config:
/etc/systemd/timesyncd.conf:[Time] NTP=0.arch.pool.ntp.org 1.arch.pool.ntp.orgHardware clock:
sudo hwclock --showsudo hwclock --systohcManual set (rarely needed):
sudo date -s "2025-01-15 12:00:00"
Date arithmetic
date -d "+7 days"date -d "last monday"date -d "2 hours ago"date -d "2025-01-01 + 90 days" +%F
Epoch
Now in epoch:
date +%sEpoch → human:
date -d @1700000000
Locale
Current settings:
localeAvailable:
locale -aGenerate (edit
/etc/locale.genfirst):sudo locale-genSet system locale / keymap:
sudo localectl set-locale LANG=en_US.UTF-8sudo localectl set-keymap usStatus:
localectl statusPer-session override:
export LANG=en_US.UTF-8 export LC_ALL=en_US.UTF-8
Cron syntax
Prefer systemd timers (see systemd). Cron format:
┌─ minute (0-59)
│ ┌─ hour (0-23)
│ │ ┌─ day of month (1-31)
│ │ │ ┌─ month (1-12)
│ │ │ │ ┌─ day of week (0-7; 0/7 = Sun)
│ │ │ │ │
* * * * * command
| Expression | Meaning |
|---|---|
*/5 * * * * | every 5 min |
0 * * * * | every hour |
0 0 * * * | daily midnight |
0 2 * * * | daily 02:00 |
0 0 * * 0 | Sunday midnight |
0 0 1 * * | 1st of month |
30 8 * * 1-5 | Mon–Fri 08:30 |
0 */6 * * * | every 6 hours |
cronie
Install + enable:
sudo systemctl enable --now cronie
- Edit / list / remove:
crontab -e/crontab -l/crontab -r
Kernel modules
Loaded modules:
lsmodInfo on a module:
modinfo nvidiaParameters only:
modinfo -p nvidiaLoad (with deps):
sudo modprobe nvidiaLoad with params:
sudo modprobe snd_hda_intel power_save=1Unload:
sudo modprobe -r nvidiaShow deps:
modprobe --show-depends nvidiaReload:
sudo modprobe -r nvidia && sudo modprobe nvidia
Persistent config
Blacklist (
/etc/modprobe.d/blacklist.conf):blacklist nouveauAuto-load at boot (
/etc/modules-load.d/custom.conf):nvidia vhost_netModule options (
/etc/modprobe.d/nvidia.conf):options nvidia NVreg_UsePageAttributeTable=1
tmpfiles.d
Format: Type Path Mode Owner Group Age Argument in /etc/tmpfiles.d/*.conf.
| Type | Action |
|---|---|
d | create dir |
D | create dir + clean by age |
f | create file (if absent) |
F | create file (truncate) |
L | symlink |
R | remove recursively |
r | remove |
z | adjust perms |
Z | adjust perms recursively |
Examples:
d /run/myapp 0755 myuser mygroup -
D /tmp/myapp 0755 root root 7d
L /etc/myapp.conf - - - - /opt/myapp/config/myapp.conf
f /run/myapp/pid 0644 myuser mygroup - ""
R /tmp/old-data -
Apply:
sudo systemd-tmpfiles --createClean by age:
sudo systemd-tmpfiles --cleanRemove R/r entries:
sudo systemd-tmpfiles --removeDry run:
sudo systemd-tmpfiles --create --dry-run
Power management
Shutdown now:
sudo poweroff/sudo shutdown nowScheduled:
sudo shutdown -h +10/sudo shutdown -h 22:00Cancel:
sudo shutdown -cReboot:
sudo rebootSuspend (RAM):
sudo systemctl suspendHibernate (swap):
sudo systemctl hibernateHybrid:
sudo systemctl hybrid-sleepSuspend-then-hibernate:
sudo systemctl suspend-then-hibernatelogind config (
/etc/systemd/logind.conf):HandleLidSwitch=suspend HandlePowerKey=poweroff IdleAction=suspend IdleActionSec=30minReload:
sudo systemctl restart systemd-logindInhibit sleep:
systemd-inhibit --what=sleep --who="my-script" --why="downloading" wget URLList inhibitors:
systemd-inhibit --listCPU governor:
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governorSet performance:
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governorTLP (laptop power):
sudo systemctl enable --now tlp sudo tlp-stat -b
Hostname
Show:
hostname/hostnamectlSet persistent:
sudo hostnamectl set-hostname myarchPretty hostname (UI display):
sudo hostnamectl set-hostname "My Arch Workstation" --prettyFiles:
/etc/hostname,/etc/hosts(127.0.1.1 myarch).
cron vs systemd timer
| Feature | cron | systemd timer |
|---|---|---|
| Logging | syslog/mail | journalctl |
| Dependencies | none | full systemd |
| Missed runs | lost | Persistent=true catches up |
| Random delay | no | RandomizedDelaySec |
| Resource limits | no | cgroups |
| Calendar syntax | 5 fields | flexible OnCalendar= |
| Boot-relative | no | OnBootSec=, OnStartupSec= |
Misc utilities
Repeat command every 2s:
watch -n 2 "df -h"Highlight changes:
watch -d "free -h"Answer yes to prompts:
yes | pacman -S packageLow CPU priority:
nice -n 19 make -j$(nproc)Low I/O priority (idle class):
ionice -c3 rsync -a src/ dest/Timeout:
timeout 30 wget URLTimeout with SIGKILL:
timeout --signal=KILL 10 commandRetry until success:
until ping -c1 google.com; do sleep 1; doneOne-off scheduled:
sudo systemd-run --on-active=30min /usr/local/bin/task.shecho "reboot" | sudo at 02:00Bulk rename (perl-rename):
rename 's/\.jpeg$/\.jpg/' *.jpeg rename 'y/A-Z/a-z/' *Random data:
head -c 32 /dev/urandom | base64openssl rand -hex 16Checksums:
sha256sum file.txtsha256sum -c checksums.txtCopy with progress:
rsync -ah --progress src destHTTP server (current dir):
python -m http.server 8000Base64:
echo "hello" | base64echo "aGVsbG8K" | base64 -dURL encode/decode (python):
python -c "import urllib.parse; print(urllib.parse.quote('hello world'))" python -c "import urllib.parse; print(urllib.parse.unquote('hello%20world'))"JSON pretty:
jq . data.jsonISO from directory:
mkisofs -o image.iso /path/to/dirWrite ISO to USB:
sudo dd if=archlinux.iso of=/dev/sdb bs=4M status=progress oflag=syncSystem info:
fastfetch/neofetch
Useful one-liners
Largest files everywhere:
find / -type f -exec du -h {} + 2>/dev/null | sort -rh | head -20Kill all matching pattern:
pkill -f "pattern"Tail a file:
tail -f /var/log/pacman.logListen / connect port:
nc -l 8080/nc host 8080Diff dir contents:
diff <(ls dir1) <(ls dir2)Count files by extension:
find . -type f | sed 's/.*\.//' | sort | uniq -c | sort -rn