I wanted to set gsettings as /usr/bin/gsettings
so I created an alias. But I am not sure if that works:
$ type gsettings
gsettings is aliased to `/usr/bin/gsettings'
gsettings is /home/linuxbrew/.linuxbrew/bin/gsettings
gsettings is /usr/bin/gsettings
$ which gsettings
/home/linuxbrew/.linuxbrew/bin/gsettings
Also another example:
$ type pandoc
pandoc is aliased to `/usr/bin/pandoc'
pandoc is /home/linuxbrew/.linuxbrew/bin/pandoc
pandoc is /usr/bin/pandoc
pandoc is /home/nikhil/.cabal/bin/pandoc
$ which pandoc
/home/linuxbrew/.linuxbrew/bin/pandoc
Question
Can someone please clarify which binary for pandoc and gsettings would get executed when I type
pandoc
andgsettings
on bash?Does the order of output of
type
command has some significance?
Note
$ type type
type is a function
type ()
{
builtin type -a "$@"
}
type is a shell builtin
which
, do you have reason to believe that it's not the one returned bywhich
? – user1794469 Jun 30 '20 at 11:35which
is basically a worsetype
, you don't need it andtype
is always better.which
will only check for executables in yourPATH
, it will ignore the alias, so it is not relevant here. In fact, it is wrong, since it suggests thatpandoc
would run/home/linuxbrew/.linuxbrew/bin/pandoc
, when instead it would run/usr/bin/pandoc
because aliases take precedence. See Why not use "which"? What to use then?? – terdon Jun 30 '20 at 11:39