ll command outputs as follows
#> ll lrwxrwxrwx ...
How to determine if a soft link's target is a directory or a file from "lrwxrwxrwx"?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
You can use the
-F parameter to ls to get:
-F, --classify append indicator (one of */=>@|) to entries
# ln -s videos Videos # ls -l lrwxrwxrwx. 1 guido guido 6 Jan 23 14:11 videos -> Videos # ls -lF lrwxrwxrwx. 1 guido guido 6 Jan 23 14:11 videos -> Videos/
Anyway, I'd suggest you create symlinks to directories like this:
# ln -s Videos/ videos
in this case, you get the trailing slash even without the classify option.
The output of
ll, which I assume is a shell alias for
ls -l, does not contain this information in the mode/permissions of the symlink. On Linux (symlink(2)):
The permissions of a symbolic link are irrelevant; the ownership is ignored when following the link, but is checked when removal or renam- ing of the link is requested and the link is in a directory with the sticky bit (S_ISVTX) set.
In addition to
ls suggested elsewhere, there are some methods which are less verbose, and lend themselves to scripting.
-L which causes it to follow (dereference) symlinks:
$ file /usr/local/bin/xzcat /usr/local/bin/xzcat: symbolic link to `xz' $ file -L /usr/local/bin/xzcat /usr/local/bin/xzcat: ELF 32-bit LSB executable, [...] $ file /var/adm /var/adm: symbolic link to `log' $ file -L /var/adm /var/adm: directory
-L option is not POSIX but should work on any contemporary Linux and *BSD. It will follow multiple symlinks (which
ls does not). For more robust use it also supports various output formats, e.g.
file -L -b --mime-type /var/adm, and
-0 for zero-delimited filenames.
statis even easier:
$ stat -c %F /var/adm symbolic link $ stat -L -c %F /var/adm directory
-L option works the same as for
-c %F option instructs
stat to output only the type of the file, see the stat(1) man page for more. *BSD
stat is not quite the same as GNU
stat, the format strings are different, use
-f %HT instead.
I think what you want is:
ls -l filename
man is your friend: