From the linked inode wiki page:
A file system relies on data structures about the files, beside the file content. The former is called metadata—data that describes data. Each file is associated with an inode, which is identified by an integer number, often referred to as an i-number or inode number.
Inodes store information about files and directories (folders), such as file ownership, access mode (read, write, execute permissions), and file type. On many types of file system implementations, the maximum number of inodes is fixed at file system creation, limiting the maximum number of files the file system can hold. A typical allocation heuristic for inodes in a file system is one percent of total size.
The inode number indexes a table of inodes in a known location on the device; from the inode number, the file system driver portion of the kernel can access the contents of the inode, including the location of the file allowing access to the file.
A file's inode number can be found using the ls -i
command. The ls -i
command prints the i-node number in the first column of the report.
As noted above, ls -i
can give you the inode number - which is likely where the link is. ls -l
will provide you a path to the link's target. The latter will require a stat()
syscall, but, because a file's directory listing - its dentry - will contain its inode number and filename, the ls -i
form likely will not. At least, filesystem depending, it will likely not require a stat()
for any file object other than the containing directory.
You can modify the way ls
reports on links with the following options, as specified by POSIX:
-F
- Do not follow symbolic links named as operands unless the -H or -L options are specified. Write a slash ( '/' ) immediately after each pathname that is a directory, an asterisk ( '*' ) after each that is executable, a vertical bar ( '|' ) after each that is a FIFO, and an at sign ( '@' ) after each that is a symbolic link. For other file types, other symbols may be written.
-H
- If a symbolic link referencing a file of type directory is specified on the command line, ls shall evaluate the file information and file type to be those of the file referenced by the link, and not the link itself; however, ls shall write the name of the link itself and not the file referenced by the link.
-L
- Evaluate the file information and file type for all symbolic links (whether named on the command line or encountered in a file hierarchy) to be those of the file referenced by the link, and not the link itself; however, ls shall write the name of the link itself and not the file referenced by the link. When -L is used with -l, write the contents of symbolic links in the long format (see the STDOUT section).
And how can the link be a fast one? From the same linked wiki page:
Inlining
It can make sense to store very small files in the inode itself to save both space (no data block needed) and look-up time (no further disk access needed). This file system feature is called inlining. The strict separation of inode and file data thus can no longer be assumed when using modern file systems.
If the data of a file fits in the space allocated for pointers to the data, this space can conveniently be used. E.g. ext2 stores the data of symlinks (typically file names) in this way, if the data is no more than 60 bytes ("fast symbolic links").
Ext4 has a file system option called inline_data that, when enabled during file system creation, allows ext4 to perform inlining. As an inode's size is limited, this only works for very small files.
It is the above method that I believe the other excellent answer here refers to as the same trick...