Javatpoint Logo
Javatpoint Logo

Linux Terminal


Linux terminal is a standard way of interacting with the Linux server.

The application of the command line might look like a difficult task but it's very convenient if we begin with the basics and create our skills from there.

Let's get it started by covering up what is a terminal emulator.

Terminal Emulator

Linux Terminal

The terminal emulator can be defined as a program that permits the terminal to use it inside a graphical environment. Most people use the operating system along with a GUI for their daily computer requirements, so terminal emulator usage is essential for most of the users of the Linux server.

Here are a few commonly-used and free terminal emulators by OS:

  • Windows: PuTTy
  • Linux: XTerm, KDE Konsole, Terminal
  • Mac OS X: iTerm2, Terminal (default)

All the terminal emulators have their feature set, but each of the mentioned ones is easy for using and works great.

Introduction to Linux Terminal

The Linux terminal is also known as command-line, console, or shell. It is a text interface for our Computer. We can interpret the commands and also write our scripts with this system program.

It might look difficult at first but once we get familiar to do it, it will be easy to use.

Note: All the distributions of Linux come with the command-line. The Linux terminal provides us an interface in which we could input commands and check the result as text. We could use the tunnel for accomplishing the task such as navigating a territory or moving files without using a GUI. These terminals only transfer information. We require a shell for the OS to know this information.

We can manually execute commands by typing in the terminal with the Linux command line. We can also automate commands with the use of Shell Scripts.

Linux Terminal History

There was an OS known as Unix in the old days of computing. It was developed to execute on the mainframe computers as the multi-user system. Several users remotely connected to it by terminals.

Note: The terminal was very common because they can only transfer keystrokes and show data over the screen.

Users can efficiently and quickly interact because the text is light over resources. All the actions the users can implement by this textual interface. Users will connect to an individual master program for coordinating different program's execution.

The user award was wrapped in the shell programs. Users can write the scripts of share that automated the long series of shell commands for making difficult tasks easier.

Besides, Linux can be described as a descendant of Unix. The core part of Linux is developed for behaving to the Unix system similarly. The best chair was designed by Stephen Bourne and published in the Unix 7 version released in 1979. It has become a default shell for Linux systems over time.

The Shell

The shell can be defined as an interface of a command-line that interprets the script files and commands of a user in the Linux system and tells the operating system of the server how to act with them. Several shells are available that are extensively used like C shell (cash) and Bourne shell (sh).

All the shells have their set of features and intricacies related to how commands can be interpreted, but these shells feature output and input redirection, condition-testing, variables, among other things.

Usually, the Bourne-Again shell is known as bash. It is a default shell for almost all the distributions of Linux including RedHat, CentOS, and Ubuntu.

Command Prompt

When we first login to the server, we'll typically welcomed by a Message of the Day (MOTD). Generally, it is an informational message that contains miscellaneous information like the Linux distribution's version that the server is executing. We will be left into the shell prompt or command prompt which is where we could issue the commands to a server after the MOTD.

The information which is presented on the command prompt could be customized by the user. The example of Ubuntu 14.04 default command prompt is here:

Here is the composition's breakdown of the command prompt:

  • sammy: It is the current user's username
  • webapp: It is the server's hostname
  • ~: It is the current directory. The tilde or ~ is a unique character that is a default shell that expands to the way of the home directory of the current user in bash. In this case, it presents /home/sammy
  • $: It is the symbol of prompt. It represents the completion of the command prompt after which the keyboard input of the user will occur.

When logged in as the root and inside the var/log directory, the following is the example of how the command prompt may look like:

Note: # is a symbol that completes the command prompt which is a standard prompt symbol for root. The user of the route is a superuser account which is a unique user account that could act systemwide administrative function in Linux. It is an unrestrained user that includes permission for performing any action on the server.

Executing Commands

Commands could be issued on the command prompt by describing the executable file's name which could be a script or binary program. There are several standard Linux utilities and commands that can be installed using the operating system that permits us to navigate with the file system, software packages and installs, and configure the application and system.

An instance of the executing command is called a process. If a command is run inside the foreground (default path where commands are run), the user should wait for the procedure to complete before being back to the command prompt on which point they could continue issuing other commands.

It is necessary to note that most of the Linux are case sensitive including options, arguments, commands, directory name, and file name. When something is not implementing as expected, then double-check the case and the spelling of our commands.

We will execute by some examples that will be basic terms of the executing command.

Note: If we are not connected to any Linux server, it is a good time for logging in.

Without Options or Arguments

For executing a command without any option or arguments, then we can simply type inside the command's name and press RETURN.

If we execute a command like this, it will show its default nature which changes from one command to another command.

Let's say if we execute a cd command without an argument, we would be returned to the home directory of the current user. The ls command would print the listing of the directories and files of the current directory. The ip command without an argument would print a message that displays us how to apply the command.

Try executing the ls command without an argument for listing the directories and files in our current directory:

With Arguments

Several commands accept parameters or arguments which can impact the nature of the command. Let's take an example in which the most basic way for using the cd command. It is for passing it an individual argument that describes which directory to modify to.

Let's say to modify to the /usr/bin directory, in which several standard commands can be installed, we will issue this command:

The command is cd component and the initial argument /usr/bin pursues the command.

Note: How the current path of the command prompt has been updated.

If we would like, try executing the ls command for seeing the files that are inside our new current directory.

With Options

Most of the commands accept options and also called switches or flags that change the nature of the command. Because they are unique arguments, so options pursue the command and also are indicated using individual - character pursued by multiple options which are illustrated by a single lower or upper case letters.

A few options additionally begin with - -, pursued by an individual or multi-character (descriptive word usually) option.

For a common example of how these options work. Let's see on the ls command. Here are some basic options that are very common if using ls:

-l: It prints the long listing which contains extra information like timestamps, file sizes, ownership, and permissions.

-a: It lists all the files of a directory including unknown ones (that begins with .).

For using the ls with -l, apply this command:

Note: The listing contains similar files as before, however, with additional details about all the files.

As mentioned before, options could often be collected together. If you wish to use the -a and -l option together, we can run ls -l -a, or only merge them like in the below command:

Note: The listing contains the hidden, and directories inside the listing due to the -a option.

With Arguments and Options

Arguments and options could almost always be merged when executing commands.

Let's say, we can inspect the contents of the /home, regardless of our current directory by executing the ls command:

The command is ls, options are -la, and the argument is /home that illustrates which directory or file to list. It must print the /home directory detailed listing which must include the home directory of each normal user over the server.

Environment Variables

These variables are known as values that can be applied for changing how processes and commands are run. When we initially log in to the server, various environment variables would be by default fixed according to some configuration files.

View Every Environment Variable

For viewing each environment variable that is fixed for a specific terminal session, execute the env command:

Likely, there will be several outputs but look and try for PATH entry:

The PATH environment variable can be defined as a colon-delimited directories list in which the shell would look for some executable scripts or programs when any command is issued. Such as, the env command is placed in /usr/bin and we will be able for executing it without describing its fully-qualified position due to its path is inside the PATH environment variable.

View the Variable's Value

And environment variable value could be received by prefixing the name of the variable with the $. Doing so would develop the referenced variable to the value.

For printing out the PATH variable's value, we may apply the echo command:

Or we can apply the HOME variable which is fixed to the home directory of our user by default for changing to our home directory like this:

If we try to authorize an environment variable that has not been fixed, it will be spread to nothing; the empty string.

Environment Variables Setting

Now that we know how to see our environment variables, we must understand how to fix them.

For setting the environment variable, all we need to do is begin with the variable name, pursued by the = sign immediately, and pursued by the desired value immediately:

Note: When we fix the existing variable, the real value would be overridden. If the variable didn't present in the initial place, it will be made.

Bash contains a command known as exports which can export a variable; hence it will be acquired by the child processes. It permits us for using scrips that prefer the exported environment variable through our current session in general terms. Still, if we are unclear over what it means, do not take care of it for now.

Also, we can refer to the existing variables if setting any variable. For example, when we installed any application into opt/app/bin, we can include that directory to the completion of our PATH environment variable along with this command:

Now, authenticate that /opt/app/bin has been included in the completion of our PATH variable along with echo:

Remember that setting the environment variables in this style just sets them for our current session. It means if we log out or otherwise modify to other sessions, the modifications we created to the environment would not be preserved. Also, there is a way to permanently changing environment variables.

How to Start a Terminal

Linux Terminal

Technique 1: Activities

  1. Press on the activities over the top left side of our screen.
  2. Search for prompt, command, shell, or terminal.
  3. Choose the terminal option for launching it. Here we have our terminal or prompt. It's only a dumb-looking screen for now.

If we are using some other Linux version, the terminal will be positioned at a similar place because of other application launchers. If we cannot detect it, apply the second method.

Technique 2: Keyboard Shortcut

It is the simplest way for accessing our Linux terminal. Click CTRL+ALT+T to open the terminal instantly.

Note: We have an option to change it because it is a default shortcut. For this, go into the Settings > Keyboard Shortcuts

Here, we can see every keyboard shortcut as shown as follows:

Press the shortcut next to the launching terminal. Input our new shortcut inside the Set Shortcut window, press Set, and we are good to go.

Let's say, we change the shortcut into CTRL+T, as we can examine as follows:

How to Handle Files

Now that we have examined the terminal try out some basic commands. The commands are those instructions that we provide to our computer for doing something.

Press the window for ensuring our keystrokes go there. That odd text detected over the terminal is known as prompt. It is the way of the computer to say that it is ready to accept any command.


Enter inside the command as follows and press enter.

We are inside the home directory of our user when we launch the terminal. Usually, it looks something like "/home/user name". This command prints the working directory command enables us to understand which directory we are in.

The way it provides is an absolute way. The absolute way begins through the root which can be defined as the Linux file system's base. It is represented by the '/' (slash).


Another basic command is ls. ls command is used for displaying every file and directory in our current directory. Input ls and press enter.

For viewing the hidden files, we can include -a to the command.

We can also include other options in the command to find specific information.

Options Description
ls -x Sort using extension name
ls -t Sort using date and time
ls -s File size of the list
ls -S Sort using file size
ls -r Reverse order list
ls -R Recursively list directory tree
ls -ls List with file size with long format
ls -lh List with readable file size and long format
ls -la List with long format containing hidden files
ls -l List using long-format display permissions
ls -d Directories of the list with '*/'


It is a change directory command. Our current directory is in which we are working. Before modifying directories, let's understand what relative and absolute paths are:

The absolute path begins from the root of the system and relative path through our current directory.

We can switch return to our previous directly with:

The directory above the current one immediately is our parent directory. For navigating to our parent directory, we can use:

For moving up to levels, we can use:

For navigating to our home directory, we can use:

How to make Files and Folders

Making folders and files is quite efficient with Linux. Let's begin with making a new directory known as "Cake". We will apply the command:

For verifying if the directive was directory was made, we can use the ls command:

Also, we can create more than one directory with mkdir, we can use:

Note: Don't include any space among the names. If we do then it will add space between the names of the directories we have created.

We can make some directories in a directory by including -p. For example, we wish to make Cake2 in Cake1 in Cakes, we will use:

For viewing the structure of the directory, we will use:

Next TopicLinux sudo

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA