- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- differ hard link and soft link
Operating System - HP-UX
1753974
Members
6993
Online
108811
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-12-2011 03:48 AM
тАО05-12-2011 03:48 AM
differ hard link and soft link
differ hard link and soft link , how to create links.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-12-2011 04:58 AM
тАО05-12-2011 04:58 AM
Re: differ hard link and soft link
The "ln" command can be used to create links. It works like "cp" but creates a link instead of a copy.
"ln " creates a hard link.
"ln -s " creates a soft link.
Hard links work only within a single filesystem: you cannot make a hard link point from one filesystem to another filesystem.
A hard link is indistinguishable from the original file: the same content can be accessed using both filenames. If you have some data in "file-a" and hard-link it as "file-b", and then delete "file-a", the data will still exist as "file-b".
echo "*some data*" > file-a
ln file-a file-b
rm file-a
cat file-b
*some data*
A soft link is just a pointer, telling the system "look at this other file instead". A soft link can point to a different (mounted) filesystem. If you delete the original file that is the target of a soft link, the data will be lost.
echo "*some data*" > file-c
ln file-c file-d
rm file-c
cat file-d
cat: file-d: No such file or directory
ls -l file-d
lrwxrwxrwx 1 user group 6 May 12 15:51 file-d -> file-c
"file-d" exists, but because it's a soft link that points to a non-existent "file-c", the error message says the file does not exist. (This is called a "dangling link".)
If someone later creates "file-c" again, the soft link will start working again.
MK
"ln
"ln -s
Hard links work only within a single filesystem: you cannot make a hard link point from one filesystem to another filesystem.
A hard link is indistinguishable from the original file: the same content can be accessed using both filenames. If you have some data in "file-a" and hard-link it as "file-b", and then delete "file-a", the data will still exist as "file-b".
echo "*some data*" > file-a
ln file-a file-b
rm file-a
cat file-b
*some data*
A soft link is just a pointer, telling the system "look at this other file instead". A soft link can point to a different (mounted) filesystem. If you delete the original file that is the target of a soft link, the data will be lost.
echo "*some data*" > file-c
ln file-c file-d
rm file-c
cat file-d
cat: file-d: No such file or directory
ls -l file-d
lrwxrwxrwx 1 user group 6 May 12 15:51 file-d -> file-c
"file-d" exists, but because it's a soft link that points to a non-existent "file-c", the error message says the file does not exist. (This is called a "dangling link".)
If someone later creates "file-c" again, the soft link will start working again.
MK
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-12-2011 05:04 AM
тАО05-12-2011 05:04 AM
Re: differ hard link and soft link
nice explanation Matti. however, I found a typo, a soft link is made with the "-s" option:
instead this:
> ln file-c file-d
here is the correct one:
ln -s file-c file-d
instead this:
> ln file-c file-d
here is the correct one:
ln -s file-c file-d
****
Unix operates with beer.
Unix operates with beer.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP