LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-24-2015, 08:20 AM   #1
arun natarajan
Member
 
Registered: Jun 2014
Posts: 108

Rep: Reputation: Disabled
how to view only hard links


Hi All,

Is there any command or shell scripting to view only the link files under / .
 
Old 02-24-2015, 08:50 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,895

Rep: Reputation: 2921Reputation: 2921Reputation: 2921Reputation: 2921Reputation: 2921Reputation: 2921Reputation: 2921Reputation: 2921Reputation: 2921Reputation: 2921Reputation: 2921
what do you mean by that?
when you execute ls -l you will see something like this:
Code:
eporand@elxj3lld12-mf:/tmp/a$ ls -la
total 0
drwxr-xr-x  2 user group 140 Feb 24 14:46 .
drwxrwxrwt 17 root    root      580 Feb 24 14:45 ..
-rw-r--r--  3 user group   0 Feb 24 14:46 asdf
-rw-r--r--  3 user group   0 Feb 24 14:46 asdf1
-rw-r--r--  1 user group   0 Feb 24 14:46 asdf2
-rw-r--r--  3 user group   0 Feb 24 14:46 asdf3
-rw-r--r--  1 user group   0 Feb 24 14:46 asdf4
at the hardlinked files you will see the number of hard links.
also you can check the man page of find (see -links)
 
1 members found this post helpful.
Old 02-24-2015, 11:11 AM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,322

Rep: Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470
Quote:
Originally Posted by arun natarajan View Post
Hi All,
Is there any command or shell scripting to view only the link files under / .
As suggested, you can read the man page on the find command, and also read the man page on the ls command. BOTH have ample documentation to let you do what you're after. And if you want to write a shell script to do this, that's certainly something that can be done.
 
Old 02-24-2015, 11:25 AM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,561

Rep: Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127
Every file/dir that's not a sym link is a hard link. So a simple inverse sym link search would return everything that is not a sym link, and is therefore a hard link.

Last edited by suicidaleggroll; 02-24-2015 at 11:28 AM.
 
Old 02-24-2015, 12:59 PM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,619

Rep: Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577
Quote:
Originally Posted by suicidaleggroll View Post
Every file/dir that's not a sym link is a hard link.
And for that matter, every symlink has at least one hard link, i.e., the directory entry that points to the inode that contains the symlink. The only things in the filesystem that do not have a hard link are deleted files that are held open by some process and will be removed as soon as they are closed.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hard links and soft links - the esoteric details tekra Linux - General 2 10-09-2014 02:15 AM
Choosing between soft links and hard links. tekra Linux - General 6 01-03-2013 08:36 PM
technical question about hard links v soft links 7stud Linux - Newbie 2 02-23-2007 07:57 PM
links (hard links and soft links..) sachitha Programming 1 08-10-2005 01:10 PM
How To View Links Using RealPlayer zensufi Linux - Software 5 07-29-2004 06:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration