Knowledge base dedicated to Linux and applied mathematics.
Home > Linux > Tutorials > Introduction to Linux
All the versions of this article: <English> <français>
Following is a short introduction to Linux. We shall encounter some buzz words such as terminal, command line and other utilities. Have fun!
Early in the 90’s, a young Finnish student named Linus Benedict Torvaldsa wanted to set up his own Operating System (OS). The idea consisted of developing a Unix-type system with 80386 processors (or, a PC, to put it simple). Andrew Tanenbaum created Minix, a basic system compatible with the 80386’s. This is how Linus B. Torvaldsa decided to improve the project by extending the capabilities of Minix: Linux was born. The kernel (the system core), numbered 0.1, was made available in 1991. But it was only in 1992 that the stable version was finally out. What makes this system original is the fact that it is non commercial and many developers participate in this project.
Today, many distributions exist:
Debian, Fedora, Freebsd, Gentoo, Knoppix, Mandriva(merge between Conectiva and MandrakeSoft), Redhat, Suse, Slackware, Ubuntu , and so on so forth. There is a wide selection ! Note that if you start using Linux, opt for Mandrake or d’une Knoppix. This latter does not even require installation!
The console or terminal is text environment in which the user launch programs to be executed or sends requests. There are several types of consoles: terminal, xterm, konsole, gnome-console, virtual terminals, etc. The virtual terminals are launched via the command CTRL+ALT+F1, CTRL+ALT+F2, CTRL+ALT+F3, etc ... The console shown below is a gnome-terminal.
is what we call a prompt, nadir is the (user) and ipowerht is the name of the machine. The tilde ˜ refers to the current directory of the user; i.e. /home/nadir Alternatively stated, the prompt shows clearly in which directory we are. In our case, we are in /home/nadir/Desktop/these. As for the dollar sign, $, it means that we are under the control of the command interpreter: the shell BASH. So what is BASH exactly? It is nothing else than a program /bin/bash which interprets the commands you type and executes them, as long as there are not erroneous. In particular, BASH is case sensitive: a lower case is not the same as an upper case !
We previously mentioned that the tilde ˜ represents /home/nadir. Obviously, if the user is Astozzia, the tilde on the console will represent /home/astozzia. Each user has a subdirectory in /home. A better image to understand this concept is to imagine that all users live in /home and each of them has their own "room": that of nadir is /home/nadir, that of astozzia is /home/astozzia. Obviously, astozzia cannot enter nadir’s room since this latter is private. And vice versa. However, nadir can share a part of his room with astozzia, as we shall see later.
This command is a must !!! ’man’ is an abbreviation of manual. Practically, we type
nadir@ipowerht:~/Desktop/these $ man ls
The console will display a lot of info on the ls command. We can ask for condensed help as follows:
nadir@ipowerht:~/Desktop/these $ ls --help
ls lists the contents of a directory
nadir@ipowerht:~/Desktop/these $ ls chapters these.mtc these.mtc6 thloria.cls CRfem.aux these.mtc1 these.pdf tlfloat.sty figures these.mtc2 these.ps tlhypref.sty these.bmt these.mtc3 these.tex tlnatbib.sty these.dvi these.mtc4 these.tex~ TL-user.pdf these.flg these.mtc5 these.tex.backup
It is possible to use several options with the ’ls’ command. See the manual ! We shall mention the -l option
nadir@ipowerht:~/Desktop/CV $ ls -l total 96 -rw-r--r-- 1 nadir nadir 8 2005-03-29 11:08 cvnadir.aux -rw-r--r-- 1 nadir nadir 4488 2005-03-29 11:08 cvnadir.dvi -rw-r--r-- 1 nadir nadir 4514 2005-03-29 11:08 cvnadir.log -rw-r--r-- 1 nadir nadir 63856 2005-03-29 11:08 cvnadir.pdf -rw-r--r-- 1 nadir nadir 6778 2005-03-29 11:08 cvnadir.tex
A few comments:
– total 96 means that the directory named CV occupies 96 blocks
– the first column gives information on the rights ;
– the second shows the number of links pointing to this file ;
– the following column shows the name of the file owner ;
– the fourth column shows the name of the group who can have access to this file according to the actions authorized by the owner. If you remember, it is what we referred to as file sharing between nadir and astozzia ;
– the fifth column shows the size of the file in bytes.
– the sixth gives the date and time of the last modification of the file.
– the last column refers to the name of the file.
This command gives the path to the directory in which we are
nadir@ipowerht:~/Desktop/CV $ pwd /home/nadir/Desktop/CV
cd as in Change Directory.
To change to the top-level or root directory of the system
nadir@ipowerht:~/Desktop/CV $ cd /
To change to the var directory of the root directory
nadir@port-soualem:/$ cd /var
To change to the current directory www
nadir@port-soualem:/var$ cd www
To change to the /usr/bin directory
nadir@port-soualem:/var/www$ cd /usr/bin/
To go to the parent directory
nadir@port-soualem:/usr/bin$ cd ..
To change to my personal home directory
nadir@port-soualem:/usr$ cd ~
To change to the home directory of astozzia
nadir@port-soualem:~$ cd ~jean
This command creates a directory: Make Directory
nadir@ipowerht:~/Desktop/CV $ mkdir Photos /
will create a subdirectory called Photos in the directory /Desktop/CV
This command copies files. To copy the file ’cvnadir.tex’ in ’cv.tex’ (Duplication), we type:
nadir@port-soualem:/$ cp cvnadir.tex essai.txt
To copy the file’ cvnadir.tex’ in the directory /Desktop/CV
nadir@port-soualem:/$ cp cvnadir.tex ~/Desktop/CV
To copy files from the directory ’analysis’ into the directory ’algebra
nadir@port-soualem:/$ cp analysis/ algebra/
To copy all files from the directory ’analysis’ — including all subdirectories — in the directory ’algebra’
nadir@port-soualem:/$ cp -R analysis/ algebra/
The command mv renames a file or moves it to a new location. The following command for example renames the file ’cvnadir.tex’ into ’cv.tex’
nadir@port-soualem:/$ mv cvnadir.tex cv.tex
To move the file ’cv.tex’ into the directory ’/home/nadir/fac’, we proceed as follows:
nadir@port-soualem:/$ mv cv.tex /home/nadir/fac
This command displays the contents of a file
nadir@port-soualem:/$ cat note.txt Mean:=08/20; Min:=01.5/20; Max:=15/20;
If you have 2 files file1, file2
nadir@port-soualem:/$ cat file1 file2
will display the contents of the two files: this is called ’concatenation’. This can be generalized to more than 2 files.
When files have a large size, the cat command is not convenient since the text scrolls very fast. The command ’less’ displays the file content little by little.
nadir@port-soualem:/$ less cv.tex
rm as in Remove. This command removes files.
nadir@port-soualem:/$ rm cv.tex
will remove the file ’cv.tex’. We can also remove the contents of a directory:
nadir@port-soualem:/$ rm -R analysis/
will remove all files and subdirectories of the directory ’analysis’ as well as the directory ’analysis’ itself.
rmdir as in Remove Directory. This command removes empty directories.
nadir@port-soualem:/$ rmdir CANUM05/
To sum up, you will find below an index of the commands we have seen so far. Click on any of them to be directed to the explanation.