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

What is the cost of linux course and how much do the certification cost?
1000 for basic and 2000 for linux advance, for certification, give exam, clear it and you are certified
Anusha
What is /dev/null in Unix?
/dev/null is the null file Is is a special file which contains nothing.
Furqankhan
0 0
6
Hi my name is Raja i have 8 Years Expnt in Desktop Support i Need to change my Platform From linux basic are Network Base Work
Hi Raja, As you said, you already have some experience on desktop support, so better choose Linux Administration. First learn basic level of Linux Administration from any institute, then go to real time...
Rajasubramanian

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

Ask a Question

Related Lessons

Be prepared to get trained--init
Before starting the training,students must be mentally prepared for acceptance of new knowledge. Students must attend training with open minded forgetting the position they are working.This will help...
S

Smartnub Softsolutions

0 0
0

LINUX SERVER ADMINISTRATION
Permissions in Linux rwx|rwx|rwx =user | group | others R==4 W==2 X==1 what's the total? 421|421|421 777 So 7 has 4, 2,1==which means full. Permission (that is read write and execute) ...

Introduction to Programming Languages
What is a Programming Language? A programming language is a formal computer language or constructed language designed to communicate instructions to a machine, particularly a computer. Programming languages...

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...

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...

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