Labs and Mini-Project For Linux
Labs and Mini-Project For Linux
Administration of Linux
1. Basic commands
- List the content of the current directory , and the content of folder1. backup (copy)
folder1 directory to folder2. Remove folder1 and then rename folder2 to folder1.
- Go to folder1/noyau/ , then used pwd -P to print the current directory. Use cd ? to go
back in the previous directory.
- Print the /var/log/X.0.log file with the cat , more , less , tail and head command. Quickly
explain the difference between each command.
- On a first terminal, use the auto refresh of the tail command to display the file
/var/log/auth. Then log into another terminal and observe file's modifications on the first
terminal.
- Display all lines of the /var/log/messages which contains the word « usb ».
- Create a file name A Great File. Then remove it using the rm command and Bash
completion . Look closely at the syntax used by Bash .
Page 1 / 31
Administration of Operating Systems :
Administration of Linux
2. Introduction to shell
In this practical test, you will learn to:
7.1.Use the shell, discover autocompletion
7.2.Configure your prompt and login actions
7.3.Find help
7.4.Create aliases
7.5.Play with input/output redirections
- Find some help on the find command. You want to know wich option is used to search
by modification time.
- You don't remember the syntax of ln , to create a link. Does the destination must be
the first or the second argument ? Find some quick help !
- You never remember the command that find files that were created or modified the
previous 3 days in your home directory. Write an alias to make it easier and to
remember well.
- Use the alias you've just created in order to write the list of the files created or
modified the previous 3 days in a file called "recent_documents.txt".
Page 2 / 31
Administration of Operating Systems :
Administration of Linux
Note : To quickly logout the user of a shell session , there is a useful shortcut Ctrl + D . This
shortcut is equivalent to type exit command.
- Modify the /etc/passwd file and set the shell of redhat to /bin/false .
Note : We can also edit the files /etc/passwd and /etc/group an delete the concerned lines.
Page 3 / 31
Administration of Operating Systems :
Administration of Linux
4. Permission management
During this practice we will
learn to:
Change permissions
- Create a file named « toto » and a folder « foo ». What are the permissions by default ?
- Create a file named toto2 and a folder named foo2 , what are the permissions?
- Set read/write/execute access for the owner, read/execute for the group and read for the
others on the file toto . Use letters first, then octal permissions.
- Try to shutdown the system as redhat user by using the shutdown -h now command then
/sbin/shutdown -h now . Why shutdown does not function without using
the full path ?
- Make so that a normal user can shutdown the system by setting SUID on /sbin/shutdown .
Page 4 / 31
Administration of Operating Systems :
Administration of Linux
5. Process Management
During this practice we will learn to:
• Control and kill Processes
• Manage task with atd and crond
- Launch the eyes > /dev/null command and suspend it with a key combination.
- Use the jobs command to see the running "jobs" and their PID for the current shell.
- Open a new terminal and search for the PID, nice number of the precedent command ,
then decrease its priority to 15.
- Now, send the SIGTERM or SIGKILL signal to the yes > /dev/null process and check if it
has been quit .
- Launch the top command to display all current processes 3 times, with an interval
between the refresh of 5 seconds and redirect the output to a file. (have a look at the man)
Page 5 / 31
Administration of Operating Systems :
Administration of Linux
6. Bash Scripting
scripts. Pre-requisites :
- Basic commands
- cut, sed
- Pipes and redirections
- Variables
- Arguments given to script
- Archiving
- Permissions
- Network basics
- FHS organization
- Create a file with text and add "#! /bin/more" at the beginning. Make this file executable
and execute it.
What's happening?
- Create a script that keeps the 20 last lines of the "/var/log/messages" file.
- Modify the previous script to have a customizable line number (passed as parameter).
- Create a script that print the number of process that you have launch.
- Create a script that displays the CPU usage, its speed in MHz and the Ram amount you are
using.
- In a script, using the ls command and it's list function, check if a file exists.
- Create a script that deletes all files of a directory (Be care of the hidden files).
Page 6 / 31
Administration of Operating Systems :
Administration of Linux
Note : Use the date command (To display only hours: date +%H, only
minutes: date +%M). Copy this file in /etc/skel after verifying it works.
Pre-requisites:
- Conditionnal structures
- Loops
- Functions (arguments and return value)
- Network
- Zenity
- Gnuplot
- HTML
Monitoring your computer's internet traffic
Goals
Reaffirm your knowledge of what you have learned about programming shell scripts and using the
Gnuplot program.
The most correct solution will be gratify by +6 points add to the mark of the exam
The almost correct solution will be gratify by +4 points add to the mark of the exam
The half correct solution will be gratify by +2 points add to the mark of the exam
Deadline 01/30/2023
Page 8 / 31