UrbanPro

Learn Linux from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

How can directories have hard-links in Linux?

Asked by Last Modified  

1 Answer

Learn Linux

Follow 0
Answer

Please enter your answer

Hello Shagufta :-). Hard links are created with the ln command. For example, the following would create a hard link named hlink1 to a file named file1, both in the current directory (i.e., the directory in which the user is currently working): ln file1 hlink1 When a hard link is created, there...
read more
Hello Shagufta :-). Hard links are created with the ln command. For example, the following would create a hard link named hlink1 to a file named file1, both in the current directory (i.e., the directory in which the user is currently working): ln file1 hlink1 When a hard link is created, there is no obvious indication that it is any different from any other file. That is, hard links appear to be files of the same type as their target files (i.e., the files to which they are linked) when they are viewed with commands such as ls (i.e., list) and file (which is used to determine the type of any specified files). Likewise, when viewed in a GUI (graphical user interface), the icons for hard links are identical to those for their target files. That the initial name of a file and all hard links to that file all share the same inode can be clearly seen by using the ls command with its -i (i.e., inode) option. Thus, for example, the following would show that the inode numbers of file1 and hlink1 from the above example are identical: ls -i file1 hlink1 The number of hard links to any file is shown in the second column of output produced by using ls with its -l (i.e., long) option. It can be seen that the number is the sum of the target file and any hard links to it (i.e., the sum of the initial name and any subsequently added names) and that it is the same for the target and for each such link. Hard linked files can also be found by using the find command with its -type f option (to select only regular files) followed by its -links +1 option (to show all regular files with more than one hard link to them) as follows: find -type f -links +1 When a change is made to the contents of a file, the linkage to all of the hard links is preserved. However, some text editors may break the link by creating a new inode for the revised contents,1 and thus it can be prudent to check important links after modifying files. The rm command superficially appears to remove or delete files. What it really does, however, is to reduce a file's hard link count (i.e., the number of names the file has) by one, and it does not directly affect the inode or the file's data. When the count reaches zero, the file appears to have vanished because there is no longer any easy way to reference it. However, the file's data is only truly deleted when the location(s) on the hard disk drive (HDD) or other storage media that contains it is overwritten by a new file. Thus, for example, the following would remove the hard link hlink1 that was created in the above example: rm hlink1 Using rm again with the one remaining name as follows would then make the file's data virtually inaccessible: rm file1 Perhaps the most useful application for hard links is to allow files, programs and scripts (i.e. short programs) to be easily accessed in a different directory from the original file or executable file (i.e., the ready-to-run version of a program). Typing the name of the hard link will cause the program or script to be executed in the same way as using its original name. Symbolic links, also called soft links, are more useful than hard links because they can be made to directories as well as to files on different filesystems and on different partitions. Moreover, when using a GUI, symbolic links have special icons that immediately identify them as being links rather than ordinary files. However, they have the disadvantage that they become unusable if their target file is deleted. Aliases superficially resemble hard links in that they are another way of providing multiple names for any file. However, the alias command is built into the shell (i.e., the program that provides the text-only user interface) rather than being a separate program and the mechanism is very different from that of hard links. Like symbolic links, aliases can be used not only for files but also for directories and can cross filesystem and partition boundaries. In addition, an alias can be used as a short name for any shell text (i.e., a command or series of linked commands, inclusive of tbeir options and/or arguments). Thanking you, Ngcc Software Technologies Staff. read less
Comments

Related Questions

I am having 5+ years exp in civil engineering now I am thinking to move in IT sector can u suggest me which field is better to learn ? I am thinking to do Linux+devops+aws or powerBi 

Hi Waseem, I am a Devops and cloud engineed since last approximatelt 4 years.Linux,DevOps (techniques and tools) and Cloud, all are very much intera-related. DevOps and Cloud both are burning needs in...
Waseem

I am working as Tech support executive with windows and Linux total of 4 years of experience , Not getting enough calls / opportunities ... Which domain is good for change Sap basis consultant / any other suggestions are welcome

Learn Cloud Computing(Microsoft Azure,AWS,Google Cloud) or Devops. Make your career in this field. Your previous experience will use in this field.
Vamshi
What is openstack ?
OpenStack is open source platform for building and managing cloud computing platforms for public and private clouds in a cloud computing environment.
Vivek

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

How To Start Shell Scripting?
Hi learners, I would like to share my knowledge in shell scripting: Every new Linux learners goal is to learn shell scripting. But only a few starts quickly writing the shell scripts.Why? The reasons...

UNDERSTANDING PROCESSES - RED HAT ENTERPRISE LINUX
What is a Process An instance of a program is called a Process. Any command that you give to your Linux machine starts a new process. It is possible that for the same program we have multiple processes. Types...
A

Aseem .

1 0
0

How to detect duplicate address manually in a network from Linux ?
Below script will help you to detect duplicate IP address in a subnet The key command is the arping command which will send out an ARP packet with DAD (duplicate address detection) If the return...

LINUX - SETTING UP YUM REPOSITORY
If we buy RHEL 7 the system by default will be connected to Red Hat Network (RHN). All packages and updates will be installed from RHN. So RHN will be our main source and repository. Since we have...
A

Aseem .

1 0
0

Linux File System
Linux File system: Right click on Desktop and click open interminal Login to Linux system and run simple commands: Check present Working Directory: $pwd /home/cloudera/Desktop Change Directory: $cd...

Recommended Articles

Whether it was the Internet Era of 90s or the Big Data Era of today, Information Technology (IT) has given birth to several lucrative career options for many. Though there will not be a “significant" increase in demand for IT professionals in 2014 as compared to 2013, a “steady” demand for IT professionals is rest assured...

Read full article >

Applications engineering is a hot trend in the current IT market.  An applications engineer is responsible for designing and application of technology products relating to various aspects of computing. To accomplish this, he/she has to work collaboratively with the company’s manufacturing, marketing, sales, and customer...

Read full article >

Microsoft Excel is an electronic spreadsheet tool which is commonly used for financial and statistical data processing. It has been developed by Microsoft and forms a major component of the widely used Microsoft Office. From individual users to the top IT companies, Excel is used worldwide. Excel is one of the most important...

Read full article >

Hadoop is a framework which has been developed for organizing and analysing big chunks of data for a business. Suppose you have a file larger than your system’s storage capacity and you can’t store it. Hadoop helps in storing bigger files than what could be stored on one particular server. You can therefore store very,...

Read full article >

Looking for Linux Training?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Linux Classes?

The best tutors for Linux Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Linux with the Best Tutors

The best Tutors for Linux Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more