Lab Questions


The Red Hat exams are unique based on their reliance on labs and hands-on demonstrations. With these questions, you're practicing the skills you need on both Red Hat exams.

Lab 1

1. 

This lab assumes you have a new hard disk (or at least empty space on a current hard drive where you can add a new partition). You can simulate a new hard disk by adding appropriate settings to a VMware or Xen virtual machine. In this lab, you'll create a new partition using parted, format it, transfer the files currently on your /home (or if you don't have a lot of space, /tmp) directory to that partition, and revise /etc/fstab so the new partition is properly mounted the next time you boot Linux.

If you have a limited amount of available space, dedicate only half of it to this lab and leave the other half empty for Lab 2.

image from book

Answers

1. 



  1. If you've been able to add a new hard drive, you should be able to review it from the (parted) prompt. But make sure to open the appropriate drive. For example, if it's the second SATA drive, do so with the parted /dev/sdb command.

  2. Run the print command from the (parted) prompt. If it's a new drive, you'll see an "unrecognized disk label" message and can run mklabel to add an msdos label as described in the chapter. Otherwise don't run mklabel!

  3. Make a note of available space in your partitions.

  4. Create the new partition. The mkpart command provides prompts that help you define the new partition. If the partition is on a new hard drive, create a primary partition. Otherwise, you may be able to create only a logical partition.

  5. Use the prompts to define the size of the partition from the start and ending MB location on the drive. As noted in the lab, make sure the size of the partition is half the available free space.

  6. Run print again to confirm your changes. Make a note of the partition number. For example, if you've created partition 1 on /dev/sdb, the partition device file is /dev/sdb1.

  7. Run quit to exit from parted. Run the partprobe command to make Linux reread the partition table (without rebooting).

  8. Format the partition. Assuming you're using the default Red Hat format, use the mkfs.ext3 partitionname command; substitute the device file for partitionname.

  9. Mount the new partition on a temporary directory; I often create a /test directory for this purpose. For the aforementioned partition, the command would be mount /dev/sdb1 /test.

  10. Copy all of the files recursively from the directory that you're going to mount on the new partition. For example, if you're moving the files from the /home directory using the noted partitions, the command would be cp -ar /home/* /test.

  11. Unmount /test from the new partition with a command like umount /test.

  12. Mount the new partition such as /dev/sdb1 on the /home directory.

  13. Review the results. Are the files you transferred on the new partition?

  14. When you're confident of your new configuration, unmount /home from the new partition. You can then delete the files from the /home directory mounted on the old partition, allowing you to use the space for other directories.

Lab 2

2. 

In this lab, you'll add a new swap partition using the fdisk utility. Remember to make the partition work with the appropriate file type, and then format and activate it. Make sure it's properly included in /etc/fstab so this partition is used the next time you boot Linux.

image from book

Answers

2. 

In this lab, you'll add a new swap partition using the fdisk utility. Remember to make the partition work with the appropriate file type, format, and activate it. Make sure it's properly included in /etc/ fstab so this partition is used the next time you boot Linux.

  1. If you've completed Lab 1, you presumably have half the free space-from either an existing or a newly installed drive-still available.

  2. Use fdisk to open the drive with free space. You may need to be specific. The fdisk -l command can help you define the drive with free space, such as /dev/hdc. In that case, run the fdisk /dev/hdc command to edit that drive's partition table.

  3. Add a new partition using existing free space. From the fdisk prompt, the p command prints defined partitions, including the one you just created. Make sure to change the partition type; the t command from the fdisk prompt allows you to change the partition number you just created to the Linux swap system ID (82).

  4. Write your changes from fdisk; if you want to reread the partition table without rebooting, use the partprobe command.

  5. Format the new partition to the Linux swap filesystem: for example, if the new partition is on /dev/hdc3, you'd run the mkswap /dev/hdc3 command.

  6. Once the format process is complete, you can immediately activate this partition with the swapon /dev/hdc3 command.

  7. But that's not it. You need to make sure that swap partition is activated the next time you boot. To do so, you need to add information associated with that partition to /etc/fstab. One line that would work in this case is:

     /dev/hdc3    swap    swap     defaults    0 0 

    In many cases, this may look different from the first swap partition, probably created when you first installed RHEL. If the swap filesystem is on a logical volume, it might look like:

     /dev/VolGroup00/LogVol01    swap    swap    defaults    0 0 

    Alternatively, a swap partition on a different location such as /dev/hda3 might have a directive such as:

     LABEL=SWAP-hda3    swap    swap    defaults    0 0 

    The differences don't matter with respect to the Red Hat exams (unless otherwise specified), as the result is what matters.

Lab 3

3. 

In this lab, you'll configure the automounter on your computer on an NFS connection, using two different methods. You'll need a second computer with Linux or Unix installed, and a shared NFS directory. You can use the shared NFS installation source created in Chapter 2 or any other shared NFS directory described in Chapter 10. A virtual machine such as a VMware computer qualifies as a second computer.

  1. Back up your current /etc/auto.master and /etc/auto.net configuration files.

  2. Open the /etc/auto.master configuration file in the text editor of your choice. Add or activate the command that applies the automounter to the /net directory.

  3. Open the /etc/auto.misc configuration file. Use the example shown in this file to create an NFS entry that points to the shared NFS directory on the second computer. For the purpose of this lab, I'll assume the name of the directory to test. Substitute accordingly.

  4. Restart the autofs server.

  5. Try your connection. Run the following command:

     # ls /misc/test 

  6. You should see the contents of the shared NFS directory. Run the following command. What do you see?

     # ls /misc 

  7. Wait a while, at least the timeout specified in the /etc/auto.master configuration file.

  8. Run the ls /misc command again. What happens?

  9. Once you're satisfied with the result, restore the files you backed up in step 1.

  10. Use the /etc/auto.net servername command to see NFS shares on the NFS server. Substitute the hostname or IP address for servername here and in the following steps.

  11. Run the ls /net/servername command. You should see the NFS shares listed, including test.

  12. Run the ls /net/servername/test command. You should see the contents of the NFS share named test.

image from book

Answers

3. 

Configuring the automounter on a shared NFS directory is easier than it looks. Before you begin, make sure that you can mount the shared NFS directory from the remote computer. Resolve those problems first before beginning this lab. Refer to Chapter 2 on creating an NFS installation server or Chapter 10 on NFS for more information. If there's no problem with a source on an NFS server with an IP address of 192.168.30.4, you should be able to mount it locally. For example, you can mount a shared remote NFS /inst directory on an existing empty local /test directory as follows:

 # mount -t nfs 192.168.30.4:/inst /test 

Whatever you do, it's important to back up any files that you're about to edit. In this case, there are two configuration files that should be backed up: /etc/auto.master and /etc/auto.misc. Make sure the following directives are active in /etc/auto.master:

 /misc /etc/auto.misc /net -hosts 

In /etc/auto.misc, the following commented directive provides a template for one way to connect to a shared NFS directory:

 #linux -ro,soft,intr ftp.example.org:/pub/linux 

When active (remove the #), this would mount the NFS share /pub/linux from ftp.example.org on the /misc/linux directory. Substitute accordingly. Based on the conditions described in the lab, you would substitute test for linux, 192.168.30.4 for ftp.example.org, and test for /pub/linux.

Now you can restart the autofs server; the quickest way is with the following command:

 # service autofs restart 

Now when you test the result, you should be able to see the contents of the shared NFS directory from the remote system with both of these commands:

 # ls /misc/test # ls /net/192.168.30.4/ 

You can test the result in a different way. Once you've connected to all available systems, the following command should reveal the systems with available NFS shares:

 # ls /net 192.168.30.4 

Please, retry this lab with other shared NFS directories.

Lab 4

4. 

In this lab, you'll configure access for the supervisor named Donna to the project.odt OpenOffice .org writer file in John's home directory, /home/john. Remember that you'll need to remount the appropriate partition, revise /etc/fstab, change permissions to /home/john, and set the ACL permissions to allow access by Donna.

image from book

Answers

4. 

As described in this chapter, you'll first have to change the mount of the filesystem with the /home directory to include ACL settings. For example, if /home isn't mounted separately from the top level root (/) directory and is part of /dev/VolGroup00/LogVol00, you can remount the filesystem with the /home directory with the following command:

 # mount -o remount -o acl /dev/VolGroup00/LogVol00 / 

Needless to say, you'll also want to add acl to the appropriate line in /etc/fstab; it might look like this (obviously, it varies with the partition, mounted directory, and LABEL):

 /dev/VolGroup00/LogVol00 / ext3 defaults,acl 1 1 

Now with these settings, allow others to execute in John's home directory:

 # chmod 701 /home/john 

Now you can set ACLs to allow Donna access to John's home directory:

 # setfacl -m user:donna:r-x /home/john/ # setfacl -m mask:r-x /home/john/ 

Next, configure individual files with ACLs. The file in question is project.odt in John's home directory. Deny access to all users but the owner:

 # chmod 700 /home/john/project.odt 

To check the result, log into your own account and try opening abc from Donna's home directory. You should see the [permission denied] message.

Now set read-write permissions in the ACLs for the project.odt file with the following commands:

 # setfacl -m user:donna:rwx /home/john/project.odt # setfacl -m mask:r-x /home/john/project.odt 

Now user Donna can do what she needs with the project.odt file in John's home directory. You can confirm the changes with the getfacl /home/john/project.odt command.

To simplify the test process, you can use a separate console to log into Donna's account. If you're working from the administrative root account, you can log into Donna's account with the su - donna command.



RHCE Red Hat Certified Engineer Linux Study Guide (Exam RH302)
Linux Patch Management: Keeping Linux Systems Up To Date
ISBN: 0132366754
EAN: 2147483647
Year: 2004
Pages: 227
Authors: Michael Jang

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net