You are on page 1of 3

LAB 2: SYSTEM HIERARCHY AND BASIC COMMANDS

SYSTEM HIERARCHY

1|P ag e
LOGGING IN, LOGGING OUT AND SWITCH USER

Logging In

User: Login using your user name and password you set earlier.
Note: Don’t enter
Root: login using root password you set earlier <username> in your
command. You have to
Switch User enter your own username
Switch user to normal user: using command su <username> without the < >

Switch user to root user: using command su -

Logging out

Apply command exit or logout or Ctrl + D (close the terminal)

NOTE: you may refer to the manual in the system by enter man login or man exit

FINDING YOURSELF

To find out the name of the current directory, enter pwd

To find out the name of current directory and its contents, enter ls ; pwd

To find who are you, enter whoami

NOTE: you may refer to the manual in the system by enter man whoami

LISTING DIRECTORIES AND FILES WITH ls

To list the files and directories of the directory you are in, enter ls
Note: directory name is
To list the files and directories of a specified directory, enter ls /bin changeable

CHANGING DIRECTORIES WITH cd


Note: directory name is
To change directories, enter cd /Home changeable

To move up one level in the directory tree , enter cd ..

To move to a specific directory , cd projects


Note: directory name is
changeable

2|P ag e
Exercise:

Task: Change Directories and List Directory Contents


1. Log in with your username and password. (ex:Username = wserver1 password=password1)
2. Start your terminal.
3. Change to /tmp directory by entering cd /tmp
4. Display the name of the active directory by entering pwd and see the result.
5. Change to the home directory by entering cd ~
6. Display the name of the active directory by entering pwd
7. Change to the /usr/share/doc directory by entering cd /usr/share/docs and enter ls to view the
content of this file.
8. Display the name of the active directory by entering pwd
9. Change back to the last directory (home) by entering cd ~
10. Display the name of the active directory by entering pwd
11. Display the content of the current directory by entering ls
12. Display the content of the current directory, including the hidden files, by entering ls -a
13. View the permission and the file size of all the files in the current directory by entering ls -la
14. Close the terminal window by entering exit

NOTE: you may enter more than one terminal and login with more than one user by click Open
New Tab.

3|P ag e

You might also like