Beginners Guide to Linux Terminal

0
126
Upto 40% Off on Intel Powered Laptops - Buy Now on Snapdeal

Whether you’re a new Linux user, or already familiar with it, I am going to give you a helping hand, so that you learn to use the Linux Terminal. The terminal is not something you need to be afraid – it is a powerful tool that has a high possibility of uses.

Of course you will not grasp everything you need to know about the Linux terminal in just one article. You will have to gain experience playing with the terminal. This article is an introduction, I hope you master the basics, so you can continue to learn more.

Basic Usage of Linux Terminal

Launch the terminal via the application menu located on the desktop, or use the keyboard shortcut Ctrl + T and you will see the “bash shell”. There are other shells, but the Linux distributions use the “bash” by default.

launch terminal on ubuntu

You can launch terminal program by typing its name at the prompt. You can run an application from the command prompt. A GUI applications such as Firefox can be run from the terminal as well. (The bash actually has some integrated controls for basic file management functions and similar programs). Unlike Windows, you will not need to type the full path of a program to run it. For example, if you want to launch Firefox. On Windows, you need to type the full path to the firefox.exe file. But in Linux, you just need to type:

launch firefox from terminal

Then press “Enter” to run the command. Note that you do not have to add an .exe or something similar – programs do not have extensions on Linux.

Terminal commands also accept arguments. The types of arguments you can use depend on the programs. For example, Firefox accepts web addresses as arguments. To launch Firefox and open the Technology Blog, you can run the following command:

i will discuss more possible commands that you can run in the terminal, In most cases, the command runs inside the terminal – i.e., do not open any graphics application that runs in a separate window (as Firefox).

Installing Software

One of the most efficient things that can be done using the terminal is installing programs. Software management applications, such as the Ubuntu Software Center, hides the various terminal commands that run in the background. Instead of clicking and selecting the applications one-by-one, you can install them with a single terminal command. You can also install multiple applications with a single command.

In Ubuntu (other Linux distributions has its own package management system), the command to install a new software package is:

This may seem a little complicated, but it’s working like Firefox’s command that we saw above. The above line launches the “sudo”, (Super User Do) which asks for your password before starting the “apt-get” with “root” (root) administrator privileges. The program “apt-get” reads the arguments “install packagename” and install a package called “packagename”.

However, you can also specify multiple packages as arguments. For example, to install the Chromium web browser and instant messenger Pidgin, you could run this command:

If you have already installed Ubuntu and wanted to install all your favorite software, you can do this with a single command, as seen above. You just have to know the names of the packages of your favorite programs, and you can guess them easily – you can refine your guesses with the help of the “Tab” key, we will see soon, in this tutorial.

Working with Directories and Files

The shell looks in the current directory, unless you specify another directory. For example, the nano is a simple text editor for the terminal. nano document1 command tells nano to launch and open the file called document1, in the current directory. If you want to open a document located in another directory, you must specify the full path to the file – for example, nano /home/you/Documents/document1.

If you specify a path to a file that does not exist, the nano (and many other programs) will create a new blank file in their location and open it.

To work with files and directories, you need to know some basic commands:

  • cd – The ~ symbol at the left of the prompt is your home directory (ie, / home / you), which is the default terminal directory. To switch to another directory, you can use the cd command. For example, cd /Downloads change to the Downloads directory within the current directory (so this command will only open the Downloads directory if the terminal is inside your home directory) cd /home/you/Downloads change to your directory “Downloads” from anywhere in the system, cd ~ change to your “home” directory, and cd .. would move up a directory.
  • ls – The ls command lists the files in the current directory.
  • mkdir – The mkdir command creates a new directory. mkdir example will create a new directory called example in the current directory. While mkdir /home/you/Downloads/test would create a new directory called “test” inside your Downloads directory.
  • rm – The rm command removes a file. For example, rm /home/you/Downloads/example will remove the file called example, which is within the Downloads directory.
  • cp – The cp command copies a file from one location to another.  The syntax is: cp SOURCE DESTINATION. For example, 

    copies the file called readme.txt, present within the current directory to /projectbackup/readme-new.txt.
  • mv – The mv command moves a file from one location to another. It works just like the cp command above, but moves the file instead of creating a copy (equivalent to “cut” of Windows). The mv command can also be used to rename files.

This may seem a little tricky at first, but these are the basic commands you need to master to work with files inside the terminal. Move through your file system, using the cd command, view present files in the current directory with the ls command, create directories with the mkdir command, and manage files using the rm, cp and mv command.

Autocomplete Function Using the Tab Key

Auto Completion using the Tab key is a very useful trick. While typing something – for example, a command, or some other kind of argument – you can press Tab to auto-complete what you are typing. For example, if you type firef the terminal and press the Tab key, the word firefox appears automatically. This helps you to prevent from typing wrong commands and arguments – you can press Tab and the shell will complete the word for you. This also works with folders, file names, and package names.
For example, you type sudo apt-get install PIDG and press Tab to complete the name pidgin automatically.

In many cases, the shell will not know what you’re trying to type because there may be multiple combinations. In this case, Press & Hold the Tab key and you will see a list of possible matches. Keep typing some more letters in order to reduce the possibilities, and press Tab again to continue.

At this stage, you should hopefully feel more comfortable with the terminal and should have a better understanding of its working.

 

FlipKart Mouth Watering Deals veryday