brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: find -xtype l lists symlinks that point to nothing

Find
~/tips/tip-find-xtype-broken-symlinks

find /srv /etc -xtype l -ls

Lists symbolic links whose target no longer exists.

A moved or deleted target leaves broken symlinks behind, and those cause strange errors in scripts and web servers.

find /srv /etc -xtype l -ls

-xtype l checks the type of the file a symlink points to, and it reports l only when the link is dangling. Check the targets with -ls before you remove anything. -xtype is a GNU feature. A portable form is find . -type l ! -exec test -e {} \; -print. Run it on the folders where you keep links, for example a web root or /etc/nginx/sites-enabled.

Further reading: find manual page

More Find tips find / -maxdepth 1 -fstype proc find /backup -name '*.gz' ! -exec gzip -t {} \; -print 2>/dev/null find /srv/downloads -type f -size +100M -size -1G -exec ls -lh {} + find /srv/data -depth -print find /srv -xdev -samefile /srv/downloads/movie.mkv All Find tips (46) All topics

Link