Running Commands and Getting Help
-
Linux
Linux Basics
Tutorials
Commands
Overview
Running Commands
- Each item is separated by a space.
- Commands have the following syntax
command options arguments
- Options modify the command’s behavior
- Single letter options usually preceded by -
Can be passed as -a -b -c or -abc - Full word options usually preceded by --
Example:--help
- Single letter options usually preceded by -
- Arguments are file names or other data needed by the command
- Options modify the command’s behavior
- Multiple commands can be separated by semicolon (;)
mkdir backups; cp *.txt backups/
`
Some Simple Commands
Date - Display date and time
- date command prints system date and time.
- The format is configurable via an optional formatting string (see options with
date --help
)
Cal - Display Calendar
- cal command prints an ASCII calendar of the current month.
- When single numeric argument is passed to the cal command, cal command prints the given year calendar.
- For example:
cal 06
will print the calendar for the year 0006, not the year 2006. - When a month and year is passed as argument to the cal command, cal command prints the particular month calendar.
Getting Help
- Don’t try to memorise everythings!
- Many levels of help
- whatis command
- help option
- man command
- info command
- Extended Documentation
1. whatis comand
- Display short discriptions of commands.
- whatis command uses a database that is updated nightly, so often not available immediately after install.
- Generate whatis database without waiting for automatic update, run
makewhatis
command as root user.
2. --help option
- Just knowing what a command does is not always enough.
- In order to use a command effectively you need to know what options and arguments it accepts (the syntax of the command).
- Most commands have a --help options, but not all the commands have --help options.
- The command --help option Display usage summary and argument list.
Reading Usage Summaries
- Arguments in [] are optional.
- Arguments in <> or CAPS are variables.
- Text followed by … represent a list.
- x|y|z means x or y or z.
- -abc means any mix of -a, -b or -c.
3. The man command:
- Almost every commands as well as most of the configuration files and several developer’s libraries on Linux system has an associated man pages, which provides more through documentations than the command
--help
options. - The man pages normally contains the following sections
- NAME
- SYNOPSIS
- DISCRIPTION
- OPTIONS
- FILES
- BUGS
- EXAMPLES
- SEE ALSO
- The collection of all the man pages on a system is called Linux Manual.
- The Linux Manual is divided into several sections, each of which covers a particular topics, and every man page is associated with exactly one of these sections.
- The Linux Manual sections are:
- Often, Linux commands, calls, and files are referenced by a name followed by manual section number in parentheses.
Navigating man pages
- Navigate with arrows, PgUp, PgDn
- /text searches for text
- n/N goes to next/previous match
- q quits man page
Searching Linux Manual
- Suppose you do not know the name of command you are looking for, in this case you can perform keyword search.
- To perform keyword search its uses whatis database.
4. The info command
- Similar to man command, but often more in-depth.
- Run info command without arguments, list all the info pages.
- The structure of info pages are looks like a website.
- Each page is divided into nodes.
- Links to nodes are precededby *.
- info [command]
Navigating info pages
- Navigate with arrows, PgUp, PgDn
- Tab moves to next link
- Enter follows the selected link
- s text searches for text (default: last search)
- n/p /u/l goes to next/previous/up-one/last node
- q quits info page
NOTE!: If you prefer the navigation keys used by man commands, such as / n and N, you can start info command with –vi-keys argument. Example: info –vi-keys [command]
5. Extended Documentation
- The /usr/share/doc directory contains the documentations that does not fit the length or the format of a man and info pages.
- The /usr/share/doc is a location of documents that does not fit elsewhere.
- Sample configuration files, tutorials
- HTML/PDF/PS Documentation
- License Details
Newsletter
Get updated when I create new content.
Unsubscribe whenever. Never any spam.