man and history commands
LPIC1-101LINUX
3/2/2026


man
1. The Structure of Man Pages (Sections)
Linux manuals are divided into numbered categories:
Section Content Type Example
1 User Commands ls, pwd, grep
5 File Formats /etc/passwd, /etc/fstab
8 System Admin Commands fdisk, reboot, iptables
How to use it: To see the configuration file format for passwords instead of the command, you would run:
man 5 passwd
2. Searching for Commands
man -k (Keyword Search)
This searches the short descriptions of every man page for a specific keyword. It is identical to the apropos command.
Example: man -k partition, man -k network
3. Navigating inside a Man Page
Since man uses the less pager by default, you need to know these keyboard shortcuts:
/pattern: Search forward for "pattern".
?pattern: Search backward for "pattern".
n / N: Go to the next or previous match.
g / G: Go to the top (start) or bottom (end) of the page.
q: Quit the manual.
4. Location and Path
Where these manual files are stored or how the system finds them.
Location: Usually /usr/share/man.
-w: Show the where (the path to the actual manual file on disk).
history
It executes the command number 9 of the history list of commands.
$ history
$ !9
Executes the last command you used:
$ !!
This represents only the very last word (argument) of the previous command:
$ !$
Example:
$ mkdir /var/www/html/my_project
$ cd !$ # This expands to: cd /var/www/html/my_project
Comparison
Shortcut Name What it captures Best for...
!! Bang Bang The whole line Adding sudo or redirecting output (!! > file).
!$ Last Argument The last word Moving, editing, or deleting a file you just touched.
Some flags explained
Writes the history of your current session:
$ history -w
Clears history:
$ history -c
Delete the offset, being the number you have in your history for a command:
$ history -d offset
Append history lines from this session to .bash_history:
$ history -a
Synchronize the history lines from several virtual terminals:
$ history -n
If you manually edited the .bash_history file:
$ history -r
Display that line of the history (without executing it):
$ history -p \!28
Display a range of lines from the history:
$ history -p \!2{5..8}
Search the most recent command that starts with "ls" and show the first argument:
$ history -p \!ls:1
Write anything in the history file:
$ history -s Hello
Contact
hello@unixtips.eu
© 2025. All rights reserved.