(upbeat music)
- Most of us are familiar
with using a computer that has a graphical user interface,
or GUI.
We're accustomed to seeing visual elements
like scroll areas, images, buttons, and dropdown menus.
We can drag windows around, click links,
and view charts or graphs.
In a lot of cases,
that's exactly what we want for photo editing,
document layout, browsing the web, graphic design,
watching movies, and playing games.
But not all software requires a graphical interface.
Especially on servers, embedded applications,
and in many other areas,
software runs without this graphical interface.
But we still need a way of interacting with the program
if we don't have a desktop view to run our GUIs.
Server software utilities and other programs usually
only need some text-based information to do what they do.
Many of these programs run on a server
in a data center somewhere without a monitor.
So the overhead
of a graphical interface is completely unnecessary.
One way we interact with these programs that don't have
or don't use a GUI is through the command line.
The command line is a text-based interface where
we type commands and direct text-based input
and output to the screen to files and to other programs.
The environment we use is called a shell
or command line interpreter,
and there are many shells out there.
The command line interpreter was one of the earliest ways
of interacting with a general purpose computer,
starting in 1971 with the Thompson shell for UNIX.
As UNIX evolved
and came to be replaced in many capacities by LINUX,
the shell environments evolve too.
Bash or the Bourne-again shell,
is one of the most widely used shells.
And it's the one you're likely to need
to become familiar with
as you begin your command line journey.
Bash is the shell that comes enabled
by default with most of the popular Linux distributions.
It's also available on Mac OS
and in windows with the windows subsystem for Linux.
There are a few terms and ideas you need to be familiar with
to really be productive using the command line.
Before we jump into using commands, let's take a look
at how command line statements are structured.
The general pattern you'll see is command, options,
and arguments.
Here's a couple of common commands
you'll see with options and arguments
that are used with them.
Don't worry about the specifics of the commands right now.
We'll see them in more detail later on.
I just want to show you the structure
of what we'll be working with before we get
into what these actually do.
Depending on what you're doing,
you might just have a command or a command
and one or more options,
or just a command with one or more arguments,
but there will always be a command.
That's the basic unit we're working with.
The command is the program you're running
or the action you're taking.
In the first case here's ls, which means list.
It shows the files in a specified directory.
A lot of commands you see are very short.
Sometimes just a few letters.
This is a tradition that goes back a long time.
Many commands are just long enough
to represent what they mean
rather than using the whole word.
While it can make commands a little harder
to remember and discover,
as you become more familiar with the command line,
you'll see how it's a lot more convenient
to type a short command like ls,
every time you want to list the files in a folder
instead of typing out list
or list files or something longer like that.
Sometimes the command does something just by itself,
but other times we'll want to change how a command works
or tell it what data to use.
The next part of a command line statement, the options,
tell the command how to operate, changing the behavior
of the command or telling it to perform different actions.
Most options start with a dash
and are specified by one letter.
Most commands offer more than one option.
And when you need to use more than one,
you can list them individually.
For example, I can add an option - l to the ls command,
which tells the ls command to show me a long listing
of the files in a directory rather than a shorter one.
I can add others, maybe - a and - h,
which tell the command to show me all the files,
not just the hidden ones
and to make the file sizes human readable.
Most of the time
instead of listing each option individually,
we'll combine them right after one dash
with no spaces in between like this.
The order of the options usually doesn't matter.
So this would do the same thing.
The options that have two dashes
can't be combined together.
They have to go one right
after the next separated by a space.
The last portion of a statement
is the argument or arguments.
This is where you tell the command what thing to operate on.
It's usually a file path or a set of files or folders.
In this example,
we're telling the ls command to show us the contents
of the usr bin folder, and further down,
we're telling the sort command to sort of file called users.
That's it for the basic syntax of commands.
Understanding this basic pattern will help you learn
and use unfamiliar commands in the future.
(upbeat music)