3  First step in a terminal


Laurent Modolo

Creative Commons License

Objective: learn to use basic terminal command

Congratulations you are now connected on your VM !

The first thing that you can see is a welcome message (yes GNU/Linux users are polite and friendly), and information on your distribution.

A Linux distribution (often abbreviated as distro) is an operating system made from a software collection that is based upon the Linux kernel

What is the distribution installed on your VM ?

You can go to this distribution website and have a look at the list of firms using it.

3.1 Shell

A command-line interpreter (or shell), is a software designed to read lines of text entered by a user to interact with an OS.

To simplify the shell executes the following infinite loop:

  1. read a line
  2. translate this line as a program execution with its parameters
  3. launch the corresponding program with the parameters
  4. wait for the program to finish
  5. Go back to 1.

When you open a terminal on an Unix-like OS, you will have a prompt displayed: it can end with a $ or a % character depending on your configuration. As long as you see your prompt, it means that you are in step 1., if no prompt is visible, you are in step 4. or you have set up a very minimalist configuration for your shell.


The blinking square or vertical bar represents your cursor. Shell predates graphical interfaces, so most of the time you won’t be able to move this cursor with your mouse, but with the directional arrows (left and right).

On the IFB, your prompt is a $:


You can identify the following information from your prompt: etudiant is your login and VM is the name of your VM (~ is where you are on the computer, i.e. the current working directory, but we will come back to that later).

On Ubuntu 20.04, the default shell is Bash while on recent version of macOS it’s zsh. There are many different shell, for example, Ubuntu 20.04 also has sh installed.

3.2 Launching Programs

You can launch every program present on your computer from the shell. The syntax will always be the following:

etudiant@VM:~$ program_name option_a option_b option_c [...] option_n

And pressing enter to execute your command.

For example, we can launch the cal software by typing the following command and pressing enter:


When you launch a command, various things can happen:

  • Information can be displayed in the shell
  • Computation can be made
  • Files can we read or written
  • etc.

We can pass argument to the cal software the following way.

cal -3

What is the effect of the -3 parameter ?

You can add as many parameters as you want to your command, try -3 -1 what is the meaning of the -1 parameter ?

The -d option display the month of a given date in a yyyy-mm format. Try to display your month of birth.

Traditionally, parameters are named which means that they are in the form of:

  • -X for an on/off option (like cal -3)
  • -X something for an input option (like cal -d yyyy-mm)

Here the name of the parameter is X, but software can also accept list of unnamed parameters. Try the following:

cal 2
cal 1999
cal 2 1999

What is the difference for the parameter value 2 in the first and third command ?

3.3 Moving around

For the cal program, the position in the file system is not important (it’s not going to change the calendar). However, for most tools that are able to read or write files, it’s important to know where you are. This is the first real difficulty with command line interface: you need to remember where you are.

If you are lost, you can print your working directory (i.e., where you are now, working) with the command.


Like cal, the pwd command return textual information

By default when you log on an Unix system, you are in your HOME directory. Every user (except one) should have it’s home directory in the /home/folder.

To change directory you can type the command cd, cd take one argument: the path of the directory where you want to go. go to the /home directory.

cd /home

The cd command doesn’t return any textual information, but change the environment of the shell (you can confirm it with pwd) ! You can also see this change in your prompt:


What happens when you type cd without any argument ?

What is the location shown in your prompt ? Is it coherent with the pwd information ? Can you cd to the pwd path ?

When we move around a file system, we often want to see what is in a given folder. We want to list the directory content. Go back to the /home directory and use to the ls command see how many people have a home directory there.

We will see various options for the ls command, throughout this course. Try the -a option.

ls -a

What changed compared to the ls command without this option ?

Go to your home folder with the bare cd command and run the ls -a command again. The -a option makes the ls command list hidden files and folders. On Unix systems, hidden files and folders are all files and folders whose name starts with a ..

Can you cd to . ?

cd .

What happened ?

Can you cd to .. ?

cd ..

What appended ?

Repeat 3 times the previous command (you can use the upper directional arrow to repeat the last command).

What append ?

You can use the -l option in combination with the -a option to know more about those folders.

We have seen the commands :

  • cal for calendar
  • cd for change directory
  • ls for list directory
  • pwd for print working directory

You can now go to the Unix file system.

License: Creative Commons CC-BY-SA-4.0.
Made with Quarto.