Commands that provide help are essential. Here's a look at some of the help you can get from the Linux system itself. Credit: Altitude Visual / Shutterstock Even after you’ve used Linux for a while, you will still find yourself needing help from time to time, whether you’re learning a new command or you need more details on some of the command’s numerous options. So let’s examine some of the help that you can get from the system itself. Linux commands that provide help Man Apropos Help Which echo Man pages Among the most useful commands for getting help on Linux is the man (i.e., manual) command that provides information on what a command does and what options are available. Almost every command will have a man page available that you can use to view a screenful at a time. For example, if you wanted to see the options for formatting the output of the date command, you should look at the man page with the command “man date”. It should among other things, show you the format of the date command like this: SYNOPSIS date [OPTION]... [+FORMAT] date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]] In syntactical descriptions such as this, anything in square brackets is optional. You can use the date command simply by typing “date” and nothing more. The vertical bars in the first square-bracketed portion of the syntax shown mean “or”, so you select from the options shown if you want to see the date and time in “universal time” (the primary time standard by which the world regulates clocks and time). $ date -u Mon Jul 8 06:03:21 PM UTC 2023 Man pages will, after syntactical descriptions, go on to explain each of the options, often providing examples. Options for the date command include these and others: Options: -d output short description for each topic -s output only a short usage synopsis for each topic matching PATTERN -u, --utc, --universal print or set Coordinated Universal Time (UTC) NOTE: Most any command that does not have its own man page is likely a “built-in” – a command that is built into another command’s executable file. For example, the bash shell has a number of built-ins that make it easier to use. Apropos command The apropos command will list commands that are related to whatever you ask about. Use the command shown below and you’ll get a list of commands and explanations related to passwords. $ apropos password chage (1) - change user password expiry information tpm2_policypassword (1) - Enables binding a policy to the authorization value of the authorized TPM object. git-credential-cache (1) - Helper to temporarily store passwords in memory grub2-mkpasswd-pbkdf2 (1) - generate hashed password for GRUB htdbm (1) - Manipulate DBM password databases lchage (1) - Display or change user password policy lpasswd (1) - Change group or user password openssl-passwd (1ossl) - compute password hashes openssl-srp (1ossl) - maintain SRP password file pwmake (1) - simple tool for generating random relatively easily pronounceable passwords pwscore (1) - simple configurable tool for checking quality of a password secret-tool (1) - Store and retrieve passwords sshpass (1) - noninteractive ssh password provider systemd-ask-password (1) - Query the user for a system password systemd-tty-ask-password-agent (1) - List or process pending systemd password requests vncpasswd (1) - change the VNC password Help command The Linux help command will provide information on built-ins. For example, you can ask help about the help command. The response, as shown below, shows that help is itself a built-in. $ help help help: help [-dms] [pattern ...] Display information about builtin commands. Displays brief summaries of builtin commands. If PATTERN IS specified, gives detailed help on all commands matching PATTERN, otherwise the list of help topics is printed. Options include: Options: -d output short description for each topic -m display usage in pseudo-manpage format -s output only a short usage synopsis for each topic matching PATTERN On some systems, when you ask for help for a built-in, you’re going to get a very long page describing all of the built-ins. You will have to scroll down until you find the section that describes the built-in you’re asking about. Which command The which command will identify the executable that represents a particular command. Notice that the which command will not provide information on built-ins because it only looks for files and built-ins are included only within the shell. $ which date /usr/bin/date $ which cd /usr/bin/cd $ which help /usr/bin/which: no help in (/home/shs/bin:.:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/home/shs/bin:/opt/pash:/home/shs) With no arguments, the which command stops looking when it finds the first march for the command name. Adding the -a option will get the command to show all of the executables when there is more than one. $ which -a python /usr/python /usr/bin/python NOTE: The which command relies on your search path to determine where to look for whatever executable you ask about. Echo command The echo command is one that will repeat what you type. If you use a string, it will simply display it. If you ask it to display a variable, on the other hand, it will display the variable’s value. In the second command below, the value of the $SHELL variable is the shell that is being used.</strong<echo<> $ echo hello! hello! $ echo $SHELL /bin/bash You can also determine which shell you are using by looking at your entry in the /etc/passwd file. It’s the last field in the colon-separated line that describes your account. You can also see the numeric userid and groupid – both 1004 in this example. $ grep justme /etc/passwd justme:x:1004:1004:Just Me:/home/justme:/bin/bash Saving command output to a file To save the output of a command to a file, use a > sign to redirect the output. In the example below, the output from the date command is sent to a file named “times” – overwriting the file if it already exists. The second adds to it. $ date > times $ date >> times $ cat times Wed Nov 8 03:15:18 PM EST 2023 Wed Nov 8 03:15:24 PM EST 2023 Cheat sheets When you’re beginning your Linux journey, it’s also good to have what many call a “cheat sheet” on hand – a card, sheet of paper or file that provides very brief descriptions of a group of commands and how they work. For example, you will likely see descriptions such as these: pwd displays name of current directory (full pathname of your location on the filesystem) ls lists contents of current directory ls –l lists contents of current directory with extra details (e.g., permissions, ownerships, file size) ls ~/*.txt lists all files in your home directory ending in .txt cd change directory to your home directory cd - move into the last directory you were in before changing to wherever you are now mkdir mydir makes a directory called mydir rmdir mydir removes directory called mydir. mydir must be empty touch myfile creates a file called myfile. updating the timestamp on the file if it already exists cp myfile myfile2 copies myfile to myfile2 (overwriting myfile2 if it already exists rm myfile removes file called myfile rm –f myfile removes myfile without asking for confirmation cp –r dir newdir copies the contents of dir to newdir. (the -r makes it recursive) rm –rf mydir delete directory mydir along with all OF its content without asking you for confirmation To build your own cheat sheet, you can make a list of commands in a file and then use a script like that included in this post that pulls command descriptions from the help, whatis and man pages: Building your personal Linux cheat sheets Here’s a cheat sheet that I put together quite a while ago: Linux command cheat sheet Linux cheat sheets are commonly used by anyone coming up to speed on the Linux command line. You’ll probably find thousands of them if you type “Linux cheat sheet” into your browser’s search bar. SUBSCRIBE TO OUR NEWSLETTER From our editors straight to your inbox Get started by entering your email address below. Please enter a valid email address Subscribe