1.4 KiB
1.4 KiB
Linux+ 2.1.2: Finding files, links and device files
Finding files by size and permission, the locate database, hard and symbolic links, and finding which process holds a file open.
Before you start
Work as root. The lab installs plocate and lsof, leaves a large file
and an extra set-user-ID program somewhere on the root filesystem, and
starts a process that keeps /tmp/held.txt open. Write answers to the
files in /root/lab-answers/. Don't run the chapter's final clean-up
(rm -f ... /tmp/h.txt /tmp/s.txt ~/findme-*.txt): the lab grades those
files, and le-lab reset removes them.
Tasks
- Find every regular file over 50 MiB and every set-user-ID file on the
root filesystem (don't cross into other filesystems). Save their full
paths, one per line, in
/root/lab-answers/1(ls -lstyle lines are fine too). - Create a file
~/findme-<something>.txt, then makelocate findme-find it. - In
/tmp, createt.txtcontaininghi, a hard linkh.txtto it and a symbolic links.txtto it. Then deletet.txt, and see which of the two links still works. - Find the process that holds
/tmp/held.txtopen, and write its PID to/root/lab-answers/4.
Hints
find / -xdev -type f -size +50M,find / -xdev -perm -4000 -type f,2>/dev/null.locateonly knows what the lastupdatedbsaw.ln,ln -s,ls -li.lsof /tmp/held.txt, orfuser.