Untile now, we have seen some basic Linux commands, and each of them has own options and arguments. In this blog, we will thoroughly understand those commands by some other commands, and even we could create own commands.
- what are commands exactly?
1.1. An executable program
1.2. An command built into the shell itself
1.3. A shell funtion
1.4. An alias
- Identifying commands : “type”
It is often useful to know exactly which of the four kinds of commands is being used .
e.g.
- Display the location of an executable program : “which”
Sometimes there is more than one version of an executable program installed on a system. To determine the exact location of a given executable , the which command is used.
e.g.
- Getting a command’s documentation : “help”, “–hep”, “man”
4.1. bash has a built-in help facility available for each of the shell builtins. To use it, type “help” followed by the name of shell builtin.
e.g.
4.2. Many executable programs support a “–help” option that displays a description of the command’s supported syntax and options.
4.3. Most executable programs intended for command line use provide a formal piece of documentation called a manual or man page. A special paging program call "man " is used to view them.
e.g.
tips: The “manual” that man displays is broken into sections and not only covers user commands but also system administration commands, programming interfaces, file formats and more.
The table below describes the layout of the manual:
e.g.
- Display appropriate commands : “apropos”
It is also possible to search the list of man pages for possible matches based on a search term. It’s very crude but sometimes helpful.
e.g.
- Display a very brief description of a command : “whatis”
The “whatis” program displays the name and a one line description of a man page matching a specified keyword.
e.g.
- Display a program’s info entry : “info”
The GNU project provides an alternative to man pages for their programs, called “info”.
Info pages are displayed with a reader programs named, appropriately enough, info. Info pages are hyperlinked much like web pages.
- Create your own commands with alias : “alias”
we can use the “alias” to give a name to a string of commands, then the alias makes the same function.
8.1. It’s possible to put more than one command on a line by each command with a semicolon character.
e.g.
The commands will be executed as follow steps:
a. go to /usr
b. ls all items
c. go back last working directory
8.2. “alias”
usage:
e.g.
8.3. “unalias”
To reomve an alias, the unalias command is used.
Tips:
There is one tiny problem wiht defining aliases on the command line. They vanish when you shell session ends. In later blog, well will see how to add our own aliases to the files that establish the environment each time we log on.