For many new Ubuntu and Linux users, making the transition from Windows to Ubuntu is an exercise in not getting frustrated. For those who stick it out, there comes that eventual time when you need to go beyond the GUI, fire up a Terminal window and start working at the command prompt.
Because Linux provides so many commands and possible options, you can't expect to recall all of them or know their meaning
To help, Linux provides several methods, such as man and the apropos commands, which let you access a help database that describes each command and its options.
As always with any Linux based system, many resources are available when help is needed, and the command prompt is no exception. One thing to keep in mind when using the command prompt, unlike Windows, Linux (including Ubuntu) is case sensitive, so be sure to type each character of a command in the proper case.
Display Options And Arguments For Commands
Say you're working with a command and you want to know what options are available. The easiest method is to just type the command with the help option:
In the following example if you used the above syntax for the chmod command, the output would display as shown below:
wtn@wtn2:~$ chmod –help
Usage: chmod [OPTION]… MODE[,MODE]… FILE…
or: chmod [OPTION]… OCTAL-MODE FILE…
or: chmod [OPTION]… –reference=RFILE FILE…
Change the mode of each FILE to MODE.
-c, –changes like verbose but report only when a change is made
–no-preserve-root do not treat `/' specially (the default)
–preserve-root fail to operate recursively on `/'
-f, –silent, –quiet suppress most error messages
-v, –verbose output a diagnostic for every file processed
–reference=RFILE use RFILE's mode instead of MODE values
-R, –recursive change files and directories recursively
–help display this help and exit
–version output version information and exit
Each MODE is of the form `[ugoa]*([-+=]([rwxXst]*|[ugo]))+'.
Display Information About A Command
Each Linux command is described by a special file called a manual page. The manual pages are stored in a group of sub directories comprising a help database known as an on-line reference manual.
To access this database, use the man command with the following syntax:
For example, to look up detailed information for chmod, type man chmod. The output will display as shown below:
CHMOD(1) User Commands CHMOD(1)
chmod – change file access permissions
chmod [OPTION]… MODE[,MODE]… FILE…
chmod [OPTION]… OCTAL-MODE FILE…
chmod [OPTION]… –reference=RFILE FILE…
This manual page documents the GNU version of chmod. chmod changes
the permissions of each given file according to mode, which can be
either a symbolic representation of changes to make, or an octal num\u2010
ber representing the bit pattern for the new permissions.
The format of a symbolic mode is \u2018[ugoa…][[+-=][rwxXs\u2010
tugo…]…][,…]\u2019. Multiple symbolic operations can be given, sepa\u2010
rated by commas.
A combination of the letters \u2018ugoa\u2019 controls which users\u2019 access to
the file will be changed: the user who owns it (u), other users in the
file\u2019s group (g), other users not in the file\u2019s group (o), or all
users (a). If none of these are given, the effect is as if \u2018a\u2019 were
given, but bits that are set in the umask are not affected.
The operator \u2018+\u2019 causes the permissions selected to be added to the
Manual page chmod(1) line 1
To continue navigating through the pages, use the following keyboard shortcuts:
- Space Bar – scrolls down one page
- B – pressing B scrolls up one page
- Page Up/Down – scrolls up and down one page (same as Space Bar and B)
- Up/Down Arrow – scrolls up or down one line at a time
- Home – jumps to beginning (top)
- End – jumps to end (bottom)
- Q (or CTRL Z) – quits and exits manual page
Search Manual (man) Pages For Keywords
While the man command searches the manual pages and displays detailed information about a specified command, you can use the apropos command to easily search manual pages for keywords. This is useful to display summary information about manual pages that contain a specified keyword.
For example, typing the command:
will display a list of man pages containing the word files as shown below.
wtn@wtn2:~$ apropos files
aa-logprof (8) – utility program for managing AppArmor security profiles
aa-unconfined (8) – output a list of processes with tcp or udp ports that do not have AppArmor profiles loaded
aplaymidi (1) – play Standard MIDI Files
apparmor.d (5) – syntax of security profiles for AppArmor.
apparmor.vim (5) – vim syntax highlighting file for AppArmor profiles
apparmor_parser (8) – loads AppArmor profiles into the kernel
apport-unpack (1) – extract the fields of a problem report to separate files
apt-ftparchive (1) – Utility to generate index files
apt-sortpkgs (1) – Utility to sort package index files
arecordmidi (1) – record Standard MIDI Files
aspell-autobuildhash (8) – Autobuilding aspell hash files for some dicts
bittorrent-downloader.bittorrent (1) – download files using a scatter-gather network
bogoutil (1) – Dumps, loads, and maintains bogofilter database files
btdownloadcurses (1) – download files using a scatter-gather network
btdownloadcurses.bittorrent (1) – download files using a scatter-gather network
btdownloadheadless (1) – download files using a scatter-gather network
btdownloadheadless.bittorrent (1) – download files using a scatter-gather network
Note, that the search is limited to the short description that appears at the beginning of each manual page.
The apropos command is useful when you don't recall the name of a Linux command. By typing a related keyword, you can obtain a list of commands and search the list for the command you need.
Other Ways To Find Commands
While apropos helps you find commands using keywords, you can list commands using the following methods.
– List All Available Commands – press the tab key twice. You will see the following message
Display all 1910 possibilities? (y or n)
To display, just press y. You can scroll through the list by pressing the space bar. To exit before reaching the end of the list, press q.
– List All Commands Starting With A Letter Or Letters – type a letter and press the tab key twice.
For example typing w and pressing tab key twice will display all commands starting with 'w'.
w whereis wpa_cli
w3m which wpa_passphrase
w3mman while wpa_supplicant
wait whiptail w.procps
wall who write
watch whoami writevt
wc whois wvdial
wftopfa wodim wvdialconf
wget word-list-compress www-browser
While typing wh and pressing tab key twice will display all commands starting with 'wh'.
whatis which whiptail whoami
whereis while who whois
– Show Brief Description Of Command – To display just command descriptions, type whatis and the command name. For example, typing whatis who displays the following:
wtn@wtn2:~$ whatis who
who (1) – show who is logged on
– Display Location Of Command – To display the directory or path for a command, use the which command using the following syntax. , which who.
wtn@wtn2:~$ which who
As you can see, many oprions exist to find help at the command prompt when using Ubuntu or any Linux distributions. For Windows users making the switch to Ubuntu, knowing how to find help will ease the transisition and eliminate any fears at the command prompt.