I'm trying to figure out how to list the contents of a directory using a symbolic link to that directory.

I read the answers here - Show contents of symbolic link

The problem I'm having is just that when I trying using /, I end up getting the following:

[ ~]$ ln -s /dir2/dir3 link3
[ ~]$ ls -l link3/
ls: cannot access link3/: No such file or directory

The link is there, though:

[ ~]$ ls -F link3
  • Is the target of the link there? (i.e. /dir2/dir3) – Kusalananda Oct 21 '19 at 20:48
  • Yeah, $ ls dir2/dir3 temp5 It only has the file temp5, and link3 I just created in a fresh directory – Austin Oct 21 '19 at 20:50
  • Is /dir2/dir3 a file or directory? Because if it's a file you can't put the / at the end. – slybloty Oct 21 '19 at 20:51
  • dir2/dir3 is a directory with file temp5 under it – Austin Oct 21 '19 at 20:52
  • 2
    @Austin, note carefully the questions from Kusalananda and slybloty, they asked about /dir2/dir3 but you answered about dir2/dir3, no leading slash. What does ls link3/. show you? – icarus Oct 21 '19 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.