Linux Tutorial / Linux Terminal and Shell Basics: Command Syntax and Finding Help

To run commands on Linux, open a terminal and enter them into a shell. The terminal is the interface where you type and see output; the shell interprets what you type and runs commands. This lesson shows you how to read basic command syntax, distinguish results from errors, and find help when a command is unfamiliar.

What is the difference between a terminal and a shell?

The terminal application is the window that accepts text input and displays results. A shell runs inside it and interprets commands. The shell can handle a built-in command itself or start another program, then display its output in the terminal. Terminal applications may look different, but the basics of writing commands remain similar when they run the same shell.

The examples here use Bash (Bourne Again Shell). Bash is available on both Ubuntu and Rocky Linux, although the shell currently running and the commands installed may differ by system. A remote server may not have a graphical terminal application, but the principles of using a shell are the same.

Open a terminal and find the prompt

In a graphical desktop, search the application list for “Terminal.” The menu name and launch method depend on your desktop environment. When the terminal opens, you will usually see a blinking cursor after text such as your user name or current directory. This is the prompt: the shell is waiting for input.

Your prompt may contain a $ or #, but that character is not part of the command. The code blocks in this lesson contain only what you should type. When a task requires administrator privileges, we will explain when to use sudo instead of relying on the appearance of the prompt.

Type the following command and press Enter:

printf '%s\n' hello

The command prints hello, then the prompt returns:

hello

printf prints text using a format. Here, %s stands for a string and \n adds a newline. It is normal if your actual prompt looks different from one shown elsewhere.

Read the parts of a command

Many commands follow a command + option + argument pattern. The command specifies what to do, an option changes how it works, and an argument identifies what to work on. Not every command needs both options and arguments.

ls -l /etc
Part Example Meaning
Command ls Lists entries.
Option -l Uses a detailed listing format.
Argument /etc Specifies the directory to list.

Spaces separate these parts. In a synopsis such as ls [OPTION] [FILE...], square brackets mean that a part is optional; you do not type the brackets. The ellipsis means that you can specify more than one item. Each command has its own syntax, so check its help when in doubt.

Use quotes when a value containing spaces should be passed as one argument. Compare these commands:

printf '%s\n' hello world
printf '%s\n' 'hello world'

The first command receives hello and world as separate arguments and prints two lines. The second receives one argument and prints one line:

hello
world
hello world

Different kinds of quotes also affect shell expansion in different ways. For now, focus on their basic use for keeping a value with spaces together; variables and expansions belong in a later lesson.

Handle input, output, and errors

After you enter a command and press Enter, the shell runs it. Text on the screen may be a normal result or an error about something such as an unsupported option or a missing file. No output does not necessarily mean failure. Read the message in light of what you asked the command to do.

You can scroll back through long output in the terminal. Press the Up arrow to recall a previous command. Because commands may be kept in shell history, avoid putting passwords or tokens directly into command arguments.

To interrupt a running command, you can usually press Ctrl+C. In a terminal, this sends an interrupt signal to the running command; it is not the usual Copy shortcut. To leave the shell, type exit. Ctrl+D can also exit from an empty input line, but it may have a different effect when another program is waiting for input.

Find help for an unfamiliar command

Check the documentation before guessing an option. External programs and shell built-ins may provide help in different ways.

Method When to use it
command --help Quickly review options if the program supports this flag. Not every command does.
man command Read the installed manual page for detailed syntax and options.
help command Read Bash's help for a shell built-in.
type command Find out whether Bash resolves a name to a built-in, alias, function, or external program.

For example, ls --help gives you a quick look at its options, while man ls provides more detail. Within a manual page, type / followed by a search term to find text, and press q to quit. Some minimal installations do not include the manual page you want.

ls --help
man ls

cd is an example of a Bash built-in. Use type cd to identify it, then help cd to read its usage. The wording of the result can vary with the shell and display language.

type cd
help cd

For more examples, see the separate guides to the man command, the help command, and the type command.

Try a short exercise

  1. Run type printf to see how your current Bash shell interprets printf.
  2. Run help printf and locate the explanation of its format string and arguments.
  3. Run printf '%s\n' 'Linux practice' and check that Linux practice appears on one line.
type printf
help printf
printf '%s\n' 'Linux practice'

The last command produces the following output. The wording from the first two commands may vary with the Bash version and display language.

Linux practice

If you see command not found, check the spelling first. For an error such as invalid option, check the command's help for supported options and syntax. Do not add sudo to every command that reports a permissions error; first find out which file or operation requires permission.

Official documentation

The explanation of the shell and built-ins is based on the GNU Bash Reference Manual: Basic Shell Features and its Bash Builtins section. See the man(1) manual page for manual-page conventions and usage.

More in This Category
Linux lsblk Command: Inspect Disks, Partitions, and Mounts

Linux lsblk Command: Inspect Disks, Partitions, and Mounts

Learn how to inspect Disks, Partitions, and Mounts with the Linux lsblk command, including practical examples, key options, and important precautions.

Linux whereis Command: Locate Binaries, Source, and Man Pages

Linux whereis Command: Locate Binaries, Source, and Man Pages

Learn how Linux whereis locates binaries, source files, and manual pages, limits each search type, lists effective paths, and differs from which and find.

How to Check the Linux Distribution, Version, Kernel, and Architecture

How to Check the Linux Distribution, Version, Kernel, and Architecture

Learn how to identify a Linux distribution and version with /etc/os-release, then check the running kernel and CPU architecture with hostnamectl and uname. The guide also covers scripts, legacy systems, containers, WSL, and chroot environments.

Linux Tutorial / Choosing a Linux Distribution

Linux Tutorial / Choosing a Linux Distribution

Explore major Linux distributions and learn when to choose Ubuntu LTS or Rocky Linux for study and server practice. Compare package management, release policies, and practical selection criteria.

Linux install Command: Copy Files and Set Attributes

Linux install Command: Copy Files and Set Attributes

Learn how to use the Linux install command to copy files while setting modes, owners, groups, timestamps, and destination directories in deployment scripts.

Linux dnf Command: Manage RPM Distribution Packages

Linux dnf Command: Manage RPM Distribution Packages

Learn how to manage RPM Distribution Packages with the Linux dnf command, including practical examples, key options, and important precautions.

Linux wc Command: Count Lines, Words, Characters, and Bytes

Linux wc Command: Count Lines, Words, Characters, and Bytes

Learn how to use the Linux wc command to count lines, words, characters, and bytes in files or standard input, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux traceroute Command: Trace Routers on the Way to a Host

Linux traceroute Command: Trace Routers on the Way to a Host

Learn how to trace Routers on the Way to a Host with the Linux traceroute command, including practical examples, key options, and important precautions.

Linux ssh-copy-id Command: Install a Public Key on a Remote Account

Linux ssh-copy-id Command: Install a Public Key on a Remote Account

Learn how to install a Public Key on a Remote Account with the Linux ssh-copy-id command, including practical examples, key options, and important precautions.

Linux bg Command: Resume a Shell Job in the Background

Linux bg Command: Resume a Shell Job in the Background

Learn how to resume a Shell Job in the Background with the Linux bg command, including practical examples, key options, and important precautions.