How To Use The Linux Terminal

How To Use The Linux Terminal

Beginners and Pros alike will want to know How To Use The Linux Terminal in the most efficient way possible. At this point we have a Linux distribution to work with, so let’s start learning at the very beginnings. The beginning is learning about the command line, or shell as it’s also known by. The shell is in fact a program itself, running on the Linux machine, and it accepts commands you type in so the system can execute them. The program gets its name from Steve Bourne who originally wrote it. It also goes by the name bash, which stands for Bourne Again Shell, which is an updated version of the first iteration written by Bourne. For the Matt Damon fans out there, it also reminds us of the popular Bourne Identity series of movies. You know Bourne knows How To Use The Linux Terminal.

How To Access The Linux Shell

There are a couple of ways to access the Linux shell. We have already taken the approach of using SSH to log in to an Ubuntu server when we set up VirtualBox and Vagrant. With our new dual boot system, we can get access to the shell even more easily via the Terminal. The terminal is a simple program on all Linux distributions and it is very easy to find. If you need help launching the terminal, follow the Ubuntu guide here.

Start Entering Some Commands

Once you launch the terminal, you are ready to enter some commands. The first thing you’ll notice is the prompt, which might look something like this:


Welcome to the shell! This is the signal to you the Linux User, that the shell is ready to accept some input. Notice that the prompt follows a particular convention, in username@computername directory dollar sign. This convention is consistent across all types of Linux. The directory simply refers to the current working directory. This is where you currently are in the overall structure or tree of the operating system. The dollar sign indicates you are logged in as a user. This is in contrast to if there was a hashtag # which indicates superuser. It is generally accepted that you should rarely ever control your Linux instance using superuser privileges. It is much safer to use a user account and apply sudo to commands that may need elevated rights.

We can also use SSH to log into a remote Linux Server. In this case, we’ll use our homestead instance we had created in a prior episode when working with VirtualBox, Vagrant, and Laravel Homestead. Here is an example of using SSH to log in to our Virtual Machine which is running a Server edition of Ubuntu.

$ vagrant ssh
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-30-generic x86_64)

* Documentation:

System information disabled due to load higher than 1.0

Get cloud support with Ubuntu Advantage Cloud Guest:

56 packages can be updated.
26 updates are security updates.

Last login: Fri Jan 16 17:55:40 2015 from

Cool! Notice the same convention at the prompt. We are logged in as user name vagrant at machine name homestead with user rights, indicated by the dollar sign. Now let’s try a handful of beginning commands to get started.

vagrant@homestead:~$ ls
vagrant@homestead:~$ date
Tue Jan 27 15:32:22 UTC 2015
vagrant@homestead:~$ cal
January 2015
Su Mo Tu We Th Fr Sa
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

vagrant@homestead:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 41251136 2013620 37501604 6% /
none 4 0 4 0% /sys/fs/cgroup
udev 1019836 12 1019824 1% /dev
tmpfs 205008 3532 201476 2% /run
none 5120 0 5120 0% /run/lock
none 1025036 4 1025032 1% /run/shm
none 102400 0 102400 0% /run/user
vagrant 249545724 137756960 111788764 56% /vagrant
home_vagrant_Code 249545724 137756960 111788764 56% /home/vagrant/Code
vagrant@homestead:~$ free
total used free shared buffers cached
Mem: 2050072 978288 1071784 20972 22088 274868
-/+ buffers/cache: 681332 1368740
Swap: 0 0 0

Excellent! So here we tried out a collection of basic commands and viewed some information about the system. ls is used to show us the contents of the directory we are currently in. Here we can see we have a folder named Code within it. We can check the current date using the date command. The cal command gave us a nice calendar of the current month. df is used to examine the amount of free space on the disk drives of the system. We can also take a look at free memory with the free command. Finally, you may have noticed on the initial login that there where several updates available for the system. This is to be covered further down the road, but the obsessive compulsive in me can’t let things go, so those outdated packages must be updated! To update your system, you can use the following commands to do so.

vagrant@homestead:~$ sudo apt-get update
vagrant@homestead:~$ sudo apt-get install

You may get several prompts during the update process checking whether to overwrite existing configuration files and such. Usually, you’ll keep your original config files, since you’ll most likely need those settings. When in doubt keep the defaults.

Close The Terminal Session

When you’re finished with your time in the terminal, you’ll need to close the session. It’s pretty easy, all you have to do is type exit.

vagrant@homestead:~$ exit
Connection to closed.

How To Use The Linux Terminal Conclusion

In this episode we started coming to grips with the Linux Terminal in order to access the Linux Shell. We learned an interesting tidbit about where the name of the shell came from in Steve Bourne, sh, and bash. We learned that bash stands for Bourne Again Shell. Finally, we used our Vagrant Box combined with Virtual Box to test some entry level commands in the Linux shell. These included ls, date, cal, df, free, sudo apt-get update, sudo apt-get install, and exit. All in all, this has been a great beginners introduction to working with the Linux Shell using the Terminal.