Determine whether report and report-copy are hard links or separate copies.
Display inode numbers together with long-format attributes.
Which command is appropriate?
Hard-linked names share an inode number. ls -li displays inode numbers and long-format metadata together.
Detailed explanation
ls -l report report-copyIncorrect. Long format alone does not display inode numbers.
ls -F report report-copyIncorrect. -F classifies names and does not show inodes.
ls -li report report-copyCorrect. ls -li report report-copy displays inode numbers for comparison.
ls -s report report-copyIncorrect. -s displays allocated blocks, not inode numbers.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); touch "$tmp/report"; ln "$tmp/report" "$tmp/report-copy"; ls -li "$tmp/report" "$tmp/report-copy"; rm -rf "$tmp"Expected result
両行のinode番号が同じで、リンク数が2Key points
- -i is inode
- -l is long format
- Hard links share an inode
Notes
- Environment: Linux / GNU coreutils 9.x / 一時ファイル
- Use disposable files and directories for link experiments.
- Link behavior can differ for special filesystem objects and cross-filesystem operations.
Foundation review
Place the operation
Matching inode numbers are evidence that two names are hard links to one filesystem object.
Check the side effect
Create a hard link in a temporary directory and compare the two inode numbers.