Worked solution

Administration et gestion des systèmes GNU/Linux

This document presents a set of exercises on GNU/Linux system administration and management, designed to test knowledge and practical skills in system configuration, file systems, user management, quotas, and command usage. Exercice 1 This exercise covers fundamental concepts about GNU/Linux system components, commands, and configurations. 1. What is the role of a Swap partition in GNU/Linux?

Based on the document Administration et gestion des systèmes GNU/Linux

This article was generated from the source document, then verified before publication.

Administration et gestion des systèmes GNU/Linux

Source document

Administration et gestion des systèmes GNU/Linux

Systèmes d'exploitation et administration Linux · PDF · 6 pages · 2000

Show document preview

View the original document

This document presents a set of exercises on GNU/Linux system administration and management, designed to test knowledge and practical skills in system configuration, file systems, user management, quotas, and command usage.

Exercice 1

This exercise covers fundamental concepts about GNU/Linux system components, commands, and configurations.

1. What is the role of a Swap partition in GNU/Linux?

The Swap partition acts as an extension of the RAM by providing a designated space on the hard disk where memory pages can be copied when the RAM is overloaded. This process is called swapping. It helps to manage memory overflow by increasing the effective memory available to the system.

Answer: The Swap partition extends the RAM by providing disk space to hold memory pages when RAM is full, thus preventing memory overload.

2. What are the advantages of the SystemD startup system?

SystemD offers several improvements over traditional init systems:

  • Manages and starts services using sockets and buses, enabling better parallelization of interdependent services.
  • Uses cgroups to track service processes beyond just PIDs, maintaining control even if daemons duplicate.
  • Provides greater parallelization, often reducing boot time significantly (e.g., from over 10 seconds to about 1 second).
  • Allows mounting and unmounting of mount points.
  • Implements a transactional dependency management system for services.

Answer: SystemD improves service management with socket/bus activation, cgroups tracking, faster parallelized startup, mount point control, and transactional dependency handling.

3. Give three characteristics of the ext4 file system.

  • Supports volumes up to 1 exbibyte (2^60 bytes).
  • Uses extent-based allocation to pre-allocate contiguous zones for files, reducing fragmentation; extent is enabled by default since Linux kernel 2.6.23.
  • Maintains backward compatibility with ext3.
  • Offers improved performance compared to ext3, ReiserFS 3, and XFS.

Answer: ext4 supports very large volumes, uses extent allocation to minimize fragmentation, is backward compatible with ext3, and provides better performance than ext3, ReiserFS 3, and XFS.

4. Given the line: mp2l:x:15:0:administrator:/root:/usr/sbin/nologin

a. From which file does this line come?

This line is from the /etc/passwd file, which stores user account information.

b. What is the precise meaning of the following fields?

FieldValueMeaning
Account namemp2lName of the user account
UID15User ID number
GID0Group ID number
GroupadministratorUser's group name
Home directory/rootUser's personal directory
Default shell/usr/sbin/nologinShell assigned to user (nologin disables shell access)

Answer: The line is from /etc/passwd. The fields represent account name (mp2l), UID (15), GID (0), group (administrator), home directory (/root), and default shell (/usr/sbin/nologin).

5. What does the /home directory contain?

The /home directory contains the personal data and directories of users.

Answer: /home stores user data directories.

6. What does the command quotacheck –auvg do?

This command checks the disk quotas for all mounted file systems and updates the quota files accordingly.

Answer: It verifies and updates user quotas on all file systems.

7. What is the purpose of the /etc/skel directory?

/etc/skel contains template files and directories that are copied to a new user's home directory when the user account is created.

Answer: /etc/skel provides templates for new user home directories.

8. Given the directory listing: drwxrwxrwt 15 root root 4096 mai 23 08:30 MP2L

a. Explain the meaning of the fields and the permissions on this directory.

  • drwxrwxrwt: Directory (d) with permissions rwxrwxrwt, meaning read, write, execute for owner, group, others, plus the sticky bit (t).
  • 15: Number of hard links to the directory.
  • root: Owner of the directory.
  • root: Group owner of the directory.
  • 4096: Size in bytes.
  • mai 23 08:30: Date and time of last modification.
  • MP2L: Directory name.

The sticky bit means that only the owner of a file within this directory can delete or rename the file, even if others have write permission on the directory.

b. What numeric value should be passed to chmod to set these permissions?

The numeric mode is 1777, where 1 sets the sticky bit and 777 sets full permissions for owner, group, and others.

Answer: The directory has permissions rwxrwxrwt (sticky bit set), 15 links, owned by root:root, last modified May 23 08:30. Use chmod 1777 MP2L to set these permissions.

9. Which command creates a file system on a partition? Give an example with ext4.

The command mkfs is used to create a file system. For ext4, an example is:

mkfs.ext4 /dev/sda4

Answer: Use mkfs.ext4 /dev/sda4 to create an ext4 file system on /dev/sda4.

10. Which command shows disk space used and free?

The command df displays disk space usage and free space on mounted file systems.

Answer: Use df to check disk space usage and availability.

11. Which command checks the integrity of a file system?

The fsck command checks and repairs file system integrity. Example:

fsck -t ext3 /dev/sda4

Answer: Use fsck -t ext3 /dev/sda4 to check an ext3 file system on /dev/sda4.

12. Which file does the command mount -a use to mount file systems?

The mount -a command mounts all file systems listed in the /etc/fstab file.

Answer: /etc/fstab is used by mount -a.

13. Which command and option initialize the quota database?

The command is:

quotacheck –avug

This scans all file systems with quotas enabled and updates quota files.

Answer: Use quotacheck –avug to initialize quota databases.

14. Explain the concepts of quota, soft limit, and hard limit in GNU/Linux.

  • Quota: A system to control disk space usage by setting limits per user or group.
  • Soft limit: A threshold that users can exceed temporarily; warnings are issued when exceeded. If exceeded beyond a grace period, it acts like a hard limit.
  • Hard limit: An absolute limit that users cannot exceed; writing beyond this is prohibited.

Answer: Quotas limit disk usage. Soft limits allow temporary exceedance with warnings; hard limits are absolute and prevent further writes.

15. How to add /opt/lib to the system-wide library path in two steps?

  1. Add the path /opt/lib to the file /etc/ld.so.conf.
  2. Run the command ldconfig to update the dynamic linker cache.

Answer: Edit /etc/ld.so.conf to include /opt/lib, then execute ldconfig.

16. What is the role of the syslogd process?

The rsyslogd daemon records system activities such as kernel messages, warnings, and debug information. Its configuration file /etc/syslog.conf specifies where messages from various sources and severity levels are logged.

Severity levels include debug, info, notice, warning, err, crit, alert, and emerg.

Answer: syslogd (rsyslogd) logs system messages according to rules in /etc/syslog.conf, organizing messages by source and severity.

17. Where are user crontab files stored in Ubuntu GNU/Linux?

User crontab files are stored in the directory:

/var/spool/cron/$USER

where $USER is the username.

Answer: Crontab files are in /var/spool/cron/$USER.

18. What do the options noauto and sync mean in /etc/fstab?

  • noauto: The file system is not mounted automatically at boot (default behavior).
  • sync: All input/output operations are done synchronously.

Answer: noauto prevents automatic mounting; sync forces synchronous I/O operations.

19. Explain the meanings of the following special permissions: SETUID, SGID, and Sticky Bit.

  • SETUID (4000): For executable files, the process runs with the permissions of the file owner.
  • SGID (2000): For executables, the process runs with the group permissions of the file owner. For directories, new files inherit the directory's group.
  • Sticky Bit (1000): For executables, the process remains in memory for faster loading. For directories, only the file owner can delete or rename files.

Answer: SETUID runs executables with owner's permissions; SGID runs with owner's group permissions and sets group inheritance on directories; Sticky Bit restricts file deletion in directories to owners and keeps executables in memory.

Exercice 2

This exercise focuses on partition management, file systems, and disk quotas.

1. Which is better: using /home as a directory under root or as a separate partition?

Using a separate partition for /home is better because it simplifies management tasks such as backups and system updates, and enhances security.

Answer: A separate /home partition is preferable for easier management and better security.

2. Name three file systems that can be used for a separate /home partition.

Possible file systems include NTFS, extended (ext3/ext4), and FAT.

Answer: NTFS, extended, FAT.

3. What command formats the /home partition (/dev/sda3) with ext4?

Two equivalent commands are:

mkfs -t ext4 /dev/sda3
mkfs.ext4 /dev/sda3

Answer: Use either mkfs -t ext4 /dev/sda3 or mkfs.ext4 /dev/sda3.

4. Explain the quota mechanism and the soft and hard limits.

Disk quotas limit the space a user or group can use. The soft limit is a threshold that can be temporarily exceeded with warnings; if exceeded beyond a grace period, it acts like the hard limit. The hard limit is an absolute maximum that cannot be exceeded; writes beyond it are denied.

Answer: Quotas control disk usage by setting soft limits (temporary, warnable) and hard limits (absolute, enforced).

4b. In which configuration file must quotas be specified?

Quotas must be enabled in the /etc/fstab file.

Answer: /etc/fstab

4c. What command sets quotas for a user named "utilisateur1"?

The command to edit quotas for a user is:

edquota -u utilisateur1

This opens a text editor to modify quota values.

Answer: Use edquota -u utilisateur1.

4d. How can the administrator activate quotas at system startup?

First, enable usrquota and grpquota options in the /etc/fstab entry for the partition, for example:

/dev/sda3 /home ext4 defaults,rw,usrquota,grpquota 0 0

Then activate quotas with the command:

quotaon

Answer: Enable usrquota and grpquota in /etc/fstab and run quotaon at startup.

Exercice 3

This exercise addresses user creation, log management, software installation, and backup strategies.

1. Command to create user "user1" with home directory /home/documents/user1 and shell /bin/sh?

The command is:

useradd -d /home/documents/user1 -s /bin/sh user1

Answer: useradd -d /home/documents/user1 -s /bin/sh user1

2. Which directory contains most log files on the server?

The directory is:

/var/log

Answer: /var/log

3a. Explain the purpose of these installation commands:

gunzip finadmin.tar.gz
tar -xvf finadmin.tar
make install
make maconfig
  • gunzip finadmin.tar.gz: decompresses the gzip archive.
  • tar -xvf finadmin.tar: extracts the tar archive contents.
  • make install: compiles and installs the software.
  • make maconfig: likely runs configuration steps for the software (possibly a typo of "make config").

Answer: Decompress archive, extract files, install software, then configure it.

3b. How to make the software installed in /opt/logiciels/finadmin accessible from any location?

Append the directory to the PATH environment variable:

PATH=$PATH:/opt/logiciels/finadmin

Answer: Use PATH=$PATH:/opt/logiciels/finadmin.

4a. What aspects should be considered when planning data backups?

  • Backup frequency.
  • Available storage space for backups.
  • Criticality of data to be backed up.

Answer: Consider backup frequency, storage space, and data importance.

4b. What backup solutions exist?

  • Incremental backup.
  • Full backup.
  • Physical backup.
  • Partition image backup.
  • Bare metal backup.

Answer: Incremental, full, physical, partition image, and bare metal backups.

4c. Differences between backup, synchronization, and RAID?

  • Backup: Stores copies of files to restore data after loss or damage.
  • Synchronization: Keeps two files or directories identical, often between computers, useful for collaboration.
  • RAID: Storage virtualization spreading data across multiple disks to improve performance, security, or fault tolerance.

Answer: Backup preserves data copies; synchronization keeps data identical across locations; RAID distributes data for performance or redundancy.

Exercice 4 - Multiple Choice Questions (QCM)

This section tests knowledge of commands, permissions, and system concepts through multiple-choice questions.

  1. What permissions does chmod 1777 set on a directory?
    • Answer: D. It allows all users to create files but only owners can delete or modify their own files (sticky bit effect).
  2. Which command formats a partition as ext4?
    • Answer: C. mkfs.ext4
  3. Which command shows disk usage of /usr/REP?
    • Answer: A. du -hs /usr/REP
  4. What is true about the command locate?
    • Answer: B. It is more efficient than find because it uses an index.
  5. Which command locks the account cpte1?
    • Answer: B. usermod -L cpte1
  6. Which file provides the initial environment for all users?
    • Answer: C. /etc/skel
  7. How to install the RPM package monprog-1.i386.rpm?
    • Answer: B. rpm -i monprog-1.i386.rpm
  8. What permissions should /usr/bin/passwd have?
    • Answer: A. 4511 (setuid bit set)
  9. How to view disk quota details?
    • Answer: A. repquota -a
  10. Which command shows free space on a mounted partition?
    • Answer: C. df
  11. What does useradd -f 5 med specify?
    • Answer: A. 5 days before account expiration.
  12. What does the -o option do in groupadd?
    • Answer: B. Allows assigning an existing GID.
  13. If a file has no group or other rights but the directory has write rights for group, who can delete the file?
    • Answer: B. The owner and group members of the directory.
  14. Where is the bash shell command history stored?
    • Answer: C. .bash_history
  15. How to set the sticky bit on /tmp?
    • Answer: D. chmod o+t /tmp
  16. What happens immediately after kernel loading during GNU/Linux boot?
    • Answer: A. Loading of initial ramdisk.
  17. How to delete a crontab entry?
    • Answer: C. crontab -r
  18. How to find configuration files of the rpm package "postfix"?
    • Answer: A. rpm -qc postfix
  19. How to check if a package is installed?
    • Answer: A. rpm --list rpmname

Method

This exam rewards clear knowledge of GNU/Linux system administration commands, file system concepts, user and group management, and system configuration files. Successful answers demonstrate precise command syntax, understanding of system processes, and the ability to interpret file permissions and system logs.

Common mistakes penalized include:

  • Confusing command options or syntax.
  • Misinterpreting file permission bits or special modes.
  • Omitting intermediate reasoning steps or explanations.
  • Failing to distinguish between similar concepts such as soft and hard limits, or backup vs synchronization.

Careful reading of questions and adherence to the source's terminology and conventions is essential for full credit.

All study guides