Working in /home/carol, you run `ln -s ../shared/data.csv /srv/app/data.csv`. Which file will /srv/app/data.csv resolve to when a program opens it?
LPIC-1 Exam 101-500, objective 104. Devices, Linux filesystems, filesystem hierarchy standard hard
Machine-checked — no person has signed for it. This question was read against the source cited below by an automated pass, which found no contradiction. That is a weaker claim than it sounds: the same kind of process wrote the question, so it can confirm its own mistake.
Treat it as a good draft rather than as settled fact, and read the source below before you rely on it. It is not used in mock exams here — only questions a person has signed for are.
How these questions are written — where each question comes from, what the verification ledger records, and what happens when one is found wrong.
The options
Correct /srv/shared/data.csv
Correct. The relative target is stored verbatim and interpreted against the directory holding the link, /srv/app, so ../shared/data.csv means /srv/shared/data.csv.
Not correct /home/shared/data.csv
Wrong. That would be the result if ln resolved the target against the current working directory at creation time. It does not: the string is stored as given and resolved only when the link is followed.
Not correct /srv/app/shared/data.csv
Wrong. This treats the leading ../ as though it were absent. The .. component is a real directory entry and moves the lookup one level up from /srv/app.
Not correct Nothing, because ln refuses to create a link whose target does not exist relative to the current directory
Wrong. ln -s performs no check on the target at all; creating a dangling symbolic link is legal and often deliberate, for example when the target will appear later.
Why
A symbolic link stores its target as an uninterpreted string. When the link is followed, a relative target is resolved against the directory that contains the link, never against the process's working directory at creation time. That is why relative symlinks survive the whole tree being moved or copied, and it is also why they break when only the link is moved. GNU ln -r computes such a relative target for you from an absolute path you supply.
Where this comes from
- Cited
- manual page symlink(7)
Practise this
Reading one question is not practice. The trainer will draw a short set from objective 104 and space the ones you get wrong.
More questions on this objective
- A new disk /dev/sdb has no partition table at all. Which command writes an empty GPT partition table onto it without dropping you into an interactive editor? machine-checked
- You need the partition /dev/sdc1 on a USB stick to carry a FAT32 filesystem so that Windows machines can read and write it. Which command creates it? machine-checked
- You have just run `mkswap /dev/sdb2`. Which command makes the kernel start using that swap area immediately, without a reboot? machine-checked
- Why is it dangerous to run e2fsck against an ext4 filesystem that is currently mounted read-write? machine-checked
- On an ext4 filesystem at /dev/sda1 you want an automatic check to be forced after every 30 mounts. Which command sets that? machine-checked
- `df -h /var` reports the filesystem 100% full, but `du -sh /var` accounts for only about half that space. Nothing is hidden under a mount point. What is the most likely explanation? machine-checked
All questions on Devices, Linux filesystems, filesystem hierarchy standard