How do I see if a file has a soft link or a hard-link file under Linux?

Source: Internet
Author: User

problem 1 : I created a hard-link file, but I don't know where it is, how do I do it?

Ideas:

    • Find files can take advantage of the Find command.

    • hard-link features do not cross the file system, so the source file is in which filesystem, right there.

    • hard-link files and source files have the same inode #, you can use the find -inum parameters and -samefile parameter means according to Inode The first thing to look for is to see the file's inode

    • -samefile" parameter means finding the same inode inode of a file

[[email protected] oldboy]# stat oldboy.txt  //Gets the inode number of the file   file: ' Oldboy.txt '   Size:55               Blocks: 8          IO Block: 4096    regular filedevice: 803h/2051d      inode: 148677       Links: 2Access:  (0644/-rw-r--r--)   Uid:  (    0/    root)    Gid:  (   0/     root) access: 2016-04-17 15:32:13.861206307 +0800modify: 2016-04-17  14:20:13.246213893 +0800change: 2016-04-17 16:04:17.023206128 +0800[[email protected]  oldboy]# find / -inum 1486772>/dev/null //based on inode number lookup, discard the error hint/usr/local/ Xiaoming/data/oldboy/oldboy.txt[[email protected] oldboy]# 

problem 2 : I have a file N Create a soft connection file, but I do not know where to put, and do not know what name, how to do?

Ideas:

    • soft links can cross file systems, and inode, attributes are different from the source file no rules can be found

    • ls–l When you view a linked file, it will: FileName---Link Filename way display.

    • We look for all the link files in the current system and then filter the source file name we're looking for n

[Email protected] oldboy]# Find-type l-exec ls-l {} \; lrwxrwxrwx 1 root root 1 Apr 16:21 ./xiaohong-> 1lrwxrwxrwx 1 root root ten Apr 16:16./oldgirl.txt-oldboy.tx T[[email protected] oldboy]#//Find file, long format display, then filter source file name [[email protected] oldboy]# Find-type l-exec ls-l {}\;| grep ' old Boy.txt ' lrwxrwxrwx 1 root root, Apr 16:16./oldgirl.txt-Oldboy.txt


This article is from the "Your Night" blog, be sure to keep this source http://lixin15.blog.51cto.com/3845983/1764780

How do I see if a file has a soft link or a hard-link file under Linux?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.