Ubuntu Linux Server Administration II Lab 3    

 

Introduction  This lab is due either before you leave today or emailed to me before next week’s class. Task 1:

Users and Groups

Task 2:

Installing Applications

Task 3:

Disk Management

Task 4:

Creating Disk Quotas

Task 5:

Backups

Task 6:

Lab Questions

Task 1: Users and Groups  1. For the screen shots, I was logged in as root, if you want to do that for these exercises, feel free. I get tired of having to type in the password all of the time 2. The useradd command will let you add a new user easily from the command line sudo useradd 3. This command adds the user, but your user won’t have a password or a home directory 4. You can use the -d option to set the home directory for the user. The -m option will force useradd to create the home directory. Create another user account with those options, and then use the passwd command to set the password for the account. You can alternatively set a password using -p on the useradd command, but I prefer to set the password using passwd. sudo useradd -d /home/testuser -m testuser sudo passwd testuser sudo ls /home/testuser 5. You’ll notice that there are bash scripts in the directory. If you wanted to set default path options for all new users, you would do so by modifying the files in /etc/skel, which would then be used to create these files by the useradd command.

6. If you don’t want to do everything manually, you can use the adduser command, because it prompts you for each piece of information and creates the home directory, etc. Type Created by Donna Warren 2/5/2012 

Page 1 

Ubuntu Linux Server Administration II Lab 3    

  sudo adduser

adduser is a whole lot less trouble and just as fast as using the GUI 7. To temporarily lock a user account, use the following command to lock your new user account sudo passwd -l username 8. Test the loc by opening a second terminal window and type login at the command prompt and try to login as the user whose account you just locked. You should get the following

9. Now go back to the first terminal window and unlock the user account, type the following command to unlock your new user account sudo passwd -u username 10. Then go to the second terminal window and type login and try to login as the user again. You should get something like the picture below

Created by Donna Warren 2/5/2012 

Page 2 

Ubuntu Linux Server Administration II Lab 3    

 

11. To add a personalized group, use the following command: sudo addgroup groupname 12. To add a personalized group, use the following command: sudo delgroup groupname 13. To delete a user from a group, type the following sudo adduser username groupname 14. To delete a user account and its primary group, type the following command sudo deluser username

15. Deleting an account does not remove their respective home folder. It is up to you whether or not you wish to delete the folder manually or keep it 16. Remember, any user added later on with the same UID/GID as the previous owner will now have access to this folder if you have not taken the necessary precautions. 17. To archive the folder and prevent future problems if you don’t delete the folder use the following commands Created by Donna Warren 2/5/2012 

Page 3 

Ubuntu Linux Server Administration II Lab 3    

  sudo chown -R root:root /home/username/ sudo mkdir /home/archived_users/ sudo mv /home/username /home/archived_users/ 18. To check if the transfer was successful type the following command:

ls –l /home/archived_users

19. Take a screen shot of the results and paste it into your lab 3 document

Task 2: Installing Applications  1. Let’s install a racing game. First we need to see what is available by typing apt-cache search racing game 2. I found something called torcs. Ok, so now, let's install it by typing apt-get install torcs 3. Next, after the uinstall is done, type the following command to run the game torcs 4. If that command had not worked you could look in the /usr/games directory to see what the correct name is. For administrative applications it's in usr/sbin directory 5. Take a screen shot of the game running and paste it into your lab 3 document

Task 3: Disk Management  1. Managing hard disk space on servers is important. Type sudo du –h | more to see how space is being used by each directory. You should get something like the print out below

Created by Donna Warren 2/5/2012 

Page 4 

Ubuntu Linux Server Administration II Lab 3    

 

2. Take a screen shot of the completion windows and paste it into your Lab 3 document 3. Next, let’s check to see what partitions we have on our machine. Type sudo fdisk –l (that’s the letter ell not a number) You should get something like the picture below for results

4. Take a screen shot of the completion windows and paste it into your Lab 3 document 5. Ubuntu provides a utility to check for bad blocks on the file system. This is a utility that you should as part of your routine maintenance schedule. This can take a couple of minutes. Type sudo badblocks – v /dev/sda The results will look something like the picture below Created by Donna Warren 2/5/2012 

Page 5 

Ubuntu Linux Server Administration II Lab 3    

 

6. Take a screen shot of the completion windows and paste it into your Lab 3 document 7. If there are bad blocks like in the example below, you can use the fsck –c /dev/sda after you un-mount the device to have them automatically written to the bad block list so the operating system will not try to use them to store data. donna@donna-laptop:~$ sudo badblocks -v /dev/sdb1 Checking blocks 0 to 97683200 Checking for bad blocks (read-only test): 3134528 done, 3:27 elapsed 3134560 done, 8:33 elapsed 3134561 done, 10:15 elapsed 3134562 done, 11:57 elapsed 3134563 done, 13:39 elapsed: done Pass completed, 5 bad blocks found. 8. First we have to write the location of the bad sectors into a flat file. sudo badblocks /dev/sdb > /home/zainul/bad-blocks 9. After that, we need to feed the flat file into the FSCK command to mark these bad sectors as ‘unusable’ sectors. sudo fsck -l bad-blocks /dev/sdb Of course, you can use GUI tools for some of these tasks but sometimes the command line is better and normally works in all the different distributions.

Task 4: Disk Quotas  1. The Quota tool can be downloaded from http://quotatool.ekenberg.se/ to your home directory 2. Use the Snynaptic Package Manager found under system administration in the GUI to install the package (we can install a tarball at the command line later on if you didn’t do one in the first Linux class) 3. Edit /etc/fstab and add usrquota and grpquota options to the mount point which contains the home directories. For me this was the root mount point, but it will depends on how you did your partitoning (it could be that you made a separate mount point for /home). sudo gedit /etc/fstab 4. The entry should read something like: # /dev/hda1 UUID=4ea80ca3-37b7-447e-831a-700a38627029 / ext3 defaults,errors=remount-ro,usrquota,grpquota 0 1 5. Add the usrquota,grpquota to the line shown above using an editor, save and exit the file Created by Donna Warren 2/5/2012 

Page 6 

Ubuntu Linux Server Administration II Lab 3    

  6. Finish the setup with the following series of commands sudo touch /quota.user /quota.group sudo chmod 600 /quota.* sudo mount -o remount / sudo quotacheck -avugm quotatool –u username –bq 200M –l ‘250 Mb’ /home 7. The disk quota is now turned on for the user and limits him to 250Mband will warn them when they exceed 200Mb. You can use the repquota to find out what the quotas are.

Task 5: Backups  1. The Ubuntu 11.10 release came with Déjà Dup, a simple Duplicity based backup tool installed by default 2. You can access Déjà Dup on Ubuntu 11.10 by selecting the power icon in the top right corner of your desktop and then System Settings option

3. On the System Settings window select the Backup icon in the lower left hand corner

Created by Donna Warren 2/5/2012 

Page 7 

Ubuntu Linux Server Administration II Lab 3    

  4. This brings up the Backup window which has the four sections shown below. The Overview option shows a summary of your backup and an option to turn on automatic backups. At the bottom of this window you can see the Back Up Now and Restore buttons. Before using these we will need to setup what we are backing up and where we are backing it up to.

5. Click on the Storage option on the left. Now you can choose where you want to backup your Ubuntu system to and choose what folder to use

6. The Folder option lets you set the folder(s) we want to backup and the folder(s) we want to ignore during the backup as shown below

Created by Donna Warren 2/5/2012 

Page 8 

Ubuntu Linux Server Administration II Lab 3    

 

7. The Schedule option includes options to set how often to backup and how long to keep the backups. This corresponds to the automatic backup feature which must be turned on in the Overview section of the backup window

8. Click on the Overview option again, optionally turn on automatic backup, and then select the Back Up Now button in the bottom left of the window

Created by Donna Warren 2/5/2012 

Page 9 

Ubuntu Linux Server Administration II Lab 3    

 

9. Next, you will need to choose an encryption password or allow the backup to be restored without a password. Select allow to restore without a password and click continue. The backup should start

Created by Donna Warren 2/5/2012 

Page 10 

Ubuntu Linux Server Administration II Lab 3    

  10. Take a screen shot of the completion windows and paste it into your Lab 3 document. 11. Now that we've created the backup you can click the Restore button on the Overview section to restore your backup

12. Choose where to restore from

13. Choose what date you want to restore

Created by Donna Warren 2/5/2012 

Page 11 

Ubuntu Linux Server Administration II Lab 3    

 

14. Next you can choose to restore to original locations or to a specific folder.

15. The last thing you have to do is type in the encryption password if you required one while creating the backup 16. Take a screen shot of the last window and paste it into your lab 3 document 17. I don’t care if you actually do the restore. I just wanted you to know how to do it.

 

Created by Donna Warren 2/5/2012 

Page 12 

Ubuntu Linux Server Administration II Lab 3    

 

Task 6: Lab Questions  1. What did you learn from this lab?

2. Was the racing game fun to play?

3. Did you have any problems with the lab? If yes, please list them and explain what you did to try and make it work.

Created by Donna Warren 2/5/2012 

Page 13