Working with Commands
commands can be one of four different things:
- an executable program.
- a command built into the shell itself.
- a shell function.
- an alias.
type
display a command’s type,command is the name that you want to examine.
type command
which
dispaly an executable’s location.Only works for executable program,not builtins and aliases
which ls
#will show /bin/ls
which cd
#cd is a shell builtin command,can't use which
what is
display the name and one line description of a man page matching a specified keyword.
whatis ls
#will show "ls (1) - list directory contents"
alias
Using the alias command,we can create our own command.
alias foo='cd /usr;ls -alh;cd -'
then you can use the foo command,it’s function is to change the directory to /usr,then ls and return to the previous directory.
Also,you can remove the alias command using unalias command:
unalias foo