Lab Exercise 2.3: Managing Linux Files and Directories

 <  Day Day Up  >  

In this exercise, you will work with the various utilities we have introduced in this chapter to complete common file system tasks . The answers are located at the end of this chapter. Complete the following:

Note

In this exercise, you will be presented with several hypothetical situations that will direct you to check several log files for error messages. If your system is running properly, you might not see any error messages at all. That's all right. (In fact, that's good!) The point of the exercise is to give you some experience using the utilities themselves , not troubleshooting actual problems .


  1. Boot your Linux server and authenticate as your student user with a password of novell .

  2. Open a terminal session.

  3. Change to the root user account by entering su - and providing a password of novell .

  4. Suppose you've been having trouble with your Linux server and you want to check the messages file for any entries with the term "error" in it. Complete the following:

    1. At the shell prompt, enter grep -i error /var/log/messages .

      Tip

      Using the “i switch tells the grep utility to ignore case and find any instance of the search string in the specified file .

    2. What error entries were you able to locate?

  5. Suppose an error just occurred again on your system. You need to check the end of the messages file to see what happened .

    1. At the shell prompt, enter tail /var/log/messages .

    2. What are the last 10 messages recorded in the file?

  6. You decide to capture messages as they are written to the messages file in an attempt to catch the error as it occurs. Complete the following:

    1. At the shell prompt, enter tail -f /var/log/messages .

      Note

      The “f switch tells the tail utility to monitor the specified file for changes and display them onscreen as they occur .

    2. Open a new terminal session.

    3. At the shell prompt, enter su - .

    4. Authenticate with a password of novell .

    5. Log out of your superuser session by entering exit .

    6. Check to see the messages displayed by the tail utility.

    7. Exit tail by switching to the terminal session where it is running and pressing Ctrl+C .

  7. Practice mounting and dismounting removable media by completing the following:

    1. Make sure you have root access by entering whoami at the shell prompt. If you aren't logged in as root, use the su command to switch to this user.

    2. Insert your SUSE Linux CD in the server's CD drive.

    3. If it doesn't automount, enter mount -t iso9660 /dev/cdrom/media/ cdrom .

    4. Access the files on the CD by entering cd /media/cdrom .

    5. Generate a listing of files on the CD by entering ls .

    6. Generate a detailed listing of the files on the CD by entering ls -l .

  8. Practice managing files and directories by completing the following:

    1. At the shell prompt, create a new directory named files in /tmp by entering mkdir /tmp/files .

    2. Using either the ls or dir command, pick a file on the mounted CD to copy.

    3. Copy this file to /tmp/files by entering cp ./file_name/tmp/files .

    4. Change to the /tmp/files directory by entering cd/tmp/files .

    5. Verify the file was copied by entering ls -l .

    6. Delete the file you just copied by entering rm ./file_name .

    7. Change to the root directory of the file system by entering cd / .

    8. Delete the directory you created by entering rmdir /tmp/files .

    9. If asked to confirm, enter y .

    10. Dismount the CD by entering umount /dev/cdrom .

    11. Remove the CD from the CD drive.

  9. Practice editing files.

    Warning

    It's important that you complete this step of this exercise. The file created will be used in a lab exercise in the next chapter .

    1. Change to the /tmp directory by entering cd/tmp .

    2. Use vi to create a new text file by entering vi ./scriptfile.txt .

    3. Enter Insert mode by pressing the Ins key.

    4. Enter the following text in the file:

       

       echo "Changing to the /var/log directory." cd /var/log echo "Running grep to check for errors." grep -i error messages cd /tmp echo "The script is now finished." 

       

    5. Exit Insert mode and return to Command mode by pressing Esc .

    6. Save the changes to the file by entering :exit .

    7. Verify that the text of the file has been entered correctly by entering cat ./scriptfile.txt .

    Real World

    If you try to execute the script at this point, you will find that it won't run. You must configure permissions on the file to make it executable. This will be done in the next chapter .


  10. Close the root session by entering exit .

  11. Close your terminal session.

That's it for this exercise. You should now know how to use the su , grep , tail , whoami , mount , ls , mkdir , cp , rm , rmdir , and umount commands. In the next chapter, you'll learn about users, groups, and permissions. After that, you'll be ready to install your own NNLS implementation.

 <  Day Day Up  >  


Novell Certified Linux Engineer (CLE) Study Guide
Novell Certified Linux Engineer (Novell CLE) Study Guide (Novell Press)
ISBN: 0789732033
EAN: 2147483647
Year: 2004
Pages: 128
Authors: Robb H. Tracy

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