Move softlinkA into dir1 and verify using ls. (Check if the link is still valid)

1 min read
Step 1: Move softlinkA
into dir1
bashCopyEditmv softlinkA ~/dir1/
Step 2: Verify the Move
bashCopyEditls -l ~/dir1/
Expected Output:
sqlCopyEditlrwxrwxrwx 1 user user 6 Mar 29 12:34 softlinkA -> fileA
Step 3: Check if softlinkA
is Still Valid
bashCopyEditcat ~/dir1/softlinkA
Possible Outcomes:
If
fileA
exists in the original location:- The soft link works fine and displays the content of
fileA
.
- The soft link works fine and displays the content of
If
fileA
was deleted earlier:The soft link is broken and gives an error:
yamlCopyEditcat: softlinkA: No such file or directory
This happens because soft links store relative/absolute paths, and moving them doesn’t change the target path.
How to Fix a Broken Soft Link?
If fileA
was deleted or moved, recreate it or update the link:
bashCopyEditln -sf /correct/path/to/fileA ~/dir1/softlinkA
0
Subscribe to my newsletter
Read articles from Ravi Vishwakarma directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
