Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm working on a legacy system and I have a bunch of files that are referencing images that are located in other folders.

lrwxrwxrwx  1 user nobody      56 Feb 10  2010 t100x100.jpg -> /home/www/virtual/categories/swm/24/m/00012/t100x100.jpg
lrwxrwxrwx  1 user nobody      56 Feb 10  2010 t100x133.jpg -> /home/www/virtual/categories/swm/24/m/00012/t100x133.jpg
lrwxrwxrwx  1 user nobody      56 Feb 10  2010 t125x150.jpg -> /home/www/virtual/categories/swm/24/m/00012/t125x150.jpg
lrwxrwxrwx  1 user nobody      56 Feb 10  2010 t150x200.jpg -> /home/www/virtual/categories/swm/24/m/00012/t150x200.jpg

How can I know if these are symbolic links or aliases?

share|improve this question
3  
A symbolic link is a file entry that references another file. In Linux, an alias is a command syntax replacement. What do you mean by an alias? Or are you simply asking how to identify which files are symbolic links? find folder -type l will list all symbolic links below 'folder'. –  StarNamer Jul 29 '12 at 22:49
    
Are you asking about aliases in Mac OS X Finder, or shell command aliases? –  Daniel Beck Jul 29 '12 at 23:55
    
I guess I was a bit confused. The files in question were just symbolic link and I guess I was confusing with Os X Finder aliases. –  Martin Jul 30 '12 at 0:14
add comment

2 Answers

up vote 9 down vote accepted

Symbolic links:

lrwxrwxrwx  1 user nobody      56 Feb 10  2010 t100x100.jpg -> /home/www/virtual/categories/swm/24/m/00012/t100x100.jpg
^
 ` Here it is, l for symbolic link.

If you files are hard links then they show up just as other files. For example every directory has directory named . hardlinked to it.

From $ man find:

Each directory on a normal Unix filesystem has at least 2 hard links: its name and its .' entry. Additionally, its subdirectories (if any) each have a..' entry linked to that directory.

Hard links:

-rw-r--r--  3 root root   60 2012-06-25 12:17 File
-rw-r--r--  3 root root   60 2012-06-25 12:17 HardLinkToFile
-rw-r--r--  3 root root   60 2012-06-25 12:17 HardLinkToFile2
lrwxrwxrwx  1 user nobody      56 Feb 10  2010 t100x100.jpg -> /home/www/virtual/categories/swm/24/m/00012/t100x100.jpg
            ^
             ` This number is hard link (reference) count.
share|improve this answer
add comment

The file or stat commands will tell you what a file is:

$ ln -s /home this_is_a_link
$ touch this_is_not_a_link
$ file this_*
this_is_a_link:     symbolic link to `/home'
this_is_not_a_link: empty
$ stat this_*
  File: `this_is_a_link' -> `/home'
  Size: 5               Blocks: 0          IO Block: 4096   symbolic link
Device: ca00h/51712d    Inode: 106983      Links: 1
Access: (0777/lrwxrwxrwx)  Uid: ( 1000/    andy)   Gid: ( 1000/    andy)
Access: 2012-07-29 23:28:17.000000000 +0000
Modify: 2012-07-29 23:28:17.000000000 +0000
Change: 2012-07-29 23:28:17.000000000 +0000
  File: `this_is_not_a_link'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: ca00h/51712d    Inode: 106992      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/    andy)   Gid: ( 1000/    andy)
Access: 2012-07-29 23:28:27.000000000 +0000
Modify: 2012-07-29 23:28:27.000000000 +0000
Change: 2012-07-29 23:28:27.000000000 +0000

If scripting, the test command may be of more use:

   -h FILE
         FILE exists and is a symbolic link (same as -L)
$ for f in this_*; do if test -h "$f"; then echo "$f is a symlink"; else echo "$f is not a symlink"; fi; done
this_is_a_link is a symlink
this_is_not_a_link is not a symlink
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.