Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.- Create a regular user named user01. 2.- As super-user create a directory cal

ID: 3605207 • Letter: 1

Question

1.- Create a regular user named user01.

2.- As super-user create a directory called backup under the home directory of user01 and change the owner and group associated to the directory to user01.

3.- Set security on the backup directory so that user01 has all permissions and no one else has any permissions.

4.- Write a script for creating a backup of all your data in the folder backup. In the creation of the copy of security exclude the copy of the folder backup. The name of the backup must be like backupUserData_10_26_17.zip. The name of the script and location will be /home/user01/backup/backupUserData.sh

5.- Add the script above to the crontab scheduler of user01 in such a way that a new copy of security is created every Friday at 11:30 pm. Specify the text line to be added in the job scheduler.

Explanation / Answer

# 1. To create a new user, run this command
sudo useradd user01
# 2.
sudo su # To run further commands as super-user
cd /home/user01/ # go to the user's home directory
mkdir backup # create a new directory
chown user01:user01 backup #change ownership of the directory

# 3.
chmod 700 backup # chmod is used for chanding permissions of file 7 --> Owner permission, 0--> Group permission, 0--> Others permission
   # there are three types of permissions - Read(4), write(2), and execute(1). Depending on what permission you need to
   # supply, add these numbers. So for full permissions, 4+2+1 = 7

# 4.
tar -cvpzf backupUserData_`date +%m_%d_%y`.tar.gz --exclude=/home/user01/backup/ --one-file-system /

Add this line to /home/user01/backup/backupUserData.sh
Make this file executable : chmod +x /home/user01/backup/backupUserData.sh

Explanation:
tar is better suited for backups, as it preserves unix permissions. date command is used to get today's date. But it gives a space
separated value. %m gives month, %d gives date and %y gives last two digit of year (%Y gives all four digits). '`' can be used to
run another command within a command.
-c creates a new file
-v verbose mode
-p preserves permissions
-z compresses the file to save space
-f <filename> to specify output filename
--exclude to exclude the folder
--one-file-system To skip mounted file systems, like /media
/ root directory

# 5.

crontab -u user01 -e # to edit crontab of user01
30 23 * * Fri /home/user01/backup/backupUserData.sh

Format:
minute hour date Month day_of_week <file_to_run>