Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
4  
If you're coming from the Windows world, links are the equivalents of Windows shortcut files. –  terdon Mar 5 at 16:17
2  
@terdon iirc, Windows shortcuts are different from symlinks. Shortcuts are actually files. Also, NTFS has "real" symlinks and also directory junctions, but they are different from shortcuts. You can observe the differences if you mount an NTFS partition in Linux. –  Alvin Wong Mar 6 at 9:00
add comment

3 Answers 3

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

share|improve this answer
add comment

a symbolic link is a reference to another file. you create it with the ln command:

ln -s /some/file mylink
share|improve this answer
add comment

l indicates that the object is a symbolic link. This is simply a pointer to some other object, which may or may not exist. Attempts to access the link will result in the object being pointed to being accessed instead. The object could be anything: a file, directory or special file will all work.

For example, in your root directory you may well have this:

lrwxrwxrwx 1 root root 27 Sep 12  2012 /vmlinuz -> boot/vmlinuz-2.6.32-5-amd64

This means that, when /vmlinuz is accessed, the file being pointed to is read instead. If that file doesn't exist, the operation will fail.

To create a symbolic link, use the command

ln -s source-file link-file

This will create a link that looks like

link-file -> source-file

Note that this is distinct from a hard link, created by omitting the -s option. A hard link creates a filesystem pointer to the same inode as that used by the source object, and can't point to an object on a different filesystem.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.