You don't need to memorise everything
Linux has hundreds of commands, and each has many options. Experienced users don't remember them all; they know how to look things up. Linux has the documentation built in.
Quick help with --help
Most commands print a short summary of their options when you add --help:
mkdir --helpIn the terminal
student@vulntech:~$ mkdir --help Usage: mkdir [OPTION]... DIRECTORY... Create the DIRECTORY(ies), if they do not already exist. Mandatory arguments to long options are mandatory for short options too. -m, --mode=MODE set file mode (as in chmod), not a=rwx - umask -p, --parents no error if existing, make parent directories as needed, with their file modes unaffected by any -m option. -v, --verbose print a message for each created directory -Z set SELinux security context of each created directory to the default type --context[=CTX] like -Z, or if CTX is specified then set the SELinux or SMACK security context to CTX --help display this help and exit --version output version information and exit GNU coreutils online help: <https://www.gnu.org/software/coreutils/> Report any translation bugs to <https://translationproject.org/team/> Full documentation <https://www.gnu.org/software/coreutils/mkdir> or available locally via: info '(coreutils) mkdir invocation'
whatis: one line about a command
whatis tells you in one line what a command does:
whatis ls
whatis dateIn the terminal
student@vulntech:~$ whatis ls ls(1) - list directory contents student@vulntech:~$ whatis date date(1) - print or set the system date and time
man: the full manual
man (short for manual) opens the complete manual page of a command:
man lsThe manual opens full-screen. A man page always has the same sections:
| Section | What's in it |
|---|---|
| NAME | The command's name and a one-line description |
| SYNOPSIS | How to type it. Parts in [brackets] are optional |
| DESCRIPTION | What it does, and every option explained |
| EXAMPLES | Example commands (not every page has these) |
| SEE ALSO | Related commands |
Moving around a man page
| Keys | What it does |
|---|---|
| Space | Next page |
| b | Back one page |
| ↓ / ↑ | Scroll one line |
| /word | Search for word, then press Enter |
| n | Jump to the next search match |
| q | Quit and go back to the prompt |
Tip: To find which option does something, open the man page and search. For example, in
man lstype/sizeand press Enter to jump to options about file sizes.
Searching all manuals
Don't know the command's name? apropos (or man -k) searches the one-line descriptions of every manual page:
apropos directoryIn the terminal
student@vulntech:~$ apropos directory basename(1) - strip directory and suffix from filenames chroot(1) - run command or interactive shell with special root directory dir(1) - list directory contents find(1) - search for files in a directory hierarchy ls(1) - list directory contents mktemp(1) - create a temporary file or directory mountpoint(1) - see if a directory or file is a mountpoint pwd(1) - print name of current/working directory pwdx(1) - report current working directory of a process vdir(1) - list directory contents chdir, fchdir(2) - change working directory chroot(2) - change root directory execveat(2) - execute program relative to a directory file descriptor futimesat(2) - change timestamps of a file relative to a directory file descriptor getcwd, get_current_dir_name, getwd(2, 3) - get current working directory getdents, getdents64(2) - get directory entries lookup_dcookie(2) - return a directory entry's path mkdir, mkdirat(2) - create a directory readdir(2) - read directory entry rmdir(2) - delete a directory VFAT_IOCTL_READDIR_BOTH, VFAT_IOCTL_READDIR_SHORT(2const) - read filenames of a directory in a FAT filesystem closedir(3) - close a directory dirfd(3) - get directory stream file descriptor getdirentries(3) - get directory entries in a filesystem-independent format mkdtemp(3) - create a unique temporary directory opendir, fdopendir(3) - open a directory readdir(3, 3am) - directory input parser for gawk readdir(3) - read a directory readdir_r(3) - read a directory remove(3) - remove a file or directory rewinddir(3) - reset directory stream scandir, alphasort, scandirat, versionsort(3) - scan a directory for matching entries seekdir(3) - set the position of the next readdir() call in the directory stream. telldir(3) - return current location in directory stream proc_pid_cwd, /proc/pid/cwd(5) - symbolic link to current working directory proc_pid_root, /proc/pid/root/(5) - symbolic link to root directory
Is it a real program?
type tells you what a command is, and which shows where its program file lives:
type ls
type cd
which dateIn the terminal
student@vulntech:~$ type ls ls is aliased to `ls --color=auto' student@vulntech:~$ type cd cd is a shell builtin student@vulntech:~$ which date /bin/date
cd is a shell builtin: it's built into bash itself, so it has no program file and no man page of its own. For builtins, use help, for example help cd.
Remember:
--helpfor a quick reminder,manfor everything,whatisandaproposto find the right command. Pressqto leave a man page.