Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

LINUX

Composition de Linux 2019-2020 :

Part one :

1.) Draw the directories structure ans indicate the number of directory level :

We have four directory level.

2.) Create the subdirectories of ODILI directory with one command line

~$ mkdir OBI

~$ mkdir MUSA

~$ mkdir MUSA/EDNA

~$ mkdir MUSA/ELSI

~$ mkdir JOHN

~$ mkdir JOHN/COCO

~$ mkdir NANGA

~$ mkdir NANGA/ACHEBE

~$ mkdir NANGA/CYPRIAN

~$ mkdir NANGA/CYPRIAN/JACK

3.) Go to EDNA directory.

~$ cd MUSA/EDNA

... EDNA$

4.) Then go to JACK directory

... EDNA$ cd ODILI/NANGA/CYPRIAN/JACK

Ou
... EDNA$ cd ~/NANGA/CYPRIAN/JACK

... JACK$

5.) Then go to CYPRIAN directory.

... JACK$ CD ~/NANGA/CYPRIAN

... CYPRIAN$

Ou

... JACK$ cd ..

... CYPRIAN $

6.) Go to ACHEBE directory.

... CYPRIAN$ ~/NANGA/ACHEBE

... ACHEBE$

7.) Display the path to active directory

... ACHEBE$ pwd

8.) Create with command cat a file that contains the sentence “ ODILI has a
monkey ” and name that file “monkey”

... ACHEBE$ cat > monkey

ODILI has a monkey ( Write now )

CTRL+D ( arrêter la création du fichier ).

9.) Copy the monkey file in your login directory and name it “ domestic ”.

... ACHEBE$ cp monkey ~/domestic

10.) Copy the monkey file in MUSA directory :


... ACHEBE$ cp monkey ~/MUSA

11.) Copy the monkey file of ACHEBE directory in ELSI directory :

... ACHEBE$ cp monkey ~/MUSA/ELSI

12.) Rename the file in ELSI directory EMEKE.

... ACHEBE$ mv ~/MUSA/ELSI/monkey ~/MUSA/ELSI/EMEKE

... ACHEBE$

13.) Delete the domestic file

... ACHEBE$ rm ~/domestic

... ACHEBE$

14.) Return to your login directory :

... ACHEBE$ cd

15.) Move the CYPRIAN directory to the MUSA directory.

~$ mv ~/NANGA/CYPRIAN ~/MUSA

~$

16.) Delete with one command line the subdirectories of ODILI.

~$ rm -r OBI MUSA JOHN NANGA

Part two :

Analyze and comment the following commands :

1.) cat > essai.txt

It's used to create the file essai.txt

2.) cat essai.txt


It's used to display the content of essai.txt

3.) sort essai.txt

It's used also to display the content of essai.txt but create a space without the last
line and the file’s content.

4.) cat >> essai.txt

It's used to add the content to file essai.txt if it's created before, otherwise the file
will be created.

Composition de Linux 2020-2021 :

Enter the command that accomplishes the result :

NB: Linux prompt is $ at the beginning of the work session.

In which directory am I ?

~$ pwd

I copy the file /etc/passwd in the current directory and I name the copy
mot_de_passe.

$ cp /etc/passwd ~/mot_de_passe

I copy the files /etc/group and /etc/profile in the current directory, I preserve the
original name.

~$ cp -r /etc/group /etc/profile ~

I display the files that are present in the directory.

~$ ls

I list the files by displaying their attributes.

~$ ls -l
Display the first lines of the /etc/services file.

~$ head /etc/services

Display the last lines of the /etc/services files.

~$ tail /etc/services

Display the lines of the /etc/services file that contain the string ‘’HTTP”

~$ grep HTTP /etc/services

Redirect the result of the command cal in a file named cal.txt

~$ cal > cal.txt

Redirect the result of the command date in the file cal.txt (of question 9) :

~$ date > cal.txt

- What happened ?

I happened that when we have redirected the result of the command date in the
file cal.txt, the precedent content of this file has deleted.

Add the result of command date to cal.txt.

~$ date >> cal.txt

Go to the /bin directory :

~$ cd /bin

~/bin$ …

We display the commands that begin by a in the /bin directory.

~/bin$ ls a*

We display the commands that contain 5 characters.

~/bin$ ls ?????
We display the commands beginning by w, or by x, or by y, or by z.

~/bin$ ls [wxyz]

We don’t display the commands beginnings by a letter contained between a and


v.

~/bin$ ls [!a-v]

We return to the login directory :

~/bin$ cd

~$ …

Create a directory named reptest :

~$ mkdir reptest

Go to reptest directory :

~$ cd reptest

~/reptest$ …

Display the attributes of current directory :

~/reptest$ ls -ld

Create a file named obi that contains the sentence "echo hy !"

~/reptest$ cat > obi

echo hy !

CTRL + D to stop the writing.

When we display the attributes of obi file, we obtain the following result :

-rw-rw-r--

Can you make that your fellows can execute this file.
~/reptest$ chmod g+x obi

The result of question 20 is the following :

drwxrwxr--

Can you make that the others can delete obi file.

~/reptest$ chmod o+w obi

Can you make that your fellows can read and execute this obi file (absolute rights
or permissions).

~/reptest$ chmod g+rx obi

Make a hard link named obi1 to obi file.

~/reptest$ ln obi obi1

Display the inode of obi file.

~/reptest$ ls -i obi

Make a symbolic link obi2 to obi file.

~/reptest$ ln -s obi obi2

Delete obi file

~/reptest$ rm obi

Display the content of reptest. What happened to obi1 and obi2 files ? Explain.

~/reptest$ ls

We happened now that obi1 and obi2 files don't operate. It's because of the fact
that obi1 and obi2 are the links that allow to accede to the content of obi file. But,
obi file has been deleted. Thus, obi1 and obi2 aren't functionnal.

Return to your account.

~/reptest$ cd
~$ ...

You might also like