found ls binary using whereis but can't find ll why?
found ls binary using whereis but can't find ll why ? How to find where ll binary loacted ?
I found "ls" binary using "whereis" but can't find "ll"
$ whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz
But can't find ll :
$ whereis ll
ll:
Solution 1:
ll
is not a binary but an alias of the ls -alF
command.
Check the .bashrc
file :
$ alias ll
alias ll='ls -alF'
Solution 2:
As noted by kos in the comments, you should use the bash built-in type
command which, unlike whereis
, is also aware of aliases and shell built-ins:
$ type ll ls cd
ll is aliased to `ls -alF'
ls is hashed (/bin/ls)
cd is a shell builtin
(For the meaning of "hashed", see this question on unix.SE.)
Solution 3:
Many users like short cuts and this is what an alias is, a shortcut option for users.
Scripts should not use shortcuts, that is not a portable design, as you found out, these alias commands are not consistently defined.
Easiest answer to meet your need, assuming the use of 'll' is repeated:
Within the script, define the alias ll='ls -l', before referencing the command, then the use of 'll' will work throughout this script.
#!/bin/bash
alias ll='ls -alF'
... (rest of the script)
Better Answer: better to use the full command in the script, provides documentation. Never use an alias in a script that others have to use.