A question for links in Unix


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers A question for links in Unix
# 1  
Old 01-13-2006
A question for links in Unix

Is there a command that I can list, at once, all the links(path) of a give file ( including hard link and soft link)? If not, can it be down by writing a script? Thanks a lot.

(I know that pwd would only list one path.)
# 2  
Old 01-14-2006
I can't think of a way to list all the soft links.

To find the hard links, first run ls -li to find out the inode number of the file. Then do a find from the root of the file system (hard links do not cross mount points) for that inode.

Example from a Solaris 10 box:
Code:
> cd /usr/bin
> ls -li zcat
      3262 -r-xr-xr-x   3 root     bin        27176 Jan 22  2005 zcat
> find . -inum 3262
./compress
./uncompress
./zcat
>

In this case /usr/bin is the root file system, so I chose not to run the find from / as it would look in other file systems. The 3 between the file permissions and root means there are 3 links to one file.
# 3  
Old 01-15-2006
Softlink may need to write a script to find out. Thank you very much for the help.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Soft links question

Hello. I have some main directories. For example : /main_dir1 /main_dir2In main_dir2, I have a sub dir named sub_dir2-1 with 2 files in it ( file_2-1, file_2-2 ) /main_dir2sub_dir2-1file_2-1 file_2-2From "/main_dir1/A/B/C" I make a soft link ln -s /main_dir2/sub_dir2-1 ... (6 Replies)
Discussion started by: jcdole
6 Replies

2. UNIX for Dummies Questions & Answers

Symbolic links in UNIX

Hi, I have a file with more than 1 layers of soft links for it. For ex. ls -la .profile .profile@ -> /home/act/.profile_abc ls -la /home/act/.profile_abc@ -> .profile_final I want to get the name of the last file (i.e. .profile_final) when I refer to .profile using shell script. I... (2 Replies)
Discussion started by: deo_kaustubh
2 Replies

3. UNIX for Dummies Questions & Answers

A Basic Question About Links

How can you tell if a file is linked to another file?????? Do not title posts "Urgent", etc. Per forum rules. (3 Replies)
Discussion started by: BIGGDRE10
3 Replies

4. Shell Programming and Scripting

Book and Links about Shells; and zsh question

HI, I would like to ask You about some good books or links where I can find information about shells, theoretical information. I will be grateful if You can help me And I have question about zsh loop trivial script: #!/bin/zsh for i in {1..100000} do echo $i; doneexec time is 10... (9 Replies)
Discussion started by: Physix
9 Replies

5. UNIX for Dummies Questions & Answers

hard links in unix

hi i have a hardlink how can i find the source of it (2 Replies)
Discussion started by: jpriyank
2 Replies

6. UNIX for Dummies Questions & Answers

Collection of Unix Links

Hi, Is there is a good collection of Links to Unix Related stuff? Regards, Kriss (1 Reply)
Discussion started by: Kriss
1 Replies

7. UNIX for Advanced & Expert Users

links in UNIX

Hi Can you please tell me how to create a softlink to a file on a different partition ? thanks (3 Replies)
Discussion started by: infyanurag
3 Replies

8. UNIX for Dummies Questions & Answers

Question posting links

Hi, I do not want to violate any rules, so thought to ask before posting any links. Just to contribute to the forum: through surfing I found a link to download "Unix in a Nutshell" (*.chm) FREE. I was wondering if I can post that link here. Thanks Hemang (5 Replies)
Discussion started by: hemangjani
5 Replies
Login or Register to Ask a Question