- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: how to find if a file or directory is linked
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-04-2005 04:05 AM
тАО07-04-2005 04:05 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-04-2005 05:28 AM
тАО07-04-2005 05:28 AM
Re: how to find if a file or directory is linked
find . -type l -exec ll {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-04-2005 07:43 AM
тАО07-04-2005 07:43 AM
SolutionBasically there are two types of links - hard link and soft link.
1) When you create hard link an inode will be assigned to the new name (link name you have created) linking to the original file.This can be observed in the ls -l filename output where you will see the number of links to the file ( Mind you these are the hard links). If you do a ls -il for both the files - you will see different inode numbers. Thus when you have ahrd links you can just know how many links are there to that file but you cant know which are the links
2) When you create a soft link - only a directory entry is made pointing to the file to which the link is made - thus no separate inode is assigned.Thus if you do a ls -l to the link you will see that it is showing as pointing to some file - e.g. -> /xyz/filename
Hope this helps.
Nad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-04-2005 04:00 PM
тАО07-04-2005 04:00 PM
Re: how to find if a file or directory is linked
If the entry shows greater than 1 then the file has links.
One thing to keep in mind, by default a directory has 2 links.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-04-2005 07:11 PM
тАО07-04-2005 07:11 PM
Re: how to find if a file or directory is linked
Now to answer your question there is no perfect way to find the if there is any soft link pointing "to" a file. For hardlinks you can get the count of hardlinks by using 'll' command. The second column is what tells that. But once again, there is no way to get the list of all files/directories hard linked with it.
-Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-04-2005 07:46 PM
тАО07-04-2005 07:46 PM
Re: how to find if a file or directory is linked
1) file -h
2) ls -l
we can use inode filed (field 2) which displayed on executing ls -l.
# Soft Link
# ls -l /tmp/file2
lrwxrwxrwx 1 root sys 10 Jul 5 01:43 /tmp/file2 -> /tmp/file1
number of links count=1
# Hard Link
# ls -l /tmp/file2
-rw-rw-rw- 2 root sys 0 Jul 5 01:43 /tmp/file2
number of links count=2
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-04-2005 10:13 PM
тАО07-04-2005 10:13 PM
Re: how to find if a file or directory is linked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-04-2005 10:21 PM
тАО07-04-2005 10:21 PM
Re: how to find if a file or directory is linked
I am not sure why you are saying that "you are unable to find soft link with ln -s or file -h command"
hth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2005 05:30 AM
тАО07-06-2005 05:30 AM
Re: how to find if a file or directory is linked
cd $HOME
touch fsm.list
cd /var/temp
ln -s $HOME/fsm.list fixit
Now, can he look at fsm.list in $HOME and determine the /var/temp/fixit exists.
The only thing I can think of that might help is:
cd
find . -type l -exec ls -l {}\; > somefile
then examine "somefile" to see if it contains references to the files he wants to delete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2005 02:09 PM
тАО07-06-2005 02:09 PM
Re: how to find if a file or directory is linked
A softlink is unique in that it doesn't maintain any connection with the target. Move the target and the softlink now reports that it isn't found. A softlink can contain anything, not just a filename, partial path or fulpath.
Bill Hassell, sysadmin