Short Introduction to the Command Line

(Note: this tutorial is only valid if you work on MacOS or Linux. If you are on Windows, you may skip to the next chapter)

Development for server programming requires to start local servers in specific directories. The actions required to run these servers may vary depending on the OS and usually involves the use of the command line.

Notion of terminal and shell

To start the server with the expected options, we will use some command lines. Command lines is a general way to execute and pass arguments to programs. Command lines are usually written in a terminal emulator (or simply called terminal) allowing to interactively enter and execute the written commands (similar to lines of codes).

Every line entered in the terminal is interpreted by a command interpretor (also called shell) that will try to execute the commands. The shell commands can be viewed as a programming language in itself. There exists several shells, the most common one on Linux system is called bash. (Mac computers also have access to the bash shell. Windows however uses a different syntax).

pic/terminal.png

Example of terminal

Current working directory

The command line entered in a terminal is locally executed in the context of a local directory. By default, the terminal is open in the root of the current user directory called home.

Note on directory structure in Linux

Special symbols for specific directory

Examples

Rem.

Creating/removing directory

ex./

mkdir my_directory
ls
cd my_directory
pwd
mkdir subdirectory
ls
cd subdirectory
pwd
cd ..
pwd
cd ..
ls
rm -r my_directory
ls

Manual of a command

Each Linux command can usually be called using multiple options. These options are documented in the so called man pages (=Manual).

Example to read the documentation about the command `ls`

man ls