What does ‘l’ in file metadata mean

ls

When we type ls -l, we get meta data regarding all the objects in the current directory.

The meta data has 10 dashes and the 1st dash indicates if the object is a directory or file or a link

Screenshot

d indicates that the object is a directory like a folder

- indicates that the object is a file etc : .cpp, .png, .jpeg

l indicates that the object is a link

What exactly does it mean when a object is a link, how do you create a object that is a link?

Best Answer

The l you're referencing means the file is a link (symbolic) to another file (or directory).

Example

lrwxrwxrwx.   1 root root   22 Feb 24 17:36 jcmd -> /etc/alternatives/jcmd
lrwxrwxrwx.   1 root root   23 Feb 24 17:36 javap -> /etc/alternatives/javap
lrwxrwxrwx.   1 root root   23 Feb 24 17:36 javah -> /etc/alternatives/javah

These were created with a command, ln -s source link. The source is the file/directory we want to link to, the "link" is the name we want to give the link.

making a link

$ ln -s ~/winfile.txt a_link.txt

confirming

$ ls -l | grep winfile
lrwxrwxrwx.   1 saml saml   22 Mar  5 11:15 a_link.txt -> /home/saml/winfile.txt
-rw-rw-r--.   1 saml saml   41 Mar  5 07:44 winfile.txt

Further details

If you consult the info ls info page you'll find descriptions of all the symbols used in the output of ls.

excerpt

 The file type is one of the following characters:

 '-'          regular file
 'b'          block special file
 'c'          character special file
 'C'          high performance ("contiguous data") file
 'd'          directory
 'D'          door (Solaris 2.5 and up)
 'l'          symbolic link
 'M'          off-line ("migrated") file (Cray DMF)
 'n'          network special file (HP-UX)
 'p'          FIFO (named pipe)
 'P'          port (Solaris 10 and up)
 's'          socket
 '?'          some other file type

References

10.1.2 What information is listed - coreutils documentation on ls

Related Question