2. Some commands about commands
-
The command
type
displays a command's type:type type
type ls
type cp
The command
cp
is an executable program located on/usr/bin/cp
. -
The command
which
displays the location of an executable:which ls
which cd
The command
cd
is not an executable but a shell builtin command.type cd
-
The command
help
displays a help page for the shell builtin commands:help cd
help mkdir
The command
mkdir
is not a shell builtin. -
The option
--help
displays usage information:mkdir --help
-
The command
man
displays the manual page of a program:man ls
Manual pages are organized into different sections, where section 1 for example is about user commands, and section 5 is about file formats. So, these two commands will display different manual pages:
man passwd
man 5 passwd
-
The command
info
is another way to display manual pages:info coreutils
info passwd
-
The command
apropos
displays appropriate commands:apropos passwd
This is the same as:
man -k passwd
It makes a simple search on man pages for the term "passwd".
-
The command
whatis
displays a very brief description of a command:whatis ls
-
The command
alias
is used to create new commands.alias --help
alias
type alias
type ls
cd /usr; ls; cd -
type foo
alias foo="cd /usr; ls; cd -"
type foo
foo
unalias foo
type foo