Objectives:: Lab1: Reviewing Command Line Basics
Objectives:: Lab1: Reviewing Command Line Basics
Objectives:: Lab1: Reviewing Command Line Basics
3A46
Objectives:
The main objectives of this first lab are:
Response: An operating system (OS) is the interface between the computer user and the
computer hardware. An operating system is a software that performs all basic tasks such as
file management, memory management, process management, processing input and output,
and controlling peripheral devices (such as disk drives and printers).
Unix Linux
It is a complete OS It’s kernel, it is similar to the Unix kernel
It is paid and proprietary system It is Free
It is refers to the original operating system It is refers to the kernel of the GNU/Linux
developed by AT&T. operating system.
System-V Unix and derivatives like IBM- GNU/Linux and derivates like Debian and
AIX and HP-UX; Berkeley Unix and Fedora.
derivatives like FreeBSD and macOS.
1
Administration & Sécurité des Systèmes d’exploitation Unix Ghofrane FERCHICHI
3A46
Shell
File system
Response:
Response: Linux shell is responsible for the control management, and execution of
processes, and to ensure proper utilization of system resources. It is a program that acts as an
interface between a user and the kernel.
6. What is the minimum number of disk partitions required to install Linux? Quote them
and give the role of each?
Response:
2
Administration & Sécurité des Systèmes d’exploitation Unix Ghofrane FERCHICHI
3A46
SingleUser: Single users are the users created by the root or another user with sudo
privileges. Usually, a normal user has a real login shell and a home directory. They have a
limited access and permissions
SuperUser(root): is used to make system changes and can override user file protection.
root has unlimited powers, and can do anything on system hence the term superuser is
used.
Response:
pwd Command : The pwd command is used to display the location of the current
working directory.
mkdir Command : The mkdir command is used to create a new directory under any
directory.
rmdir Command : The rmdir command is used to delete a directory.
Response: To copy a file named file.txt to a file named file_backup.txt in the current directory:
3
Administration & Sécurité des Systèmes d’exploitation Unix Ghofrane FERCHICHI
3A46
If the destination file exists, it will be overwritten. To get a confirmation prompt before
overwriting the files, use the -i option.
Response:
rmdir command – Deletes the specified empty directories and folders in Linux.
rm command – Delete the file including sub-directories. You can delete non-empty
directories with rm command in Linux.
rmdir directory-name
rmdir [option] directory-name
Character Description
\ To escape / quote a single character;
used to quote <new line> character to
allow continuation of a shell command
on the following line
. Represents the directory you are in
.. Represents the parent directory
~ Special home directory variable
* Match any string of zero or more
characters
? To substitute a wildcard for exactly
one character (match any single
character)
[] matches any occurrence of character
enclosed in the square brackets.
| To create pipe between commands
> To redirect output for a command
>> Appends to a file or creates the file if
it doesn't exist
&& The second command will only
4
Administration & Sécurité des Systèmes d’exploitation Unix Ghofrane FERCHICHI
3A46
5
Administration & Sécurité des Systèmes d’exploitation Unix Ghofrane FERCHICHI
3A46
6
Administration & Sécurité des Systèmes d’exploitation Unix Ghofrane FERCHICHI
3A46
NB: Each question must be answered in one command and the current directory must
always be your personal directory.
(a) Create two directories; named, Unix and Python in your home directory.
(b) Create two directories TP1 and TP2 in the Unix directory.
(c) Copy the two directories TP1 and TP2 to the Python directory.
(d) Create two seance1 and seance2 directories in the Unix TP1Unix directory.
7
Administration & Sécurité des Systèmes d’exploitation Unix Ghofrane FERCHICHI
3A46
(e) Create two files exo1 and exo2 files in the seance1 directory.
(f) Copy the two files exo1 and exo2 into the Python TP2 directory as .exo1 and .exo2
Python/TP2 is empty car les fichiers .exo1 et .exo2 sont des fichiers cachés
6. Move into Python/TP1. Make sure you are tcdThere, and then, using a single command,
move into Unix/TP2 by specifying the relative path.
7. Return to Python/TP1, but this time, using the absolute path. Finally, return to the root of
your home directory.
9. Remove the Python TP2 directory using the rmdir command. Why did the command fail?
Remove TP2 from Python.
8
Administration & Sécurité des Systèmes d’exploitation Unix Ghofrane FERCHICHI
3A46
14. Create a symbolic link on the toto file named "lsymb", at the tmp directory level.
15. Compare the properties of toto and lsymb. What can you deduce from this?
Lsymb have all the privelage (read write and execute), it is pointed on the root
16. If we delete the toto file, will lsymb be available? Explain.
Yes it still available because a symbolic link is a file that points to another file; if you delete
the target file, the symbolic links will point to an inexistan file.
17. Name 3 differences between a physical and a symbolic link.
9
Administration & Sécurité des Systèmes d’exploitation Unix Ghofrane FERCHICHI
3A46
Do not share the same inode with target file. Share the same inode with target file. Hard
Hence symbolic link span across file system link does not span across file system.
Can be used for files and directories Should only be used for files not directories
If target file is deleted, the link will not work If target file is deleted, the link still works
Cut -b 13-
NB:
2. How can the address book be displayed in alphabetical order of first names? Save the result
in the carnet_sort file?
3. Sort the file following reverse alphabetical order and save the result in another file named
reverse_sort.
4. Display the first three people whose first names begin with ‘F’, using the carnet_trie file.
10
Administration & Sécurité des Systèmes d’exploitation Unix Ghofrane FERCHICHI
3A46
5. Write the command that will allow you to determine how many users you have stored in
your address book.
$cat -n telephone.txt
6. Display all users ‘first names that contain any of the letters ‘a’, ‘b’, ‘c’,‘d’ or ‘e’.
11