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.

Σχετικά με αυτήν τη δέσμη

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.

Κάρτες σε αυτήν τη δέσμη

  1. Κάρτα 1

    Ερώτηση

    In GNU find, archive is a symlink to the readable directory records. What does find archive -print print if records contains index.txt?

    Απάντηση

    Only archive. The default mode treats the starting point as a link entry, so the search ends there.

  2. Κάρτα 2

    Ερώτηση

    readout is a symlink to the regular file samples.txt. What does GNU find -L readout -print print?

    Απάντηση

    Only readout. A regular-file target has no children to search.

  3. Κάρτα 3

    Ερώτηση

    You want GNU find to follow readable symlinks passed as starting points and treat symlinks found during the walk as link entries. Which mode fits?

    Απάντηση

    -H. Its traversal follows links explicitly supplied as starting points.

  4. Κάρτα 4

    Ερώτηση

    How do you fix GNU find inbox -L -print so it uses -L?

    Απάντηση

    find -L inbox -print. Put -L before the first starting point.

  5. Κάρτα 5

    Ερώτηση

    gateway is a symlink to the readable directory warehouse, which contains only the regular file manifest.txt. Which path does find -H gateway -type f -print print?

    Απάντηση

    gateway/manifest.txt. The printed path keeps the spelling of the starting point.

  6. Κάρτα 6

    Ερώτηση

    Which GNU find option explicitly keeps both starting-point and encountered symlinks as link entries during traversal?

    Απάντηση

    -P. It selects the default traversal mode.

  7. Κάρτα 7

    Ερώτηση

    current.dat is a symlink to the regular file run.dat. What does find -P current.dat -type f -print print?

    Απάντηση

    Nothing. With -P, -type f checks the entry itself, which is a symlink.

  8. Κάρτα 8

    Ερώτηση

    GNU find starts in a real directory and needs to search inside the readable directory symlinks it meets along the way. Which mode opens those paths?

    Απάντηση

    -L. It follows resolvable symbolic links encountered during the search.

  9. Κάρτα 9

    Ερώτηση

    port is a symlink to a readable directory. When find -L port -maxdepth 0 -type d -print tests the starting point, what does it print?

    Απάντηση

    port. With -L, -type d sees the resolved directory type.

  10. Κάρτα 10

    Ερώτηση

    desk/mix stores the symlink text ../library/./mix.txt, which resolves to the regular file library/mix.txt. Does find -P desk -lname '../library/mix.txt' -print print desk/mix?

    Απάντηση

    No. -lname matches the stored text. The extra ./ is part of that text.

  11. Κάρτα 11

    Ερώτηση

    quick.ini is a symlink to the regular file defaults.ini. What does find -H quick.ini -type f -print print?

    Απάντηση

    quick.ini. Under -H, a resolvable symlink supplied as a starting point is tested using its target type.

  12. Κάρτα 12

    Ερώτηση

    trail is a symlink to the readable directory records, whose only entry is the regular file day.txt. Which paths does find -L trail records -name day.txt -print print?

    Απάντηση

    trail/day.txt and records/day.txt. GNU find searches from each starting point and prints the path used to reach a match.

  13. Κάρτα 13

    Ερώτηση

    The only entries in shelf are the regular file item.txt, a symlink kept to it, and a symlink lost to missing old.txt. What does find shelf -type l -print list?

    Απάντηση

    shelf/kept and shelf/lost. Both entries are symlinks. The default mode tests each link entry itself.

  14. Κάρτα 14

    Ερώτηση

    The only entries in survey are the regular file map.dat and a symlink map-copy to it. Which paths does find -P survey -xtype f -print print?

    Απάντηση

    survey/map.dat and survey/map-copy. With -P, -xtype f checks a live symlink's target type and a regular file's own type.

  15. Κάρτα 15

    Ερώτηση

    drop is a real directory. Its symlink route points to readable ../intake, which contains label.txt. How should you change the starting point in find -H drop -name label.txt -print to reach drop/route/label.txt?

    Απάντηση

    Use drop/route as the starting point.

    find -H drop/route -name label.txt -print
    
  16. Κάρτα 16

    Ερώτηση

    handbook is a symlink to the regular file manual.txt. Which exact basename should replace PATTERN in find -L handbook -name PATTERN -print?

    Απάντηση

    handbook. The basename that -name tests comes from the path GNU find is visiting.

  17. Κάρτα 17

    Ερώτηση

    Which link-following mode takes effect in GNU find -L -P -H stage -print?

    Απάντηση

    -H. The last of -P, -H and -L sets the link-following mode.

  18. Κάρτα 18

    Ερώτηση

    scan has symlink ok to existing regular file new.dat and symlink stale to missing old.dat. Which link path does find -L scan -type l -print print?

    Απάντηση

    scan/stale. The missing target leaves GNU find with the link's own type for -type l.

  19. Κάρτα 19

    Ερώτηση

    GNU find can read and search both directories. The only entry in incoming is offsite, a symlink to the readable sibling directory ../shared. The only entry in shared is the regular file memo.txt. Which path does find -L incoming -name memo.txt -print print?

    Απάντηση

    incoming/offsite/memo.txt. Following the directory link lets the search reach into shared.

  20. Κάρτα 20

    Ερώτηση

    How do you use GNU find to list only symlinks to existing directories under yard while keeping the walk out of symlinked directories?

    Απάντηση

    find -P yard -type l -xtype d -print
    

    -type l selects the link entry and -xtype d checks its target type.

  21. Κάρτα 21

    Ερώτηση

    The symlink tile stores stone.txt, the name of a readable regular file. Does find -L tile -lname stone.txt -print print anything?

    Απάντηση

    No. With -L, -lname is false for a link whose target GNU find can resolve.

  22. Κάρτα 22

    Ερώτηση

    You need find -L routes -type l -print to print resolvable symlinks as well as symlinks to missing targets. Which test should replace -type l?

    Απάντηση

    -xtype l. With -L, it matches both resolvable symlinks and symlinks with missing targets.

  23. Κάρτα 23

    Ερώτηση

    portal is a symlink to the readable directory paper, which contains notes.txt. In find -L portal -path PATTERN -print, what literal path should replace PATTERN to print only that file through the symlink?

    Απάντηση

    portal/notes.txt. The path GNU find tests starts with the supplied starting point.

  24. Κάρτα 24

    Ερώτηση

    The symlink shortcut points to another symlink, relay, which points to readable directory workspace. Does find -P shortcut -xtype d -print print anything?

    Απάντηση

    Yes, shortcut. With -P, -xtype d checks the final target, which is a directory.

  25. Κάρτα 25

    Ερώτηση

    The symlink bookmark stores missing.txt, a path that does not exist. What does find -L bookmark -lname missing.txt -print print?

    Απάντηση

    bookmark. When the target is missing, -lname can match the stored text of the link itself.

  26. Κάρτα 26

    Ερώτηση

    The only entries in dock are the regular file report.txt and a symlink alias to it. What does find -L dock -xtype f -print list?

    Απάντηση

    Only dock/report.txt. For the live link, -xtype under -L checks the link type. For the regular file it checks the file type.

  27. Κάρτα 27

    Ερώτηση

    entrance is a symlink to a readable directory containing badge.txt. What can find -H entrance -maxdepth 0 -print print?

    Απάντηση

    Only entrance. Depth zero is the starting point, even when GNU find follows that link.

  28. Κάρτα 28

    Ερώτηση

    signpost is a symlink to missing stop.txt. What changes in find -H signpost -print if signpost itself is also missing?

    Απάντηση

    The search reports a missing starting path and prints no match. While the dangling symlink exists, the command prints signpost.

  29. Κάρτα 29

    Ερώτηση

    Which GNU find type test lists symlinks with missing targets under cache when you keep -P? Assume every link either resolves or points to a missing path.

    Απάντηση

    -xtype l.

    find -P cache -xtype l -print
    
  30. Κάρτα 30

    Ερώτηση

    The symlink tray/pin points to readable regular file ../draft.txt. In find -H START -xtype f -print, how does the match for tray/pin change if you move the start from tray to tray/pin?

    Απάντηση

    It matches from tray and stops matching when it is the start. Under -H, -xtype checks an encountered live link's target type and a live starting link's own type.

  31. Κάρτα 31

    Ερώτηση

    sort has symlink aisle to readable directory ../store. In store, gone is a symlink to missing unit.txt. Does find -L sort -type l -print reach and print sort/aisle/gone?

    Απάντηση

    Yes. -L follows sort/aisle into the directory, and -type l selects the dangling link inside.

  32. Κάρτα 32

    Ερώτηση

    deliveries is a symlink to a readable directory. What GNU find command opens that starting point and prints the symlink entries it finds, keeping later links as entries?

    Απάντηση

    find -H deliveries -type l -print
    

    -H follows the starting link. Inside, -type l selects the symlink entries.

An orange cord connects a small blue folder tab to a cream folder on a dark green background.

32 κάρτες

GNU find Symlink Flashcards

Μελετήστε αυτήν τη δέσμη δωρεάν

Το Nibomo ανοίγει για να ξεκινήσετε τη μελέτη.

Παρόμοιες δέσμες