CST8177 - Lab 2 Review #1
Student Name |
Student number |
Section |
|
|
|
Objectives
To review command line features, file system access, and permissions
Lab Outcome
A review of working with the command line
A review of basic Linux utilities
Additional Notes
If you are uncertain as to how to proceed or have any problems, refer to class notes from previous for more information, your textbook, and the man pages.
In-Lab Demo: Display the home directories for root and any other user using both absolute and relative path from yet another user's home directory.
Exercise #1: Working with relative and absolute path
Answer the questions below based on the following directory structure:
/
/etc
/root
/home
/home/andrew
/home/andrew/department
/home/andrew/department/chair
Your current location in the directory structure is the root (/) directory, and you are logged in as regular user andrew.
Record the absolute path for chair:
[andrew @college /] $ __________________________________________
Record the relative path for the file chair:
[andrew @college /] $ __________________________________________
Given the prompt below, identify the result of the command
[andrew @college home] $ cd ~
________________________________________________________________
What command do you need to use to see andrew's present working directory?
[andrew @college /] $ __________________________________________
Record the result of that command:
________________________________________________________________
Log in again as root with the current directory as /home/andrew
Record the relative path to the root account's home directory:
[root @college andrew] # _______________________________________________
Record the relative path to andrew's home directory:
[root @college home] # _________________________________________________
Record the absolute path to andrew's home directory:
[root @college home] # _________________________________________________
Note: Linux is designed for multi-user, multi-tasking, network-based operation, so a user's home directory is typically more important to a user than the system's root or other system directories.
Exercise #2: Working with standard commands
Log in as root. Create two a user accounts, user1 and user2.
Log in as user1. Record the command prompt below by filling in the three blank fields:
[__________(1)____________@localhost__________(2)______________]__(3)__
What does each entry refer to?
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
Create a directory named temp.
[user1 @localhost ~] $ ______________________________________
List the directory entry, including all file attributes and the inode number, to confirm the creation of temp
[user1 @localhost ~] $ ______________________________(command)
______________________________________________________________
______________________________________________________________
List all attributes shown above(there are eight fields of which one is the date/time; count the first letter of the permissions as a separate attribute) and briefly define each:
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
Change ownership of the directory temp to user2
[user1 @localhost ~] $ _______________________________________
What is the result? _______________________________________________
Change the permissions of temp to allow others no access, the group members no write access and full access for the owner:
Change the permissions using absolute (octal) mode
[user1 @localhost ~] $ _______________________________________
Show the change the permissions again, using symbolic mode
[user1 @localhost ~] $ _______________________________________
Create an empty file file in the temp directory
[user1 @localhost ~] $ _______________________________________
Rename file to empty-file
[user1 @localhost ~] $ _______________________________________
Delete the directory temp and the file empty-file in a single command (no semicolon)
[user1 @localhost ~] $ _______________________________________
Switch to user2
[user1 @localhost ~] $ _______________________________________
Record the command prompt:
[ _________________________ @ hostname ___________________________ ] _______
Switch to root., changing to root's environment:
[user1 @localhost ~] $ ______________________________________
Record the command prompt again:
[ ________________________ @ hostname __________________________ ] ______
Exercise #3: Switching logon id – the su command
Switch to user1., then run these command, displaying both the command and its output.
The whoami command tells you the userid you are logged in as; try it.
[user1 @localhost ~] $ _______________________________________
______________________________________________________________
The id command also gives you uid and gid numbers, and group memberships
[user1 @localhost ~] $ _______________________________________
______________________________________________________________
The environment variable for your path is PATH. Display it (write down only the beginning and end if it's too long for this space):
[user1 @localhost ~] $ _________________________________________________
______________________________________________________________
Switch to root, changing to root's environment. Repeat the three commands above:
whoami: _______________________________________________________
id: __________________________________________________________
$PATH: ________________________________________________________
Use the exit command or a Control-D (^D; end-of-file for stdin) and whoami again:
whoami: ________________________________________________________________
Exercise #4: Executing commands
Log in as user1.
To view the directories that Linux searches when looking for a command
[user1 @localhost ~] $ echo $PATH
Record the path: ______________________________________________________________
_____________________________________________________________________________
[ user1 @localhost ~] $ whereis ls
_____________________________________________________________________________
[user1 @localhost ~] $ ls
_____________________________________________________________________________
Does this command execute? Why?
Record your answer: ___________________________________________________________
[user1 @localhost ~] $ grcat
_____________________________________________________________________________
Does this command execute? Why?
Record your answer: ___________________________________________________________
[user1 @localhost ~] $ /usr/libexec/awk/grcat
_____________________________________________________________________________
Does this command execute? Why?
Record your answer: __________________________________________________________
Record the result of the last command in this sequence:
[user1 @localhost ~] $ echo $PATH
[user1 @localhost ~] $ PATH=
[user1 @localhost ~] $ echo $PATH
_____________________________________________________________________________
[user1 @localhost ~] $ ls
_____________________________________________________________________________
Does this command execute? Why?
Record your answer: ___________________________________________________________
[user1 @localhost ~] $ /bin/ls
_____________________________________________________________________________
Does this command execute? Why?
Record your answer: ___________________________________________________________
Terminate this shell, since its PATH is damaged; use ^D or:
[user1 @localhost ~] $ exit
Login with your user1 id. This will reset your PATH to the default settings, but check:
[user1 @localhost ~] $ echo $PATH
Copy the (binary) file /bin/pwd to your home directory and name it mypwd.
[user1 @localhost ~] $ _______________________________________
Now run the pwd copy from your home directory:
[user1 @localhost ~] $ mypwd
_____________________________________________________________________________
Does this command execute? Why?
Record your answer: ___________________________________________________________
Run the pwd copy from your home directory again, but this time specify the path ./:
[user1 @localhost ~] $ ./mypwd
_____________________________________________________________________________
Does this command execute? Why?
Record your answer: ___________________________________________________________
Delete the pwd copy from your directory:
[user1 @localhost ~] $ ___________________________________________