Linux Assessment
Before you begin...
- Make sure you can login to your instance using your account and password (see here for reference)
- Note: Your servers will be rebooted after you've taken the assessment. Make sure the configuration changes you made are persistent even after rebooting the server.
Tasks
Task 1: Package Management
- (5 pts) Install the necessary package to install the
nmap
command - (5 pts) Remove the package that contains the
bc
command
Task 2: File Compression
- (10 pts) Make a copy of
/etc/resolv.conf
and name the copyresolv_backup
. Compress theresolv_backup
to a gzip archive named/root/gzbackups/resolv_copy.gz
- (5 pts) Download https://getsamplefiles.com/download/tar/sample-1.tar. Once done, extract its contents into a directory named
/root/extract/sample-1/
Task 3: User Environment
- (5 pts) Create a new directory named
/root/secure_data
. Set the permissions so that the owner can read, write, and execute, while the group and others have no permissions - (10 pts) Add a local user named
hanna
with a home folder set to/mnt/data/hanna_home
- (5 pts) Make
hanna
a sudoer - (10 pts) Create an empty file named
/root/important_data.txt
. Change the permissions ofimportant_data.txt
so that only the owner has read, write, and execute permissions, the group has only read and write, and others have no access to the file. Makehanna
the owner of the file
Task 4: Storage Management
- (5 pts) Create an MBR partition in
/dev/sdb
with a size of 256MB with partition type ofLinux
- (10 pts) Format
/dev/sdb1
to ext4 and mount it to/mnt/data
. Ensure that the mount is persistent and will be mounted during system bootup
Task 5: Manipulating Text
- (5 pts) Download https://users.cs.duke.edu/~ola/ap/linuxwords. Search in the file all lines that contains
error
, then redirect the output to a file named/root/error_occurrences.txt
- (5 pts) Using the same
linuxwords
file, search all lines that contains eitherbash
orcrown
. Once you've retrieved the lines, replace all instances ofbash
tozebra
. Store the results to a file named/root/zebra.txt
- (10 pts) Extract the first 4 fields of
/etc/passwd
with:
as the delimiter. Then, replace all number0
withZ
. Sort the results alphabetically in descending order, then redirect your answers to/root/custompasswd
Task 6: Service Management
- (5 pts) Ensure that
firewalld
service is running and will run upon boot-up. Install the service if it's non-existent - (5 pts) Service
sssd
must not be running and must not be run upon boot-up
Task 7: BASH Scripting
- (10 pts) Create a cron job under the root user that runs a script named
/root/scripts/date.sh
which displays the current year. Create the script if it's non-existent. Then, the cron job must run every hour at the exact beginning of the hour wherein it will append the output to a log file/var/log/date.txt
- (10 pts) Write a BASH script named
/root/counter.sh
that accepts a text file as an argument. The BASH script must count the number of instances of the characters:
,0
, anda
, in this order. Here's a sample output:$ ./counter.sh /etc/group 174 36 55