I'm not quite clear if you're asking about:
- aliases (a way of making one command actually run something else)
- symlink (a way of making a shortcut to a file)
- hard link (two file names both pointing to the same file contents)
The command you were trying:
if [ -h /path/to/file ]
helps you figure out if a file is a symlink or not, e.g.:
$ touch newfile
$ ln -s newfile newlink
$ for f in newfile newlink; do
if [ -h "$f" ]; then
echo "$f is a symlink"
else
echo "$f is not a symlink"
fi
done
newfile is not a symlink
newlink is a symlink
If you mean: "how can I find out whether typing some command will run an alias", then you can use type
or alias
, e.g.
$ type ls
ls is aliased to `ls --color=auto --format=across'
$ type less
less is /usr/bin/less
If you're asking about hard links, find -inum
and ls -i
can help, but that is a more advanced topic.