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 -perm -4000 lists every setuid program on the system

Find
~/tips/tip-find-perm-4000-setuid

sudo find / -xdev -type f -perm -4000 2>/dev/null

Lists every file that runs with the rights of its owner.

A setuid binary runs with the rights of its owner, usually root. An audit starts with the list of them.

sudo find / -xdev -type f -perm -4000 2>/dev/null

-perm -4000 matches files with that bit set, whatever the other bits are. -perm /6000 matches setuid or setgid. Save the output once and compare it later with diff, so a new entry stands out. -xdev keeps find on one filesystem, so repeat the command for every other mount you want to cover. Expect entries such as sudo, passwd and mount. Add -ls if you also want the owner and size in the list.

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