Linux miscellaneous

Linux stuff that does not go elsewhere

view on github

Default system environment variables

$LANG
$LANGUAGE
$PATH
$GREP_COLORS
$LS_COLORS
$USER
$LOGNAME

How to free up disk space on a linux machine

✔️ Scan the system for large files

# print the 20 largest files in /var/log and subdurectories
sudo du -a /var/log | sort -n -r | head -n 20

✔️ Clear APT cache

# check apt cache disk usage
sudo du -ch --block-size=k --summarize /var/cache/apt/archives/.

# clear apt cache
sudo apt-get clean

# uninstall orphan dependencies
sudo apt-get autoremove

✔️ Remove docker items

# remove all unused docker containers, images, networks
docker system prune -a

# remove all unused docker volumes
docker volume prune -a

✔️ Remove app builds and toolchain related items

# check npm cache disk usage
du -ch --block-size=k --summarize ~/.npm/.

# clear npm cache
npm cache clean --force

# display all installed puppeteer-compatible chromium versions
ls -la ~/.cache/puppeteer/chrome/.

# display all installed node versions
ls -la ~/.nvm/versions/node/.

# display current / switch to / uninstall node version
nvm current
nvm use <version>
nvm uninstall <version>

# recursively search for builds and node_modules folders
find -P git -maxdepth 5 -regextype 'posix-extended' -regex '^.*/(node_modules|build|\.next|\.vercel)$' -ls

Miscellaneous

# system users ... 
root
systemd-timesync
messagebus
rtkit

# questions and remarks ...
# see if possible to use locate instead of find in the custom commands
# use of wildcards in shell commands ls -la ~/.*/*.jpg ?
# default access rights on users home directories is drwxr-xr-x ?
# permissions for /bin/su and /bin/sudo are -rwsr-xr-x ? what's that s for ? SUID 
# permissions for /tmp are drwxrwxrwt ? what's that t for ? 
# /bin/bash vs /bin/sh (/bin/dash) ? history not available ? sh is crap
# investigate the at shell command when necessary (advanced task scheduling/send mail, etc...)