New hard y soft

Hard Link vs Soft Link
December 12, 2015 – 11:39 am
Hardy used, like new

Once again, one of the very basic question asked in the interviews, What is the difference between Hard links and Soft links. You can explain few basic things, but emphasizing on internals about the linux filesystem, is something which can impress the interviewer.

What is a Soft Link or Symbolic Link or Symlink ?

Symbolic links or Symlinks are the easiest to understand, because for sure you have used them, at least when you were using Windows. Soft links are very similar to what we say “Shortcut” in windows, is a way to link to a file or directory. Symlinks doesn’t contain any information about the destination file or contents of the file, instead of that, it simply contains the pointer to the location of the destination file. In more technical words, in soft link, a new file is created with a new inode, which have the pointer to the inode location of the original file. This can be better explained with a diagram:

Soft Links on Linux

Symbolic links are created with the “ln” command in linux. The syntax of the command is:

$ ln -s
-s = This flag tells to create a symlink (if you don’t use this it will create a hard link, which we will talk about soon).

For Example, if you want to create a soft link of one fo your favorite application, like gedit, on your desktop, use the command like this:

$ ln -s /usr/bin/gedit ~/Desktop/gedit

I hope now the concept of Soft Links should be clear.

What is a Hard Link ?

Hard link is a bit different object when compared to a symlink. In softlink a new file and a new Inode is created, but in hard link, only an entry into directory structure is created for the file, but it points to the inode location of the original file. Which means there is no new inode creation in the hard link. This can be explained like this:

So, in hard link, you are referencing the inode directly on the disk, which means that there should be a way to know how many hard links exist to a file. For the same, in the inode information, you have an option for “links”, which will tell how many links exists to a file. You can find the same information by using this command:

$ stat

$ stat 01
Size: 923383 Blocks: 1816 IO Block: 4096 regular file
Device: 803h/2051d Inode: 12684895 Links: 3
Access: (0644/-rw-r–r–) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2012-09-07 01:00000 -0500
Modify: 2012-04-27 06:00000 -0500
Change: 2012-04-27 06:00000 -0500

In this example, it means that the specific file have 2 hard links, which makes the count to 3.

You can create a hard link with the same command “ln” like this

# ln

So, to create a hard link of gedit program on your desktop, you will use the command like this:

# ln /usr/bin/gedit ~/Desktop/gedit

Now, the bigger question is, who will decide what is better and when to use soft link or hard link

When to use Soft Link:

  1. Link across filesystems: If you want to link files across the filesystems, you can only use symlinks/soft links.
  2. Links to directory: If you want to link directories, then you must be using Soft links, as you can’t create a hard link to a directory.
Source: www.geekride.com
You might also like
Do you like it soft or hard?
Do you like it soft or hard?
2013 NEW COLOR Harley-Davidson FLSTN Softail Deluxe Hard
2013 NEW COLOR Harley-Davidson FLSTN Softail Deluxe Hard ...
G Flex 2 Phone Case, Bastex Heavy Duty Hybrid Kickstand Holster Case - Soft Blue Silicone Cover Hard Black Kickstand Holster Case for LG G Flex 2**INCLUDES STYLUS**
Wireless (Bastex)
  • Protect your phone with this stylish premium high-quality case.
  • This high-quality case is thick and durable for optimal protection.
  • Protects the phone from scratches and dust.
  • Color designed to give your phone a unique style. Free BASTEX Cleaning Cloth
  • Gives complete access to all functions of the phone.
HTC Desire - Cellularvilla Hard Soft Dual Layer Hybrid Armor Shell Holster Kickstand Combo Case with Locking Belt Swivel Clip Cover for HTC Desire 510 (Yellow Black)
Wireless (Cellularvilla)
  • Durable thick inner layer of silicone for extra protection, shock absorption, and grip.
  • Case has precise openings for all buttons, camera, charging and music funtions.
  • Extremely heavy duty outer hard shell for added durability.
  • 3-in-1 complete protective set, includes: belt holster, case, and a kickstand.
  • It Only Fit On HTC Desire 510.
CoverON® CoverON® HYBRID Dual Heavy Duty RED RUBBERIZED Hard Case and Soft BLACK TPU Skin Cover for HUAWEI M866 ASCEND Y US CELLULAR [WCC894]
Wireless (CoverON®)
  • Personalize the look of your phone with this case. Custom made with the highest quality material to fit your phone.
  • Designed to offer all-around external surface protection. This case will not add much extra weight or bulk to your phone.
  • Smart design, gives you total access to all functionality and buttons. Plug your charger and/or hands free without removing the case.
  • No tools or instructions needed to install; just snap on/off.
  • CoverON(TM) Offers Fast Shipping Within 24Hrs and 90 day warranty. No questions. Return it for exchange or refund.
For ZTE Valet Z665C Fury N850 Director N850L - Wydan Trapezoid Y-Stand Hybrid Hard Soft Gel Case Cover-Black on Blue w/ Wydan Stylus Pen, Prying Tool and Car Charger
Wireless (Wydan)
  • Our premium hard cases provides your wireless device the maximum protection against scratches and scuffs, enabling you to keep your wireless device in new condition...
  • All openings are precisely cut to allow full access to all the wireless device functions - the dock connector, charger, side buttons, speaker, microphone and camera.
  • It is user-friendly, and super easy to install.
  • Wydan stylus pen and prying tool is included.
  • Car charger is included for those instances you need a quick charge on the go.
Moto X - Cellularvilla Hard Soft Dual Layer Hybrid Armor Holster Kickstand Case with Locking Belt Swivel Clip Cover for Motorola Moto X XT1058 XT1060 XT1055 XT1056 XT1053 (Verizon) (Yellow Black)
Wireless (Cellularvilla)
  • Durable thick inner layer of silicone for extra protection, shock absorption, and grip.
  • Extremely heavy duty outer hard shell for added durability.
  • Case has precise openings for all buttons, camera, charging and music funtions.
  • 3-in-1 complete protective set, includes: belt holster, case, and a kickstand
  • Rubberized texture for firm, non-slip grip case
Popular Q&A
avatar
How do we know which vowels are hard and which ones are soft when we come across new words? | Yahoo Answers

You're right about names. Many of them with foreign origins do not follow normal rules of pronunciation.
This is not a regional issue. The problem with English is that it borrows many words from many different languages, and often keeps the original spelling. The other problem was that when Noah Webster wrote America's first real dictionary, he decided that words' spellings should be related to their origins, in addition to their pronunciations.
There's kind of a rule for the vowels. The long vowels (hard?) usually have another silent vowel close by. Examples: cake, jeans, mile, Coke,…

Related Posts