4
School of Engineering (TAFE) ISYS5671C UNIX Unix Lab 1 Booting into a Linux System and Using Basic Commands Aims: To boot into a Linux system To use basic commands in the command line interface to navigate the file system o cd cd .. To examine and use the help facility within Linux o man To find the path of the current directory o pwd To examine directory contents o ls ls –a ls -l To obtain a calendar and the current date o cal date To change to the root user o su user su – user To open and use multiple command windows To identify the current user o whoami To shut the system down from the command line in an orderly way o shutdown –h now 1. Boot into OpenSUSE using the Live CD Do not install SUSE or any software to the hard drive o You will run SUSE directly from the CD o Note: there is no password set with OpenSUSE Live 2. Examine and explore the user interface Make a brief note of the facilities offered by this distribution 3. Open the command line terminal The command prompt line shows linux@linux:~> This means that user linux is logged on to a computer also named linux The prompt ~> means a non root user is logged on 4. Examine the directory structure: To change to the parent directory of the current directory key in cd .. o You will see command prompt line change to linux@linux:/home> /home indicates that the directory home is situated under the root (/ )directory The root directory is the base directory of the Linux system Key in key in cd .. Document: document.doc Author: George Listopad Save Date: 12/03/2011 RMIT University Page 1 of 4

Unix Directory Navigation

Embed Size (px)

DESCRIPTION

Unix Lab 1 Booting into a Linux System and Using Basic Commands

Citation preview

School of Engineering (TAFE)ISYS5671C UNIX

Unix Lab 1 Booting into a Linux System and Using Basic Commands

Aims: To boot into a Linux system To use basic commands in the command line interface to navigate the file system

o cd cd .. To examine and use the help facility within Linux

o man To find the path of the current directory

o pwd To examine directory contents

o ls ls –a ls -l To obtain a calendar and the current date

o cal date To change to the root user

o su user su – user To open and use multiple command windows To identify the current user

o whoami To shut the system down from the command line in an orderly way

o shutdown –h now

1. Boot into OpenSUSE using the Live CD Do not install SUSE or any software to the hard drive

o You will run SUSE directly from the CDo Note: there is no password set with OpenSUSE Live

2. Examine and explore the user interface Make a brief note of the facilities offered by this distribution

3. Open the command line terminal The command prompt line shows linux@linux:~> This means that user linux is logged on to a computer also named linux The prompt ~> means a non root user is logged on

4. Examine the directory structure: To change to the parent directory of the current directory key in cd ..

o You will see command prompt line change to linux@linux:/home> /home indicates that the directory home is situated under the root (/ )directory

The root directory is the base directory of the Linux system Key in key in cd ..

o The prompt changes to linux@linux:/> Key in key in cd ..

o The prompt remains at linux@linux:/> You have now reached the root (/ )directory of the system and can go no further

To navigate back down the directory tree to your original location key in the following and observe the effect:o cd home

The command prompt line changes to linux@linux:/homeo cd linux

The command prompt line changes to linux@linux:~>Document: document.doc

Author: Save Date: 12/03/2011

RMIT University Page 1 of 3

School of Engineering (TAFE) You are now at the original point when you first opened the command screen

To summarise: o To move up one level from child directory to parent directory use cd ..o To move down one level from parent directory to child directory use cd child_directory_name

To move directly to the root directory key in cd /. Do this To move directly to the home directory of the current user key in cd. Do this To move directly to any directory key in cd path_from_root_directory_to_desired_directory

o Key in cd /home and observe the effectTo find your current location with respect to the root directory – ie the path to your current directory –

key in pwdo If you are in the user linux home directory you will see /home/linux

In your lab journal explain the meaning of /home/linux Summarise the above commands clearly in your lab journal

5. Use the commands from step 4 to: Show the path from the root directory to the default user linux directory Record this information in your lab journal

6. The help facility within Linux may be accessed from the command line using the command man Key in man man to obtain help on the manual. The manual is a short form help file which may

appear cryptic and somewhat difficult to understand for the first time user. The best strategy in learning to use it is to persevere over time. o Key in q to quit man

7. Listing the contents of a directory using the command ls: Return to the default user’s home directory

o The command prompt line should show linux@linux:~> Key in the command ls

o In your lab journal write the information that you see To examine the function and the options for the command ls key in man ls at the command

prompto Read the effect of the switch –a

man states: do not ignore entries starting with . Directory entries starting with . indicate hidden files The switch option ls –a displays all files including hidden files

o Read the effect of the switch –l man states: use a long listing format The file and directory attributes will be shown

Quit man and key in ls –ao In your lab journal note and explain the effect ls –a compared to ls

At the command prompt key in ls –l o In your lab journal note and explain the effect ls –l compared to ls

8. The calendar may be obtained using the command cal: Key in man cal to find the options for using cal

o cal will show the current month of the current yearo cal Y will show the calendar for all months of the year Y

Y is a number that represents the year Note 10 will show the calendar for the year 10, not 2010

o cal M Y will show the calendar for the month M (where M is a number that represents the month) of the year Y

Experiment with the cal command:o Show the calendar for the current month of the current year

Document: document.docAuthor:

Save Date: 12/03/2011RMIT University Page 2 of 3

School of Engineering (TAFE)o Show the calendar for the year 12o Show the calendar for June of the 1895

9. The current date may be obtained using the command date: Key in man date to find the options for using date Experiment with the command

10. It is necessary to change users from time to time particularly when performing administrative tasks that can only be done by the root user. The command to do this is:

su – usero This changes the user to user and also changes the current directory to the user user home

directory Example key in su – root

o The prompt will change to linux:~# The # indicates the root user

o Key in pwd The screen will show /root which is the home directory of the root user

What is the difference between the home directory of the root user and the root directory? Write your response in your lab journal.

Key in su – linux to change the user to linux and the current directory to the user linux home directory. o Explain in your lab journal how you would verify this is so

Now key in su rooto Explain in your lab journal how this is different from the previous command

11. When multiple users have access to the system it is helpful to be able to identify who is using the current window. The command to do this is whoami

Key in whoami at the command prompt Write the response in your lab journal and explain what it means.

12. It is often helpful to have multiple command windows open, particularly for debugging purposes. Open a second command window Change user to the root user Note that both windows run independently of each other

13. Experiment with the above commands to commit them to memory

14. Shutdown Linux in an orderly way using the shutdown command: Use man to find the options for the shutdown command Key in shutdown –h now The system will shut down

15. Research assignment to complete this lab: Discuss the relationship between Linux and Unix Research and explain:

o A short history of SUSEo SUSE distributions currently availableo How you would obtain a copy of SUSE for yourself from the Interneto How you would produce a usable CD or DVD for your own use

Document: document.docAuthor:

Save Date: 12/03/2011RMIT University Page 3 of 3