Linux Shell or Command Line Interface – Getting Started

In this section we will post a number of tutorials where we take a look at how to use the Linux Shell or also so called Linux  Command Line Interface (CLI). The goal of this tutorial is to help you get started with the Linux command line and explain some things you need to know before you should start with the other tutorials. In short: this is the introduction tutorial!

What Linux Distribution are We Using?

Before we get started you need to know that on this site we will mostly use Red Hat based Linux systems to explain things. So command line tools, configuration files and file system layout may differ on other distributions of Linux.

We recommend that you install a Red Hat based system. Some Red Hat based distributions are  Fedora, CentOS and Scientific Linux.

What is the Shell?

So what is a shell or command line? A Unix/Linux shell is a command-line interpreter (or shell) which takes commands from the keyboard and gives them to the operating system (OS). (Note: that a shell is also a program). Before we got the graphical user interfaces (GUIs) the command line interfaces (CLIs), such as the shell, where the only way to communicate to the OS.

On most Linux systems a program called bash, which stands for Bourne Again Shell, acts as the shell program. Because a shell is a program we can install other shell programs, for example the original Unix shell program sh. Some other know shell programs are ksh, zsh and tcsh.

What is a Terminal?

So how do you get to the shell? To interact with the shell you need a program called terminal emulator. A terminal emulator is a progam that opens a window and lets you talk to the shell. There are many different terminal emulators you can use (almost all distributions supply different emulators), such as: konsole, xterm, kvtm, gnome-terminal, eterm, nxterm, and many others.

Starting a Shell Session or Terminal

To start a command line session or open a terminal it depends on if you are already working on the machine or you need to login from one machine to another machine.

So if you are working on the physical machine that has the Linux distribution install on it you probably had it installed so you get a graphical user interfaces (GUIs) or Window Manager (such as KDE or Gnome) when you start the machine. If this is the case your window manager has a way to launch a terminal from the menu. Browse through the menus and look for a program that looks like a terminal emulator. If you are a KDE user, the terminal program is called “konsole,” in Gnome it is called “gnome-terminal.” Note that you can start more than one terminal or shell session.

If you need to login in from one machine to another machine (that has the Linux distribution installed on it) to get access to the command line. Then you need to install telnet and SSH Client on you current machine to remote login to the Linux system. Such a client is for instance PuTTY.

Shell Prompt

The shell prompt that you get on a system may vary, but it probably look something like this:


-sh-4.1$

Or like this where @ is shown by the shell prompt:


[user@lnxserver01 /]$

The dollar sign will tell you that you are logged in as a user and not as root.
In most cases a root shell prompt will end with a hash sign, such as in this example:


[root@lnxserver01 /]#

Note: it is not good practice to work with the root or root equivalent user, for many different reasons. If you work as superuser , root user or root equivalent user you have all administrative privileges. In other words you can do potentially dangerous things, such as removing filesystems, deleting files and destroying your OS, if you don’t know what you are doing!

Unless you absolutely need administrative privileges, do not operate as a superuser, root user or root equivalent user. A better way is to login as a normal user and give this user permission to do things (for instance using sudo).

That’s all for this command line (shell) introduction tutorial. In the next tutorial we will take a look at Paths and Directories, in other words: how to navigate around in a filesystem.

This entry was posted in Linux Command Line. You can follow any responses to this entry through the RSS 2.0 feed. You can trackback from your own site. Tweet This! Tweet This! or use to share this post with others.

Leave a Reply: