Plateforme d’entrainement #
1-16. User and Group Management #
Question 1: #
Which command is used to create a new user account in a Red Hat-based system?
A. useradd
B. usermod
C. groupadd
D. userdel
Réponse
Answer: A
Explanation: The `useradd` command is used to create new user accounts. `usermod` modifies existing user accounts, `groupadd` adds groups, and `userdel` deletes user accounts.Question 2: #
How can you set a password for a user when creating the account?
A. passwd -c <username>
B. usermod -p <username>
C. useradd -p <password>
D. passwd <username>
Réponse
Answer: D
Explanation: To set or change a user’s password, you use the `passwdQuestion 3: #
Which command is used to modify an existing user account’s properties?
A. useradd
B. groupmod
C. usermod
D. passwd
Réponse
Answer: C
Explanation:
The usermod
command is used to modify existing user accounts, such as changing their home directory, shell, or other properties.
Question 4: #
How do you delete a user and their home directory?
A. userdel -r <username>
B. useradd -d <username>
C. usermod -r <username>
D. userdel <username>
Réponse
Answer: A
Explanation:
The userdel -r
command deletes the user along with their home directory and mail spool. Without -r
, it will only delete the user account.
Question 5: #
Which file contains the encrypted password for a local user on a Red Hat system?
A. /etc/passwd
B. /etc/group
C. /etc/shadow
D. /etc/sudoers
Réponse
Answer: C
Explanation:
Passwords are stored in /etc/shadow
, which contains encrypted passwords and other security-related information like password expiration.
Question 6: #
Which command would you use to add a user to an existing group?
A. groupadd <groupname> <username>
B. usermod -g <groupname> <username>
C. gpasswd -a <username> <groupname>
D. groupmod -a <username>
Réponse
Answer: C
Explanation:
The correct command to add a user to an existing group is gpasswd -a <username> <groupname>
. The -g
option in usermod
changes the user’s primary group but doesn’t append them to additional groups.
Question 7: #
How can you check the groups a user belongs to?
A. groupmod -l <username>
B. groups <username>
C. usermod -g <username>
D. groupadd <username>
Réponse
Answer: B
Explanation:
The groups <username>
command lists the groups that a specific user is a member of.
Question 8: #
Which command would you use to lock a user account to prevent login?
A. usermod -L <username>
B. passwd -l <username>
C. userdel <username>
D. usermod -l <username>
Réponse
Answer: B
Explanation:
The passwd -l
command locks the user account by disabling the password. usermod -L
locks the account as well, but the commonly used command for this is passwd -l
.
Question 9: #
What is the correct command to unlock a previously locked user account?
A. passwd -u <username>
B. usermod -U <username>
C. passwd -l <username>
D. usermod -L <username>
Réponse
Answer: A
Explanation:
To unlock a user account that was previously locked, use passwd -u
. The usermod -U
command also works but is less commonly used.
Question 10: #
How can you force a user to change their password at the next login?
A. passwd -e <username>
B. passwd -d <username>
C. usermod -p <username>
D. passwd -l <username>
Réponse
Answer: A
Explanation:
The passwd -e
command forces the user to change their password at the next login by expiring the current one.
Question 11: #
Which file contains group membership information?
A. /etc/passwd
B. /etc/shadow
C. /etc/group
D. /etc/sudoers
Réponse
Answer: C
Explanation:
Group information and membership are stored in /etc/group
.
Question 12: #
What does the -G
option in the usermod
command do?
A. Sets the user’s primary group
B. Removes the user from all groups
C. Appends the user to the specified additional groups
D. Creates a new group
Réponse
Answer: C
Explanation:
The usermod -G
option allows you to append a user to additional groups. This does not affect the user’s primary group.
Question 13: #
Which command would you use to change a user’s home directory?
A. usermod -d /new/home <username>
B. usermod -m <username>
C. useradd -d <username>
D. passwd -d <username>
Réponse
Answer: A
Explanation:
The usermod -d /new/home
command changes the user’s home directory to the specified path.
Question 14: #
Which command is used to delete an existing group?
A. groupdel <groupname>
B. groupmod -d <groupname>
C. groupremove <groupname>
D. groupadd -r <groupname>
Réponse
Answer: A
Explanation:
The groupdel
command is used to delete an existing group.
Question 15: #
What happens when you use the command usermod -l <newname> <oldname>
?
A. The user’s group name is changed
B. The user’s account is deleted
C. The user’s login name is changed
D. The user’s home directory is renamed
Réponse
Answer: C
Explanation:
The usermod -l
command changes the user’s login name from <oldname>
to <newname>
.
Question 16: #
Which command would you use to list all the users currently logged into the system?
A. whoami
B. users
C. who
D. usermod
Réponse
Answer: C
Explanation:
The who
command shows all the users currently logged into the system. The users
command also provides this information but in a different format.
17-33. Package Management with dnf
#
Question 17: #
What is the correct command to install a package using dnf
?
A. dnf install <package_name>
B. dnf add <package_name>
C. dnf update <package_name>
D. dnf download <package_name>
Réponse
Answer: A
Explanation:
To install a package using dnf
, use the dnf install
command followed by the package name.
Question 18: #
How do you update all installed packages to the latest version using dnf
?
A. dnf update
B. dnf install
C. dnf upgrade
D. dnf refresh
Réponse
Answer: C
Explanation:
To update all installed packages to their latest version, use dnf upgrade
. dnf update
is a deprecated command but still works in some systems.
Question 19: #
How can you list all the enabled repositories in your system?
A. dnf repolist enabled
B. dnf list repo
C. dnf list repositories
D. dnf show repos
Réponse
Answer: A
Explanation:
The command dnf repolist enabled
shows a list of all currently enabled repositories.
Question 20: #
Which command would you use to remove a package using dnf
?
A. dnf delete <package_name>
B. dnf uninstall <package_name>
C. dnf remove <package_name>
D. dnf purge <package_name>
Réponse
Answer: C
Explanation:
The correct command to remove a package is dnf remove <package_name>
.
Question 21: #
How do you install a specific version of a package using dnf
?
A. dnf install <package_name>-<version>
B. dnf update <package_name>-<version>
C. dnf install --version <version> <package_name>
D. dnf install <package_name>@<version>
Réponse
Answer: A
Explanation:
To install a specific version of a package, use the syntax dnf install <package_name>-<version>
.
Question 22: #
Which command would you use to check for dependencies before installing a package?
A. dnf depcheck <package_name>
B. dnf resolve <package_name>
C. dnf check <package_name>
D. dnf repoquery --requires <package_name>
Réponse
Answer: D
Explanation:
The dnf repoquery --requires <package_name>
command shows the dependencies required for the package.
Question 23: #
How do you clean cached dnf
metadata to ensure fresh package data?
A. dnf refresh-cache
B. dnf clean all
C. dnf purge cache
D. dnf clear-cache
Réponse
Answer: B
Explanation:
To clean cached metadata and packages, use dnf clean all
.
Question 24: #
How do you enable a repository temporarily for a single dnf
command?
A. dnf enable-repo <repo_name>
B. dnf --repo <repo_name>
C. dnf --enablerepo=<repo_name>
D. dnf repolist enable <repo_name>
Réponse
Answer: C
Explanation:
The dnf --enablerepo=<repo_name>
command enables a repository temporarily for one dnf
command.
Question 25: #
Which command allows you to search for a package by keyword in its name or description?
A. dnf find <keyword>
B. dnf search <keyword>
C. dnf query <keyword>
D. dnf list <keyword>
Réponse
Answer: B
Explanation:
The dnf search <keyword>
command searches for a package by keyword in its name or description.
Question 26: #
How do you list all available package groups?
A. dnf group list
B. dnf grouplist
C. dnf group show
D. dnf list groups
Réponse
Answer: A
Explanation:
The dnf group list
command lists all available package groups.
Question 27: #
What is the correct command to install a package group?
A. dnf group install <group_name>
B. dnf groupadd <group_name>
C. dnf group apply <group_name>
D. dnf install <group_name>
Réponse
Answer: A
Explanation:
The correct command to install a package group is dnf group install <group_name>
.
Question 28: #
How do you list all installed packages on the system?
A. dnf list --installed
B. dnf list all
C. dnf info installed
D. dnf show installed
Réponse
Answer: A
Explanation:
The command dnf list --installed
shows all installed packages on the system.
Question 29: #
How can you remove all packages from a package group?
A. dnf group remove <group_name>
B. dnf group delete <group_name>
C. dnf group uninstall <group_name>
D. dnf remove-group <group_name>
Réponse
Answer: A
Explanation:
To remove all packages in a package group, use dnf group remove <group_name>
.
Question 30: #
How can you prioritize a repository over others when using dnf
?
A. Edit /etc/yum.conf
and set the priority
option
B. Use dnf set-priority <repo_name>
C. Set a priority
value in the repository’s .repo
file
D. Use dnf --priority=<number> <repo_name>
Réponse
Answer: C
Explanation:
To prioritize a repository, you must set a priority
value in the repository’s .repo
file (usually in /etc/yum.repos.d/
).
Question 31: #
Which command shows detailed information about a specific package?
A. dnf info <package_name>
B. dnf describe <package_name>
C. dnf list <package_name>
D. dnf query <package_name>
Réponse
Answer: A
Explanation:
The dnf info <package_name>
command provides detailed information about the specified package, including version, repository, and architecture.
Question 32: #
How can you view the changelog of a package using dnf
?
A. dnf changelog <package_name>
B. dnf log <package_name>
C. dnf history <package_name>
D. dnf check <package_name>
Réponse
Answer: A
Explanation:
The dnf changelog <package_name>
command shows the changelog of a package, including version changes, bug fixes, and new features.
Question 33: #
How do you rollback a recent package update in dnf
?
A. dnf undo <transaction_id>
B. dnf history undo <transaction_id>
C. dnf rollback <transaction_id>
D. dnf revert <transaction_id>
Réponse
Answer: B
Explanation:
To rollback a recent update, use dnf history undo <transaction_id>
.
34-49. Managing File System Permissions #
Question 34: #
What permission is represented by the following: rwxr-xr--
?
A. Read, write, and execute for the owner; read and execute for the group; read only for others
B. Read, write, and execute for the owner and group; read only for others
C. Read, write, and execute for the owner; read and write for the group; no permission for others
D. Read and write for the owner and group; no permission for others
Réponse
Answer: A
Explanation:
The owner has read, write, and execute permissions (rwx); the group has read and execute permissions (r-x); others have read only (r–).
Question 35: #
How do you change the ownership of a file to a different user?
A. chown <file_name> <user>
B. chmod <user> <file_name>
C. chown <user> <file_name>
D. chgrp <user> <file_name>
Réponse
Answer: C
Explanation:
Use the chown <user> <file_name>
command to change the ownership of a file to a different user.
Question 36: #
Which command is used to change the group ownership of a file?
A. chmod
B. chgrp
C. chown
D. getfacl
Réponse
Answer: B
Explanation:
The chgrp
command is used to change the group ownership of a file or directory.
Question 37: #
What special permission allows regular users to execute a file with the permissions of the file’s owner?
A. SGID
B. SUID
C. Sticky bit
D. ACL
Réponse
Answer: B
Explanation:
The SUID (Set User ID) bit allows a user to execute a file with the permissions of the file’s owner.
Question 38: #
Which command is used to set special permissions (SUID, SGID, Sticky bit) on a file?
A. chown
B. chgrp
C. chmod
D. setfacl
Réponse
Answer: C
Explanation:
The chmod
command is used to set the SUID, SGID, or sticky bit on a file using symbolic or octal notation.
Question 39: #
How do you add write permission for the group on a file?
A. chmod g+w <file_name>
B. chmod g+r <file_name>
C. chmod o+w <file_name>
D. chown g+w <file_name>
Réponse
Answer: A
Explanation:
The chmod g+w <file_name>
command adds write permission for the group.
Question 40: #
What is the octal representation of the permission rwxr-xr-x
?
A. 755
B. 644
C. 777
D. 744
Réponse
Answer: A
Explanation:
The owner has full permission (7 = rwx), the group has read and execute permissions (5 = r-x), and others also have read and execute permissions (5 = r-x). Thus, it’s 755.
Question 41: #
How do you recursively change the ownership of a directory and all its contents?
A. chown -R <user> <directory>
B. chown <user> <directory>
C. chmod -R <user> <directory>
D. chgrp -R <user> <directory>
Réponse
Answer: A
Explanation:
The -R
option in chown -R <user> <directory>
applies the change recursively to all contents within the directory.
Question 42: #
What does the sticky bit do when applied to a directory?
A. It allows users to delete any file in the directory.
B. It prevents users from executing files in the directory.
C. It allows only the file owner to delete or modify their own files in the directory.
D. It allows users to change permissions of files in the directory.
Réponse
Answer: C
Explanation:
The sticky bit, when set on a directory, allows only the file owner to delete or modify their own files, even if others have write permissions on the directory.
Question 43: #
What is the correct command to view the current ACLs for a file?
A. getfacl <file_name>
B. showacl <file_name>
C. lsacl <file_name>
D. aclshow <file_name>
Réponse
Answer: A
Explanation:
The getfacl <file_name>
command shows the Access Control List (ACL) entries of the specified file.
Question 44: #
How do you remove write permission for others on a file?
A. chmod o-w <file_name>
B. chmod g-w <file_name>
C. chown o-w <file_name>
D. chmod o+r <file_name>
Réponse
Answer: A
Explanation:
The chmod o-w <file_name>
command removes write permission for others.
Question 45: #
What is the octal representation for the permission rwxr--r--
?
A. 755
B. 644
C. 744
D. 655
Réponse
Answer: C
Explanation:
The owner has full permission (7 = rwx), the group has read-only permission (4 = r–), and others have read-only permission (4 = r–), making the octal code 744.
Question 46: #
How do you grant read and write permissions to a specific user using ACL?
A. setfacl -m u:<user>:rw <file_name>
B. chmod u+rw <file_name>
C. chown u+rw <file_name>
D. setfacl -m rwx <user> <file_name>
Réponse
Answer: A
Explanation:
The setfacl -m u:<user>:rw <file_name>
command adds read and write permissions for a specific user using ACLs.
Question 47: #
What does the SGID (Set Group ID) bit do when set on a directory?
A. It gives all users write access to the directory.
B. Files created in the directory will inherit the group ownership of the directory.
C. It allows any user to delete files in the directory.
D. It sets the directory to be executable by all users.
Réponse
Answer: B
Explanation:
When the SGID bit is set on a directory, all files created inside will inherit the group ownership of the directory instead of the primary group of the user who created the file.
Question 48: #
Which command recursively applies permissions to all files and directories within a given directory?
A. chmod -R <permissions> <directory>
B. chmod <permissions> <directory>
C. chown -R <permissions> <directory>
D. chgrp -R <permissions> <directory>
Réponse
Answer: A
Explanation:
The chmod -R <permissions> <directory>
command recursively applies permissions to all files and directories within the specified directory.
Question 49: #
How do you remove an ACL entry for a user?
A. setfacl -x u:<user> <file_name>
B. setfacl -r u:<user> <file_name>
C. chown -r u:<user> <file_name>
D. chmod -r u:<user> <file_name>
Réponse
Answer: A
Explanation:
The setfacl -x u:<user> <file_name>
command removes an ACL entry for the specified user.
50-65. System Time and Time Zone Configuration #
Question 50: #
Which command is used to display the current system time and time zone?
A. timedatectl
B. date
C. hwclock
D. time
Réponse
Answer: A
Explanation:
The timedatectl
command shows the current system time, date, time zone, and NTP status.
Question 51: #
How can you list all available time zones on the system using timedatectl
?
A. timedatectl list-timezones
B. timedatectl --zones
C. timedatectl timezones
D. timedatectl --list-all
Réponse
Answer: A
Explanation:
Use timedatectl list-timezones
to display all available time zones.
Question 52: #
Which command will set the system time to a specific time manually?
A. timedatectl set-time 12:00:00
B. hwclock --set 12:00:00
C. timedatectl time --set 12:00:00
D. date set 12:00:00
Réponse
Answer: A
Explanation:
The timedatectl set-time 12:00:00
command manually sets the system time.
Question 53: #
How do you set the system time zone to “America/New_York”?
A. timedatectl set-timezone America/New_York
B. timedatectl timezone America/New_York
C. timedatectl change-timezone America/New_York
D. timedatectl set-zone America/New_York
Réponse
Answer: A
Explanation:
To set the system time zone to “America/New_York”, use timedatectl set-timezone America/New_York
.
Question 54: #
Which file stores the symbolic link for the current system time zone?
A. /etc/timezone
B. /etc/localtime
C. /etc/zoneinfo
D. /etc/sysconfig/time
Réponse
Answer: B
Explanation:
The /etc/localtime
file is a symbolic link that points to the correct time zone data under /usr/share/zoneinfo/
.
Question 55: #
How do you enable Network Time Protocol (NTP) synchronization?
A. timedatectl set-ntp true
B. timedatectl ntp enable
C. timedatectl ntp-sync true
D. timedatectl sync ntp on
Réponse
Answer: A
Explanation:
To enable NTP synchronization, use the timedatectl set-ntp true
command.
Question 56: #
What is the purpose of the chrony
service in time synchronization?
A. It is a lightweight NTP client used for time synchronization.
B. It is a tool for changing system time zones.
C. It is used to display the current system clock.
D. It disables time synchronization services.
Réponse
Answer: A
Explanation:
chrony
is a modern replacement for ntpd
that provides improved performance and is used for synchronizing the system clock with NTP servers.
Question 57: #
How can you check the NTP synchronization status using timedatectl
?
A. timedatectl status
B. timedatectl show-ntp
C. timedatectl ntp-status
D. timedatectl sync-status
Réponse
Answer: A
Explanation:
The timedatectl status
command will show the system’s time, time zone, and NTP synchronization status.
Question 58: #
Which command allows you to synchronize the hardware clock with the system clock?
A. hwclock --systohc
B. timedatectl sync-hwclock
C. hwclock --set
D. date --systohc
Réponse
Answer: A
Explanation:
The hwclock --systohc
command synchronizes the hardware clock with the system clock.
Question 59: #
What command will disable NTP synchronization?
A. timedatectl set-ntp false
B. timedatectl disable-ntp
C. timedatectl no-ntp
D. timedatectl stop ntp
Réponse
Answer: A
Explanation:
Use timedatectl set-ntp false
to disable NTP synchronization.
Question 60: #
Which file contains the list of NTP servers that chronyd
will sync with?
A. /etc/chrony.conf
B. /etc/ntp.conf
C. /etc/timedatectl.conf
D. /etc/timezones.conf
Réponse
Answer: A
Explanation:
The /etc/chrony.conf
file contains the list of NTP servers and configuration settings for the chronyd
service.
Question 61: #
Which option ensures that the system clock persists after a reboot?
A. timedatectl set-ntp true
B. timedatectl set-local-rtc 0
C. timedatectl persist
D. timedatectl --save-clock
Réponse
Answer: B
Explanation:
The timedatectl set-local-rtc 0
command ensures that the system uses the UTC time zone and that the clock persists after reboot.
Question 62: #
Which command will show both the current hardware clock time and the system clock time?
A. hwclock --show
B. timedatectl show-clock
C. hwclock --compare
D. date --compare
Réponse
Answer: C
Explanation:
The hwclock --compare
command compares and shows both the hardware clock and the system clock.
Question 63: #
What does the timedatectl set-local-rtc 1
command do?
A. It sets the system to use local time instead of UTC.
B. It forces NTP synchronization to use the local time.
C. It enables manual synchronization of the clock.
D. It sets the hardware clock to use UTC time.
Réponse
Answer: A
Explanation:
The timedatectl set-local-rtc 1
command configures the system to use the local time zone instead of UTC.
Question 64: #
How can you verify whether chronyd
is active and synchronized?
A. chronyc tracking
B. timedatectl ntp-status
C. timedatectl --chrony
D. chronyd sync-status
Réponse
Answer: A
Explanation:
The chronyc tracking
command shows the synchronization status of chronyd
and its current offset with the NTP servers.
Question 65: #
Which systemd service manages the chrony
time synchronization?
A. chronyd.service
B. ntpd.service
C. timesyncd.service
D. timedatectl.service
Réponse
Answer: A
Explanation:
The chronyd.service
manages the chrony
time synchronization in RHEL-based systems.
66-81. SELinux File Context Management #
Question 66: #
Which command shows the current SELinux mode (enforcing, permissive, or disabled)?
A. getenforce
B. setenforce
C. sestatus
D. selinux-mode
Réponse
Answer: A
Explanation:
The getenforce
command displays the current SELinux mode.
Question 67: #
How do you temporarily switch SELinux to permissive mode?
A. setenforce 0
B. getenforce 0
C. sestatus permissive
D. selinux-config --permissive
Réponse
Answer: A
Explanation:
The setenforce 0
command switches SELinux to permissive mode temporarily.
Question 68: #
What does SELinux “enforcing” mode do?
A. It logs actions but does not prevent them.
B. It enforces all SELinux policies and prevents unauthorized actions.
C. It disables SELinux.
D. It allows unauthorized actions but alerts the user.
Réponse
Answer: B
Explanation:
In enforcing mode, SELinux enforces policies and prevents any unauthorized actions.
Question 69: #
Which command will show a detailed status of SELinux, including policy version and current mode?
A. getenforce
B. sestatus
C. selinux-status
D. setenforce --status
Réponse
Answer: B
Explanation:
The sestatus
command provides detailed information about the SELinux status, including the current mode and policy version.
Question 70: #
What is the function of the restorecon
command?
A. It restores the default SELinux context for a file or directory.
B. It restores the system’s SELinux policy.
C. It changes the SELinux mode to enforcing.
D. It disables SELinux temporarily.
Réponse
Answer: A
Explanation:
The restorecon
command restores the default SELinux context of files based on the SELinux policy.
Question 71: #
Which SELinux mode is the least secure, allowing all actions without logging or restrictions?
A. Enforcing
B. Permissive
C. Disabled
D. Alert
Réponse
Answer: C
Explanation:
In disabled mode, SELinux is completely turned off, allowing all actions without restrictions.
Question 72: #
What does the chcon
command do in SELinux?
A. It changes the ownership of a file.
B. It changes the SELinux context of a file or directory.
C. It restores the default SELinux policy.
D. It checks the current SELinux policy for errors.
Réponse
Answer: B
Explanation:
The chcon
command is used to manually change the SELinux security context of a file or directory.
Question 73: #
Which of the following commands will set SELinux back to enforcing mode after being in permissive mode?
A. setenforce 1
B. getenforce 1
C. sestatus enforcing
D. selinux-mode enforcing
Réponse
Answer: A
Explanation:
To set SELinux back to enforcing mode, use the setenforce 1
command.
Question 74: #
How can you disable SELinux permanently?
A. Edit /etc/selinux/config
and set SELINUX=disabled
B. Use setenforce 0
C. Use getenforce --disable
D. Use restorecon --disable
Réponse
Answer: A
Explanation:
To permanently disable SELinux, you need to edit the /etc/selinux/config
file and set SELINUX=disabled
.
Question 75: #
What does the setenforce
command do?
A. It enables SELinux logs.
B. It toggles between enforcing and permissive mode for SELinux.
C. It sets default SELinux contexts.
D. It restores the SELinux policy.
Réponse
Answer: B
Explanation:
The setenforce
command is used to toggle between enforcing and permissive modes.
Question 76: #
Which context field in SELinux specifies the security type (e.g., system_u:object_r:default_t:s0
)?
A. user
B. role
C. type
D. level
Réponse
Answer: C
Explanation:
In the SELinux context, the type
field determines the type of object being labeled, such as httpd_sys_content_t
for web content.
Question 77: #
What is the purpose of the semanage fcontext
command?
A. To view the current SELinux mode.
B. To modify or view the file context mappings in SELinux.
C. To change the file system mount options for SELinux.
D. To disable SELinux logging.
Réponse
Answer: B
Explanation:
semanage fcontext
is used to modify or view file context mappings in SELinux policies.
Question 78: #
Which tool can be used to troubleshoot SELinux denials and gather detailed logs?
A. ausearch
B. chcon
C. restorecon
D. setenforce
Réponse
Answer: A
Explanation:
The ausearch
tool allows you to search through SELinux audit logs to find denials and related information for troubleshooting.
Question 79: #
What happens if SELinux is in permissive mode?
A. All actions are allowed, but SELinux denials are logged.
B. All SELinux policies are enforced.
C. SELinux is disabled completely.
D. Only specific actions are restricted by SELinux.
Réponse
Answer: A
Explanation:
In permissive mode, SELinux policies are not enforced, but violations are logged for review.
Question 80: #
What command would you use to view the current file security context of /var/www/html/index.html
?
A. ls -Z /var/www/html/index.html
B. chcon -l /var/www/html/index.html
C. sestatus /var/www/html/index.html
D. getenforce /var/www/html/index.html
Réponse
Answer: A
Explanation:
The ls -Z
command shows the security context of a file or directory.
Question 81: #
What is the primary purpose of SELinux in a RHEL system?
A. To manage file permissions based on users and groups.
B. To provide mandatory access control (MAC) for processes and files.
C. To monitor and log system activities for auditing purposes.
D. To enhance firewall rules in the operating system.
Réponse
Answer: B
Explanation:
SELinux enforces mandatory access control (MAC) policies to restrict processes and users based on their security contexts.
82-98. Storage Management #
Question 82: #
Which command is used to create a new ext4 file system on a disk partition?
A. mkfs.ext4
B. fdisk
C. mkfs.xfs
D. parted
Réponse
Answer: A
Explanation:
The mkfs.ext4
command is used to create an ext4 file system on a specified partition or disk.
Question 83: #
Which command will mount a file system to the /mnt/data
directory?
A. mount /dev/sda1 /mnt/data
B. mount /mnt/data /dev/sda1
C. mount /mnt/data
D. mount /dev/sda1
Réponse
Answer: A
Explanation:
The mount
command attaches the file system from /dev/sda1
to the /mnt/data
directory.
Question 84: #
Which file contains persistent mount information for file systems that should be mounted at boot?
A. /etc/fstab
B. /etc/mtab
C. /proc/mounts
D. /var/log/boot.log
Réponse
Answer: A
Explanation:
The /etc/fstab
file contains information on file systems that should be mounted automatically at boot.
Question 85: #
How do you create a new Logical Volume (LV) named lvdata
in a Volume Group (VG) named vgdata
?
A. lvcreate -L 5G -n lvdata vgdata
B. vgcreate -L 5G lvdata vgdata
C. vgextend -L 5G lvdata vgdata
D. lvadd -L 5G -n lvdata vgdata
Réponse
Answer: A
Explanation:
The lvcreate
command is used to create a new logical volume. The -L
flag specifies the size, and the -n
flag specifies the name.
Question 86: #
How can you extend a Logical Volume named lvdata
by 2GB?
A. lvextend -L +2G /dev/vgdata/lvdata
B. lvresize -L +2G /dev/vgdata/lvdata
C. vgextend -L +2G /dev/vgdata/lvdata
D. lvcreate -L +2G /dev/vgdata/lvdata
Réponse
Answer: A
Explanation:
The lvextend
command is used to increase the size of an existing logical volume by 2GB.
Question 87: #
Which of the following is the correct command to format a partition with the XFS file system?
A. mkfs.xfs
B. mkfs.ext4
C. format.xfs
D. mkfs -t ext4
Réponse
Answer: A
Explanation:
The mkfs.xfs
command is used to create a new XFS file system on a disk or partition.
Question 88: #
Which command is used to activate a swap partition?
A. swapon
B. swapon -a
C. swap activate
D. swapon /etc/fstab
Réponse
Answer: A
Explanation:
The swapon
command is used to activate a swap partition or file.
Question 89: #
How do you check the available free space in a Volume Group?
A. vgdisplay
B. vgcheck
C. lvdisplay
D. vgfree
Réponse
Answer: A
Explanation:
The vgdisplay
command provides information about a Volume Group, including available free space.
Question 90: #
Which command is used to create a new partition on a disk in Linux?
A. fdisk
B. parted
C. Both A and B
D. pvcreate
Réponse
Answer: C
Explanation:
Both fdisk
and parted
are used to create partitions on a disk.
Question 91: #
Which command will add a new physical volume (PV) for use in a Volume Group?
A. pvcreate /dev/sdb
B. vgcreate /dev/sdb
C. lvcreate /dev/sdb
D. fdisk /dev/sdb
Réponse
Answer: A
Explanation:
The pvcreate
command initializes a disk or partition for use in a Volume Group.
Question 92: #
How do you add a new file system to an active Volume Group (VG)?
A. Create a Logical Volume (LV) and format it with a file system
B. Create a Physical Volume (PV) and format it
C. Mount the VG directly
D. Unmount the VG, then add the file system
Réponse
Answer: A
Explanation:
To add a new file system, you must create a Logical Volume and then format it.
Question 93: #
Which command shows the currently mounted file systems and their mount points?
A. df -h
B. mount
C. lsblk
D. All of the above
Réponse
Answer: D
Explanation:
The df -h
, mount
, and lsblk
commands can all be used to view mounted file systems and their mount points.
Question 94: #
What is the purpose of the mkswap
command?
A. To create a new swap file or partition
B. To mount a swap partition
C. To activate a swap partition
D. To format a logical volume for swap
Réponse
Answer: A
Explanation:
The mkswap
command initializes a file or partition to be used as swap space.
Question 95: #
Create a volume group, and set 32M as a extends. And divided a volume group containing 70 extends on volume group lv, make it as ext4 file system, and mounted automatically under /mnt/data.
Compose and reveal solution below.
Réponse
pvcreate /dev/sda7 /dev/sda8
vgcreate -s 32M vg1 /dev/sda7 /dev/sda8
lvcreate -l 70 -n lvm02 vg1
mkfs.ext4 /dev/vg1/lvm01
blkid /dev/vg1/lvm01 (reveal UID)
vim /etc/fstab
UUID=abcd1234-xxxx-yyyy-zzzz-1234567890ab /mnt/data ext4 defaults 0 0
mkdir -p /mnt/data
mount -a
Question 96: #
Which of the following commands can be used to display detailed information about a Logical Volume?
A. lvdisplay
B. lvs
C. lvscan
D. All of the above
Réponse
Answer: D
Explanation:
All of these commands (lvdisplay
, lvs
, lvscan
) can be used to display information about Logical Volumes.
Question 97: #
What is the correct sequence to create a new file system using LVM?
A. pvcreate
→ vgcreate
→ lvcreate
→ mkfs
B. vgcreate
→ pvcreate
→ lvcreate
→ mkfs
C. pvcreate
→ lvcreate
→ vgcreate
→ mkfs
D. mkfs
→ lvcreate
→ vgcreate
→ pvcreate
Réponse
Answer: A
Explanation:
To create a file system using LVM, the correct sequence is to create a Physical Volume (pvcreate
), then a Volume Group (vgcreate
), a Logical Volume (lvcreate
), and finally format it using mkfs
.
Question 98: #
Which file must be edited to make a swap partition mount at boot?
A. /etc/fstab
B. /etc/mtab
C. /etc/swap
D. /proc/swaps
Réponse
Answer: A
Explanation:
To ensure a swap partition mounts at boot, you must add it to the /etc/fstab
file.
99-113. Networking #
Question 99: #
Which command is used to display the current IP addresses of network interfaces?
A. ip addr show
B. ifconfig -a
C. nmcli device show
D. All of the above
Réponse
Answer: D
Explanation:
All of these commands can be used to display the current IP addresses of network interfaces.
Question 100: #
How would you assign the IP address 192.168.1.100/24
to the eth0
interface using the ip
command?
A. ip addr add 192.168.1.100/24 dev eth0
B. ip add 192.168.1.100 dev eth0
C. ip config eth0 192.168.1.100/24
D. ifconfig eth0 192.168.1.100 netmask 255.255.255.0
Réponse
Answer: A
Explanation:
The correct syntax for assigning an IP address to a network interface with the ip
command is ip addr add [IP address] dev [interface]
.
Question 101: #
How do you bring up the eth0
interface using nmcli
?
A. nmcli device connect eth0
B. nmcli device up eth0
C. nmcli connection up eth0
D. nmcli network up eth0
Réponse
Answer: C
Explanation:
The nmcli connection up
command is used to bring up a network interface.
Question 102: #
Which command will show the default gateway on a Linux system?
A. ip route show
B. route -n
C. netstat -rn
D. All of the above
Réponse
Answer: D
Explanation:
All of these commands can show routing information, including the default gateway.
Question 103: #
How do you reload firewall rules using firewalld
?
A. firewall-cmd --reload
B. firewall-cmd --reload-rules
C. systemctl restart firewalld
D. firewalld reload
Réponse
Answer: A
Explanation:
The firewall-cmd --reload
command is used to reload the firewall rules without disrupting active connections.
Question 104: #
Which command can be used to permanently open HTTP (port 80) in firewalld
?
A. firewall-cmd --add-service=http --permanent
B. firewall-cmd --add-port=80/tcp
C. firewall-cmd --permanent --add-service=http
D. iptables -A INPUT -p tcp --dport 80 -j ACCEPT
Réponse
Answer: A
Explanation:
The firewall-cmd --add-service=http --permanent
command opens the HTTP service (port 80) in the firewall permanently.
Question 105: #
Which command will list all active firewall rules in firewalld
?
A. firewall-cmd --list-all
B. iptables -L
C. firewalld list rules
D. firewall-cmd --list-rules
Réponse
Answer: A
Explanation:
The firewall-cmd --list-all
command displays all active firewall rules for the default zone.
Question 106: #
How do you configure a static IP address for the eth0
interface using nmcli
?
A. nmcli con mod eth0 ipv4.addresses 192.168.1.100/24
B. nmcli con mod eth0 ip4.address 192.168.1.100/24
C. nmcli con add ipv4.address 192.168.1.100 dev eth0
D. nmcli con mod eth0 address 192.168.1.100
Réponse
Answer: A
Explanation:
The correct syntax for configuring a static IP address using nmcli
is nmcli con mod [interface] ipv4.addresses [IP address/CIDR]
.
Question 107: #
How can you enable the firewall on a Linux system?
A. systemctl enable firewalld
B. systemctl start firewalld
C. firewall-cmd --enable
D. Both A and B
Réponse
Answer: D
Explanation:
To enable and start firewalld
, use both systemctl enable firewalld
and systemctl start firewalld
.
Question 108: #
Which of the following commands will display the current network configuration for all interfaces?
A. nmcli device show
B. ip addr show
C. ifconfig -a
D. All of the above
Réponse
Answer: D
Explanation:
All of these commands will display the network configuration for the active network interfaces.
Question 109: #
How do you configure a DNS server address using nmcli
?
A. nmcli con mod eth0 ipv4.dns 8.8.8.8
B. nmcli con mod eth0 ip.dns 8.8.8.8
C. nmcli con add dns 8.8.8.8 dev eth0
D. nmcli dns mod eth0 8.8.8.8
Réponse
Answer: A
Explanation:
To set the DNS server for a connection in nmcli
, the correct command is nmcli con mod [connection] ipv4.dns [DNS server]
.
Question 110: #
How do you check if a specific port, such as 443, is allowed through the firewall using firewalld
?
A. firewall-cmd --list-ports
B. firewall-cmd --get-active-zones
C. firewall-cmd --query-port=443/tcp
D. iptables -L | grep 443
Réponse
Answer: C
Explanation:
The firewall-cmd --query-port=443/tcp
command will check whether port 443 is allowed through the firewall.
Question 111: #
Which command is used to enable and configure IP forwarding?
A. sysctl -w net.ipv4.ip_forward=1
B. echo 1 > /proc/sys/net/ipv4/ip_forward
C. nmcli con mod eth0 ip-forward yes
D. Both A and B
Réponse
Answer: D
Explanation:
Both sysctl
and writing to /proc/sys/net/ipv4/ip_forward
can enable IP forwarding on Linux.
Question 112: #
How do you permanently open port 22 (SSH) in firewalld
?
A. firewall-cmd --add-port=22/tcp --permanent
B. firewall-cmd --add-service=ssh --permanent
C. iptables -A INPUT -p tcp --dport 22 -j ACCEPT
D. firewall-cmd --add-port=22 --permanent
Réponse
Answer: B
Explanation:
The firewall-cmd --add-service=ssh --permanent
command opens port 22 for SSH traffic permanently.
Question 113: #
Which command is used to enable and configure IP forwarding?
A. sysctl -w net.ipv4.ip_forward=1
B. echo 1 > /proc/sys/net/ipv4/ip_forward
C. nmcli con mod eth0 ip-forward yes
D. Both A and B
Réponse
Answer: D
Explanation:
Both sysctl
and writing to /proc/sys/net/ipv4/ip_forward
can enable IP forwarding on Linux.
114-128. Systemd and Service Management #
Question 114: #
Which command will start a service called httpd
?
A. systemctl start httpd
B. service httpd start
C. systemctl enable httpd
D. start httpd
Réponse
Answer: A
Explanation:
The systemctl start httpd
command is used to start the httpd
service.
Question 115: #
How do you enable a service to start automatically on boot?
A. systemctl enable service_name
B. systemctl start service_name
C. systemctl reload service_name
D. systemctl restart service_name
Réponse
Answer: A
Explanation:
The systemctl enable
command sets a service to start automatically on boot.
Question 116: #
Which command is used to stop a currently running service?
A. systemctl stop service_name
B. systemctl disable service_name
C. systemctl restart service_name
D. systemctl status service_name
Réponse
Answer: A
Explanation:
To stop a running service, use the systemctl stop
command.
Question 117: #
How can you check the status of a service?
A. systemctl status service_name
B. systemctl check service_name
C. systemctl info service_name
D. systemctl show service_name
Réponse
Answer: A
Explanation:
The systemctl status
command shows the current status of a service.
Question 118: #
Which command shows all active services and their statuses?
A. systemctl list-units --type=service
B. systemctl show --type=service
C. systemctl list-services
D. systemctl status
Réponse
Answer: A
Explanation:
The command systemctl list-units --type=service
lists all active services.
Question 119: #
What does the command systemctl disable service_name
do?
A. It prevents the service from starting on boot.
B. It stops the service immediately.
C. It restarts the service.
D. It removes the service’s configuration.
Réponse
Answer: A
Explanation:
systemctl disable
disables the service from starting automatically on boot.
Question 120: #
Which command will restart a service named nginx
?
A. systemctl restart nginx
B. systemctl reload nginx
C. systemctl stop nginx && systemctl start nginx
D. systemctl update nginx
Réponse
Answer: A
Explanation:
The systemctl restart
command restarts the service, which is equivalent to stopping and starting it.
Question 121: #
How do you view the most recent entries in the system log using journalctl
?
A. journalctl -e
B. journalctl --latest
C. journalctl -f
D. journalctl --newest
Réponse
Answer: A
Explanation:
The journalctl -e
command jumps to the end of the log to show the most recent entries.
Question 122: #
Which command will show you logs for a specific service sshd
?
A. journalctl -u sshd
B. journalctl --service=sshd
C. journalctl -f sshd
D. journalctl -p sshd
Réponse
Answer: A
Explanation:
The journalctl -u
command shows logs for the specified service.
Question 123: #
What is the purpose of a systemd
target?
A. To manage system services
B. To provide a boot or run level
C. To configure network settings
D. To start a new session
Réponse
Answer: B
Explanation:
systemd
targets are used to define various states of the system, similar to traditional run levels.
Question 124: #
How do you list all available systemd
targets?
A. systemctl list-units --type=target
B. systemctl list-targets
C. systemctl show --type=target
D. systemctl list-all
Réponse
Answer: B
Explanation:
The systemctl list-targets
command lists all available systemd
targets.
Question 125: #
Which command shows logs related to the boot process?
A. journalctl -b
B. journalctl --boot
C. journalctl -p boot
D. journalctl --startup
Réponse
Answer: A
Explanation:
The journalctl -b
command displays logs related to the current boot process.
Question 126: #
How do you view the logs for the previous boot using journalctl
?
A. journalctl -b -1
B. journalctl --previous
C. journalctl -p previous
D. journalctl --boot -1
Réponse
Answer: A
Explanation:
The journalctl -b -1
command shows logs from the previous boot.
Question 127: #
Which command will check if a service is currently active and running?
A. systemctl is-active service_name
B. systemctl check service_name
C. systemctl status service_name
D. systemctl active service_name
Réponse
Answer: A
Explanation:
The systemctl is-active
command checks if a service is active and running.
Question 128: #
What is the purpose of the systemd
unit file?
A. To define and configure a system service or resource
B. To manage system users
C. To configure network settings
D. To handle system storage
Réponse
Answer: A
Explanation:
systemd
unit files define and configure system services and resources.
128-143. Process and Task Management #
Question 129: #
Which command displays real-time information about system processes?
A. ps
B. top
C. htop
D. pgrep
Réponse
Answer: B
Explanation:
The top
command provides real-time information about system processes and resource usage.
Question 130: #
How can you view all currently running processes using ps
?
A. ps -e
B. ps -aux
C. ps -ef
D. ps -all
Réponse
Answer: C
Explanation:
The ps -ef
command lists all currently running processes with full details.
Question 131: #
What does the kill -9
command do?
A. Sends a SIGTERM signal to terminate a process gracefully
B. Sends a SIGKILL signal to forcefully terminate a process
C. Displays information about the process with the specified PID
D. Pauses the process with the specified PID
Réponse
Answer: B
Explanation:
kill -9
sends a SIGKILL signal, which forcefully terminates a process.
Question 132: #
How can you schedule a one-time task to run at a specific time using at
?
A. at 14:00
B. at now + 1 minute
C. at 2 PM
D. at 14:00 tomorrow
Réponse
Answer: B
Explanation:
at now + 1 minute
schedules a one-time task to run in one minute.
Question 133: #
Which command will list all scheduled cron jobs for the current user?
A. crontab -l
B. cron list
C. crontab --list
D. cron -l
Réponse
Answer: A
Explanation:
The crontab -l
command lists all cron jobs scheduled for the current user.
Question 134: #
How do you remove a scheduled cron job for the current user?
A. crontab -r
B. crontab -d
C. crontab -e
D. crontab -x
Réponse
Answer: A
Explanation:
The crontab -r
command removes all cron jobs for the current user.
Question 135: #
How can you view detailed information about a process, including its environment variables?
A. ps -ef
B. top -p PID
C. cat /proc/PID/environ
D. ps aux | grep PID
Réponse
Answer: C
Explanation:
The file /proc/PID/environ
contains environment variables for the process with the given PID.
Question 136: #
Which command is used to edit the cron jobs for the current user?
A. crontab -e
B. cronedit
C. crontab --edit
D. edit cron
Réponse
Answer: A
Explanation:
The crontab -e
command opens the user’s crontab file for editing.
Question 137: #
How can you check if the cron
service is running?
A. systemctl status cron
B. service cron status
C. ps aux | grep cron
D. cron status
Réponse
Answer: A
Explanation:
systemctl status cron
checks the status of the cron
service.
Question 138: #
What does the crontab
entry 0 5 * * *
specify?
A. Run a task at 5 AM every day
B. Run a task at 5 PM every day
C. Run a task every hour
D. Run a task every day at midnight
Réponse
Answer: A
Explanation:
The 0 5 * * *
entry specifies that the task will run at 5:00 AM every day.
Question 139: #
How can you cancel a job scheduled with at
?
A. at -d job_id
B. atq -d job_id
C. atrm job_id
D. at cancel job_id
Réponse
Answer: C
Explanation:
The atrm
command is used to remove a job scheduled with at
.
Question 140: #
How do you display the list of pending at
jobs?
A. atq
B. at -l
C. at list
D. at jobs
Réponse
Answer: A
Explanation:
The atq
command lists all pending at
jobs.
Question 141: #
What does the top
command do when you press k
?
A. Kill a process
B. Sort processes by memory usage
C. Show kernel messages
D. Display process information in kilobytes
Réponse
Answer: A
Explanation:
Pressing k
in the top
command interface allows you to kill a process by entering its PID.
Question 142: #
How can you schedule a task to run every Monday at 2:30 PM using cron
?
A. 30 14 * * 1
B. 30 14 * * MON
C. 30 14 * * 0
D. 30 14 1 * 1
Réponse
Answer: A
Explanation:
The 30 14 * * 1
entry schedules a task to run every Monday at 2:30 PM.
Question 143: #
Which command will display the CPU usage of all processes?
A. top
B. ps aux
C. vmstat
D. iostat
Réponse
Answer: A
Explanation:
The top
command provides real-time CPU usage information for all processes.
144-161. Basic Shell Scripting #
Question 144: #
Which command is used to create a new bash script file?
A. touch script.sh
B. nano script.sh
C. vi script.sh
D. All of the above
Réponse
Answer: D
Explanation:
You can use touch
, nano
, or vi
to create or edit a new bash script file.
Question 145: #
What is the purpose of the #!/bin/bash
line at the beginning of a script?
A. It specifies the script’s file format.
B. It indicates the interpreter to be used for the script.
C. It defines the script’s permissions.
D. It initializes environment variables.
Réponse
Answer: B
Explanation:
The #!/bin/bash
line specifies the path to the interpreter used to execute the script.
Question 146: #
How do you assign a value to a variable in a bash script?
A. variable=value
B. variable = value
C. variable:value
D. variable == value
Réponse
Answer: A
Explanation:
In bash scripting, variables are assigned values without spaces around the equal sign.
Question 147: #
How do you access the value of a variable in a bash script?
A. $variable
B. variable$
C. {variable}
D. &variable
Réponse
Answer: A
Explanation:
To access the value of a variable, you use the dollar sign followed by the variable name.
Question 148: #
Which construct is used to execute commands conditionally in a bash script?
A. for
B. while
C. if
D. case
Réponse
Answer: C
Explanation:
The if
statement is used to execute commands based on a condition.
Question 149: #
How do you write a loop that iterates 5 times in a bash script?
A. for i in {1..5}; do ... done
B. while i < 5; do ... done
C. repeat 5; do ... done
D. loop 5; do ... done
Réponse
Answer: A
Explanation:
The for
loop with i in {1..5}
iterates from 1 to 5.
Question 150: #
Which command is used to print text to the terminal in a bash script?
A. echo
B. print
C. printf
D. output
Réponse
Answer: A
Explanation:
The echo
command is used to print text to the terminal.
Question 151: #
How do you read user input into a variable in a bash script?
A. read variable
B. input variable
C. get variable
D. scan variable
Réponse
Answer: A
Explanation:
The read
command is used to get user input and store it in a variable.
Question 152: #
What does the $(command)
syntax do in a bash script?
A. Executes the command in a subshell and returns the output
B. Assigns the command to a variable
C. Runs the command in the background
D. Executes the command as a root user
Réponse
Answer: A
Explanation:
The $(command)
syntax captures the output of the command for use within the script.
Question 153: #
How do you append text to a file in a bash script?
A. echo "text" >> file.txt
B. echo "text" > file.txt
C. append "text" file.txt
D. write "text" file.txt
Réponse
Answer: A
Explanation:
The >>
operator appends text to a file without overwriting its existing content.
Question 154: #
Which conditional statement checks if a file exists in a bash script?
A. if [ -f file.txt ]; then
B. if [ -e file.txt ]; then
C. if [ file.txt ]; then
D. if [ -d file.txt ]; then
Réponse
Answer: A
Explanation:
The -f
flag checks if a file exists and is a regular file.
Question 155: #
How can you execute commands in the background in a bash script?
A. command &
B. command bg
C. command fork
D. command --background
Réponse
Answer: A
Explanation:
Appending &
to a command runs it in the background.
Question 156: #
Which operator is used to test equality between two strings in bash?
A. ==
B. =
C. eq
D. equal
Réponse
Answer: B
Explanation:
In bash, =
is used to test equality between two strings.
Question 157: #
How do you specify a command to run if the previous command fails in a bash script?
A. command1 || command2
B. command1 && command2
C. command1; command2
D. command1 | command2
Réponse
Answer: A
Explanation:
Using ||
specifies that command2
should run if command1
fails.
Question 158: #
What is the purpose of the case
statement in bash scripting?
A. To execute commands based on multiple conditions
B. To handle file operations
C. To manage process execution
D. To loop through numbers
Réponse
Answer: A
Explanation:
The case
statement allows execution of commands based on matching multiple conditions.
Question 159 (Advanced): #
Write a bash script that checks if a directory exists and creates it if it does not.
Réponse
#!/bin/bash
DIR="/path/to/directory"
if [ ! -d “$DIR” ]; then echo “Directory does not exist. Creating now…” mkdir -p “$DIR” echo “Directory created.” else echo “Directory already exists.” fi
Explanation:
This script checks if the specified directory exists (-d
), and if not, creates it using mkdir -p
.
Question 160 (Advanced): #
Write a bash script that reads a list of filenames from a text file and prints their sizes.
Réponse
#!/bin/bash
FILE_LIST=“files.txt”
while IFS= read -r file; do if [ -f “$file” ]; then echo “$file: $(stat -c%s “$file”) bytes” else echo “$file does not exist.” fi done < “$FILE_LIST”
Explanation:
The script reads each line from files.txt
, checks if the file exists (-f
), and prints its size using stat -c%s
.
Question 161 (Advanced): #
Create a bash script that backs up a directory to a specified backup location and logs the outcome.
Réponse
#!/bin/bash
SOURCE_DIR="/path/to/source" BACKUP_DIR="/path/to/backup" LOG_FILE="/path/to/backup.log" TIMESTAMP=$(date +"%Y%m%d%H%M%S")
echo “Starting backup at $TIMESTAMP” » “$LOG_FILE” if cp -r “$SOURCE_DIR” “$BACKUP_DIR/backup_$TIMESTAMP”; then echo “Backup successful” » “$LOG_FILE” else echo “Backup failed” » “$LOG_FILE” fi
Explanation:
The script copies the source directory to the backup location with a timestamp and logs the success or failure of the operation.