Sie sind auf Seite 1von 5

Lab Exercise Chapter 2 Using Files and Directories What this exercise is about: - The exercise guides you

in working with files and directories using AIX basic commands. What you should be able to do: After completing this exercise, you should be able to do the following: - Copy, move, rename, and list the contents of ordinary files - Create, remove and list the contents of directories - Display the name of the current directory - Change directories Introduction Special Instructions: - While performing this exercise, you can easily lose track of where you are in the file structure. Use the pwd command frequently to verify that you are in the directory assumed in the numbered step; otherwise, your results may differ from the printed results. - If permission problems arise during this exercise, check the ownership of the file by requesting a long listing. Checking Your Environment: 1. Log in to the system. Login: Password: team01 team01s password

- Note: Password will either be team01, as set by system administrator in Lab Exercises: Before You Begin, or new password, as changed in Lab Exercise Chapter 1. 2. Use the pwd command to verify that you are in the home directory, /home/team01. This is the directory where you are placed when you first log in. $ pwd 3. Change your current directory to the root directory (/). $ cd /

4. Verify that you are in the root directory and list its contents. $ pwd $ ls 5. Practice using the ls command with the a and R options. The a option displays all the hidden files. The R option displays files recursively in a directory structure; it provides an extensive output. After you have reviewed the information press Ctrl + C to end the command. $ ls a $ ls R 6. Press Ctrl + C 7. Return to your home directory and list the contents, including the hidden files. $ cd $ ls a Working with Files: 1. Copy the next file /usr/bin/cat and the file /usr/bin/cal into your current (home) directory. Next, list the files in your current directory to verify that the files were copied. $ cp /usr/bin/cat /home/team01 $ cp /usr/bin/cal /home/team01 $ ls or $ cp /usr/bin/cat . $ cp /usr/bin/cal . $ ls 2. Look at the contents of the files /etc/motd and /etc/passwd , using the commands cat, pg, and more to see how each command handles the output.

$ cat /etc/motd $ cat /etc/passwd $ pg /etc/motd $ pg /etc/passwd $ more /etc/motd $ more /etc/passwd 3. Turn off the power to the printer attached to your system. Print the file /etc/motd on the system printer. Check the status of your print job. Turn the printer power switch to OFF. $ qprt /etc/motd $ qchk Turn the printer power switch to ON Creating and manipulating directories: 1. Create a subdirectory called myscripts in your home directory. $ mkdir myscripts 2. In an earlier step, you copied two files (cat and cal) to your home directory. Now, move these two files into your new subdirectory (myscripts). As you move them, rename them to mycat and mycal, respectively. $ mv cat myscripts/mycat $ mv cal myscripts/mycal 3. Make the new subdirectory (myscripts) your current directory, and list its contents to confirm the files were copied. $ cd myscripts $ ls 4. List the file named .profile in your home directory, using the mycat command.

$ mycat ../.profile or $ mycat /home/team01/.profile 5. Make your home directory the current directory. $ cd 6. Create another subdirectory in your home directory called goodstuff. $ mkdir goodstuff 7. Copy a file called /etc/profile into the new directory, and give it the new name newprofile. $ cp /etc/profile goodstuff/newprofile 8. Use the cat command to look at the file. If it is too difficult to read, try the pg command. $ cat goodstuff/newprofile $ pg goodstuff/newprofile 9. The file named newprofile is inconvenient to continue typing because of its length. Change the name to np. Next, list the contents of the goodstuff directory to ensure that you have accomplished the task. $ mv goodstuff/newprofile goodstuff/np $ ls goodstuff 10. This is a good time to check your work. Starting from your home directory and working downward, display a hierarchical tree of your files and subdirectories. $ ls R Removing a Directory: 1. Ensure that you are in your home directory. Next, try to remove the goodstuff directory. $ pwd

$ rmdir goodstuff - You are not able to remove the goodstuff directory because it has files in it. 2. Change to the goodstuff directory and list its contents, including any hidden files. Then, remove the files. Again, list the contents of the directory including the hidden files, $ cd goodstuff $ ls a $ rm np $ ls a $ cd .. - Note that the . and .. files remain in the directory. The directory is considered empty even though these two files may be present. 3. Now, remove the directory. $ rmdir goodstuff End of Exercise

Das könnte Ihnen auch gefallen