GNU find Symlink Flashcards
Read-only symlink drills for GNU find on Linux. Choose -P, -H or -L, predict printed paths, and check links with -type, -xtype and -lname.
O tej talii
A symlink can lead GNU find into another directory. What path will it print? These 32 flashcards give Linux learners practice choosing how a search follows links and predicting what it finds. Every example uses read-only commands tested on GNU find.
Start by predicting what short commands print and choosing -P, -H or -L for a search. Then work out which entries pass -type, -xtype or -lname. Later cards combine those choices with dangling links, targets outside the starting directory and small command fixes. Each flag comes with a search goal or a concrete example so you practise deciding when to use it. Hard-link tests and link removal are outside the scope of these exercises.
The examples are based on the GNU Findutils manual. The cover is AI-generated. The original questions, answers, arrangement, description and illustration are available under CC0 1.0 to the extent rights apply.
Karty w tej talii
Karta 1
Pytanie
In GNU
find,archiveis a symlink to the readable directoryrecords. What doesfind archive -printprint ifrecordscontainsindex.txt?Odpowiedź
Only
archive. The default mode treats the starting point as a link entry, so the search ends there.Karta 2
Pytanie
readoutis a symlink to the regular filesamples.txt. What does GNUfind -L readout -printprint?Odpowiedź
Only
readout. A regular-file target has no children to search.Karta 3
Pytanie
You want GNU
findto follow readable symlinks passed as starting points and treat symlinks found during the walk as link entries. Which mode fits?Odpowiedź
-H. Its traversal follows links explicitly supplied as starting points.Karta 4
Pytanie
How do you fix GNU
find inbox -L -printso it uses-L?Odpowiedź
find -L inbox -print. Put-Lbefore the first starting point.Karta 5
Pytanie
gatewayis a symlink to the readable directorywarehouse, which contains only the regular filemanifest.txt. Which path doesfind -H gateway -type f -printprint?Odpowiedź
gateway/manifest.txt. The printed path keeps the spelling of the starting point.Karta 6
Pytanie
Which GNU
findoption explicitly keeps both starting-point and encountered symlinks as link entries during traversal?Odpowiedź
-P. It selects the default traversal mode.Karta 7
Pytanie
current.datis a symlink to the regular filerun.dat. What doesfind -P current.dat -type f -printprint?Odpowiedź
Nothing. With
-P,-type fchecks the entry itself, which is a symlink.Karta 8
Pytanie
GNU
findstarts in a real directory and needs to search inside the readable directory symlinks it meets along the way. Which mode opens those paths?Odpowiedź
-L. It follows resolvable symbolic links encountered during the search.Karta 9
Pytanie
portis a symlink to a readable directory. Whenfind -L port -maxdepth 0 -type d -printtests the starting point, what does it print?Odpowiedź
port. With-L,-type dsees the resolved directory type.Karta 10
Pytanie
desk/mixstores the symlink text../library/./mix.txt, which resolves to the regular filelibrary/mix.txt. Doesfind -P desk -lname '../library/mix.txt' -printprintdesk/mix?Odpowiedź
No.
-lnamematches the stored text. The extra./is part of that text.Karta 11
Pytanie
quick.iniis a symlink to the regular filedefaults.ini. What doesfind -H quick.ini -type f -printprint?Odpowiedź
quick.ini. Under-H, a resolvable symlink supplied as a starting point is tested using its target type.Karta 12
Pytanie
trailis a symlink to the readable directoryrecords, whose only entry is the regular fileday.txt. Which paths doesfind -L trail records -name day.txt -printprint?Odpowiedź
trail/day.txtandrecords/day.txt. GNUfindsearches from each starting point and prints the path used to reach a match.Karta 13
Pytanie
The only entries in
shelfare the regular fileitem.txt, a symlinkkeptto it, and a symlinklostto missingold.txt. What doesfind shelf -type l -printlist?Odpowiedź
shelf/keptandshelf/lost. Both entries are symlinks. The default mode tests each link entry itself.Karta 14
Pytanie
The only entries in
surveyare the regular filemap.datand a symlinkmap-copyto it. Which paths doesfind -P survey -xtype f -printprint?Odpowiedź
survey/map.datandsurvey/map-copy. With-P,-xtype fchecks a live symlink's target type and a regular file's own type.Karta 15
Pytanie
dropis a real directory. Its symlinkroutepoints to readable../intake, which containslabel.txt. How should you change the starting point infind -H drop -name label.txt -printto reachdrop/route/label.txt?Odpowiedź
Use
drop/routeas the starting point.find -H drop/route -name label.txt -printKarta 16
Pytanie
handbookis a symlink to the regular filemanual.txt. Which exact basename should replacePATTERNinfind -L handbook -name PATTERN -print?Odpowiedź
handbook. The basename that-nametests comes from the path GNUfindis visiting.Karta 17
Pytanie
Which link-following mode takes effect in GNU
find -L -P -H stage -print?Odpowiedź
-H. The last of-P,-Hand-Lsets the link-following mode.Karta 18
Pytanie
scanhas symlinkokto existing regular filenew.datand symlinkstaleto missingold.dat. Which link path doesfind -L scan -type l -printprint?Odpowiedź
scan/stale. The missing target leaves GNUfindwith the link's own type for-type l.Karta 19
Pytanie
GNU
findcan read and search both directories. The only entry inincomingisoffsite, a symlink to the readable sibling directory../shared. The only entry insharedis the regular filememo.txt. Which path doesfind -L incoming -name memo.txt -printprint?Odpowiedź
incoming/offsite/memo.txt. Following the directory link lets the search reach intoshared.Karta 20
Pytanie
How do you use GNU
findto list only symlinks to existing directories underyardwhile keeping the walk out of symlinked directories?Odpowiedź
find -P yard -type l -xtype d -print-type lselects the link entry and-xtype dchecks its target type.Karta 21
Pytanie
The symlink
tilestoresstone.txt, the name of a readable regular file. Doesfind -L tile -lname stone.txt -printprint anything?Odpowiedź
No. With
-L,-lnameis false for a link whose target GNUfindcan resolve.Karta 22
Pytanie
You need
find -L routes -type l -printto print resolvable symlinks as well as symlinks to missing targets. Which test should replace-type l?Odpowiedź
-xtype l. With-L, it matches both resolvable symlinks and symlinks with missing targets.Karta 23
Pytanie
portalis a symlink to the readable directorypaper, which containsnotes.txt. Infind -L portal -path PATTERN -print, what literal path should replacePATTERNto print only that file through the symlink?Odpowiedź
portal/notes.txt. The path GNUfindtests starts with the supplied starting point.Karta 24
Pytanie
The symlink
shortcutpoints to another symlink,relay, which points to readable directoryworkspace. Doesfind -P shortcut -xtype d -printprint anything?Odpowiedź
Yes,
shortcut. With-P,-xtype dchecks the final target, which is a directory.Karta 25
Pytanie
The symlink
bookmarkstoresmissing.txt, a path that does not exist. What doesfind -L bookmark -lname missing.txt -printprint?Odpowiedź
bookmark. When the target is missing,-lnamecan match the stored text of the link itself.Karta 26
Pytanie
The only entries in
dockare the regular filereport.txtand a symlinkaliasto it. What doesfind -L dock -xtype f -printlist?Odpowiedź
Only
dock/report.txt. For the live link,-xtypeunder-Lchecks the link type. For the regular file it checks the file type.Karta 27
Pytanie
entranceis a symlink to a readable directory containingbadge.txt. What canfind -H entrance -maxdepth 0 -printprint?Odpowiedź
Only
entrance. Depth zero is the starting point, even when GNUfindfollows that link.Karta 28
Pytanie
signpostis a symlink to missingstop.txt. What changes infind -H signpost -printifsignpostitself is also missing?Odpowiedź
The search reports a missing starting path and prints no match. While the dangling symlink exists, the command prints
signpost.Karta 29
Pytanie
Which GNU
findtype test lists symlinks with missing targets undercachewhen you keep-P? Assume every link either resolves or points to a missing path.Odpowiedź
-xtype l.find -P cache -xtype l -printKarta 30
Pytanie
The symlink
tray/pinpoints to readable regular file../draft.txt. Infind -H START -xtype f -print, how does the match fortray/pinchange if you move the start fromtraytotray/pin?Odpowiedź
It matches from
trayand stops matching when it is the start. Under-H,-xtypechecks an encountered live link's target type and a live starting link's own type.Karta 31
Pytanie
sorthas symlinkaisleto readable directory../store. Instore,goneis a symlink to missingunit.txt. Doesfind -L sort -type l -printreach and printsort/aisle/gone?Odpowiedź
Yes.
-Lfollowssort/aisleinto the directory, and-type lselects the dangling link inside.Karta 32
Pytanie
deliveriesis a symlink to a readable directory. What GNUfindcommand opens that starting point and prints the symlink entries it finds, keeping later links as entries?Odpowiedź
find -H deliveries -type l -print-Hfollows the starting link. Inside,-type lselects the symlink entries.
32 karty
GNU find Symlink Flashcards
Otworzy się Nibomo, żeby od razu zacząć naukę.