Linux_Lab_File_Handling by linzhengnd

VIEWS: 5 PAGES: 14

									Exercises Lab 1 Getting Started

(After an install of Red Hat Fedora Core – Get it free here: http://fedoraproject.org/wiki/ )

1. Write down the password that you entered during installation for the root
administrator .


2. At the login prompt, enter the username root .

3. At the password request prompt, enter your root username password . The password is
not echoed to the screen for security reasons.

4. We have now logged into the Linux system. But hold on – we cannot leave the system
up and running forever, at some point we are going to have to shut it down. Never shut
down the system by just hitting the power button – data may be lost! At this time you
should have a prompt on the screen that appears similar to the following:

root@hostname root#

Enter the command:
shutdown –h now
It is important to remember that Linux is case sensitive. If you entered Shutdown or
SHUTDOWN, the command will not work. This halts (–h) the system immediately (now)
– by now you should see a lot of data streaming across your screen during the shutdown
process. Ok, now it says System Halted.

5. Power cycle the computer to reboot.

6. Again log in as the root username and enter your password.

7. At times we need to log onto the computer as another user. There are two ways of
doing this, for now we will use the logout command – the latter will be explained later.
At the command prompt, enter the command
# logout .

8. You are now back at the login prompt. One more time log in as the administrator with
the correct password.

9. Sometimes we wish to reboot rather than halt the system. At the prompt, enter the
command
# shutdown –t 30 –r 2 Goodbye All
This reboots (–r) the system in two minutes, but 30 seconds prior to the shutdown, issues
a message across the network that it is shutting down.
10. Lets finish up this lab by shutting down the system again – but it sure is cumbersome
to type in the whole shutdown –h now command. An easier way is to use a different set
of commands that do the exact same process.
These are:
New Command                Same as
halt                       shutdown –h now
reboot                    shutdown –r now
powerdown                 shutdown –h now
                          powers down the computer if BIOS supported
                          (not supported by Red Hat)
Case Study

As an administrator, a user calls you saying that they have forgotten their password.
What actions must you take as an IT administrator in order to set the user so they may
operate again?
Exercises Lab 2 Directory Structure

1. Log into the system as the root administrator and enter your password.

2. Copy down the prompt. It should appear something like root@hostname etc# If it does
not, then you did not log on as the root administrator.

________________________________________________________________________

3. Issue the command cd /etc/rc.d/init.d.

4. Copy down the prompt.

________________________________________________________________________


5. Issue the command pwd.

6. Copy down the response.

7. Issue the command cd /var/named.

8. Issue the command pwd.

9. Copy down the response.
_
_______________________________________________________________________


10. Issue the command cd –.

11. Issue the command pwd.

________________________________________________________________________


12. Copy down the response.

13. Issue the command cd.

14. Issue the command pwd.

15. Copy down the response.

________________________________________________________________________
Case Study

As the Network Administrator, you need to assist a user. At their system the prompt
specifies the following: [jsmith@122ca etc]$ . What would you infer from this, and
could it have alternative meaning?
Exercises Lab 3 Listing Directory Contents

1. Log in as the system administrator “root”.

2. Issue the command pwd . What is the path?

________________________________________________________________________


3. Issue the command ls. What do you observe?

________________________________________________________________________


4. Issue the command ls –l . In an abbreviated form, what do you observe?

________________________________________________________________________

________________________________________________________________________


5. Issue the command ls –a. In an abbreviated form, what do you observe?

________________________________________________________________________

________________________________________________________________________

6. Issue the command cd /var.

7. Issue the command pwd . What is the path?

________________________________________________________________________


8. Issue the command ls. What do you observe?

________________________________________________________________________


9. Issue the command ls –l . In an abbreviated form, what do you observe?

________________________________________________________________________


10. Issue the command ls –a. In an abbreviated form, what do you observe?
________________________________________________________________________


11. Issue the command ls – i . Record the inode value for each file and directory. inode
filename inode filename


________________________________________________________________________

________________________________________________________________________
Case Study

A user wants to run a specific application and needs to maintain information with
privileged information. When they attempt to search the directory for it, they could not
find the file. How would you explain the application working, but not being able to see
the file?
Exercises Lab 4 Root

In your own words, explain the meaning of:

1. The Root

________________________________________________________________________


2. Administrator Root

________________________________________________________________________


3. Home directory Root

________________________________________________________________________

4. Group Root


________________________________________________________________________

5. What is the difference between the user root and group root.


________________________________________________________________________
Exercises Lab 5 Editing Files

1. Log onto the system as the administrator.

2. At the moment we need to create a new directory and then change to it. Issue the
command:
mkdir /lab
Then change to the /lab directory.

3. Note your location.

Prompt: ____________________________________________________________

Full working Path: ____________________________________________________

4. Issue the command touch testfile.

5. Issue the command ls –l testfile. Record the results of the display.

Filename: ___________________________________________________________

File Attributes: ________________________________________________________

File Owner: ___________________________________________________________

File Group: ___________________________________________________________

File Size: _____________________________________________________________

File Creation Date: _____________________________________________________


6. Issue the command vi testfile2. You have now opened the vi editor to a new file called
testfile2. You are in the command mode. Enter the command the letter “ i ”. You are now
in the insert mode, able to type in text.

7. Enter the following text:

Name: {your name}
IP Address: {your system IP address}
File: testfile2 using vi
I am a great student and am working hard to prove myself as
an A student!

8. Strike the ESC key. This places you into the command mode. If you hear additional
beeps from the (small) computer speaker, you are already in the command mode.
9. Enter the command “ :w ”. This saves the text to the hard drive.

10. Enter the command “ :q ”. This exits the vi editor.

11. Enter the command vi testfile3.

12. Enter the following text:

Name: {your name}
IP Address: {your system IP address}
File: testfile3 using pico
My classmates are great people too.

13. List the contents of the directory. Record the results.
Exercises Lab 6 Listing a File’s Contents

1. Log in as the administrator.

2. What is the path? ______________________________________________

3. Change to the /lab directory.

4. Record the full path of the directory. (if it is not /lab, you made an error)

________________________________________________________________________


5. Using the vi text editor, create a new file called test1.

6. Insert into the test1 file the following:

Test file 1.
My name is {your name}.
I am learning Linux.

7. Save the file (look at the bottom of the screen to WriteOut the file). Then exit.

8. Using the vi text editor, create a new file called test2.

9. Insert into the test2 file the following:

Test file 2.
Created by {your name}.
This is a simple file.

10. Save the file and exit.

11. Issue the command cat test1 . Record what you observe.

________________________________________________________________________

12. Issue the command cat test2 . Record what you observe.

________________________________________________________________________

13. Issue the command cat test1 test2 . Record what you observe.

________________________________________________________________________
14. Issue the command more test1 . Record what you observe.

________________________________________________________________________

15. Issue the command history | more . Scroll down through the file. Try to scroll up.
(Note that only the space bar will scroll through the file. The “ | ”, or pipe, will be
dicussed later.) Record what you observe.

________________________________________________________________________

16. Issue the command less test2 . Record what you observe.

________________________________________________________________________

17. Issue the command history | less . Scroll up and down through the file using both the
Up / Down Arrow keys and the Page Up / Down keys.

18. Issue the command history | head . Record what you observe.

________________________________________________________________________

19. Issue the command history | tail . Record what you observe.

________________________________________________________________________

20. Issue the command history | tac . Record what you observe.

________________________________________________________________________

21. Issue the command cat > test3 and hit ENTER.

22. Enter the following lines:

Test file 3.
Created by {your name}.
Created using the cat command.
{on this line, enter a CTRL-D}

23. Display the file with the cat command, record your observations.

________________________________________________________________________
Case Study

1. Test to see if the two files (test1 and test2) may be displayed by different display
utilities. Discuss your findings.
2. Compare the differences between the output of the following:
cat –E testfile3
cat –n testfile3
hexdump –c testfile3
od –ta testfile3
od –tc testfile3
xxd testfile3
Record your observations:

								
To top