Introduction To UNIX File System

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Operating System Lab

Lab 4
Introduction to UNIX File System

Part I. The mkdir (make directory) command creates a new subdirectory under your
working directory or any other directory you specify as a part of the command.

1. Use pwd command to check your working directory. Output of pwd should be similar to:
/home/username
2. Create a directory named memos. i.e. type mkdir memos.
3. Type ls and check if directory named memos is created.

Part II. The cd (change directory) command is used to change directory.

1. Type cd command. This command will take you to your home directory.m
2. Type pwd to check if you are in your home directory. i.e. /home/username
3. Type cd memos to change your working directory to memos, and then check your
working directory by pwd command. Output of pwd should be /home/username/memos
4. Create another directory called box, and change your directory to box. Again check your
working directory with pwd. Output of pwd should be /home/username/memos/box
5. Type cd .. this command will take you one directory up. Check if your working
directory is memos.
6. Repeat 1 to return your home directory. i.e. type cd.

Part III. In this part you will learn how to copy, move and erase files. cp (copy) command is
used for copying files, mv (move) command is used to move files and rm (remove)
command is used to erase files. In this section it is assumed that in your home directory
these files are present ayse.txt, ali.txt, lena.log, sky.to and loop.co, if not create these files
using pico or gedit editor.

1. Use man command to get help on these commands: cp, mv and rm.
2. Copy lena.log into memos directory. i.e. cp lena.log memos.
3. Change your directory to memos and check if lena.log is there. i.e. use ls.
4. Remove lena.log by using rm command. i.e. rm lena.log. Then check if it is erased.
5. mv command can also be used to rename filenames. i.e. mv ayse.txt veli.dat will
rename ayse.txt as veli.dat.
6. Type cp veli.dat elena.rtr. What is the difference of this command from the
command investigated in step 5.

Part IV. In this part following directory structure will be created and tree command will
be investigated.
1. Type tree command to see directory structure under your home directory. This
command also displays the number of directories and files. i.e. tree ~.
2. Use mkdir command to create the directory structure shown below.

Submitted By: Ali Murad


Submitted To: Muhib Khan
Operating System Lab

3. Return to your home directory and type tree to see if the shown directories are
created
correctly: type cd and then tree. Show your work to the instructor.

4. Return to home directory and try to change your working directory to pop directory by
writing a single command. i.e. cd star/music/pop. And confirm by pwd command.

5. Copy all the files starting with character a to fire directory. i.e. cp ~/a*.*
~/star/fire. Please note that the tilde (~) used before slash (/) means home
directory.

6. Change your working directory to fire and remove all the files inside this directory.

7. Remove fire directory as well. i.e. you should use rmdir command.

8. The -p (i.e., parents) option creates the specified intermediate directories for a new
directory if they do not already exist. For example, it can be used to create the following
directory structure: mkdir -p food/fruit/citrus/oranges.

9. Type tree to check what directory structure has been created in step 8.

Part V. The rmdir (remove directory) command is used to remove directory.

1. Use rmdir command to remove all the directories under the star directory. Hint: start
form the inner directories (i.e. pop), the directory that you wish to remove should be
empty. Show that you remove all the directories correctly to the instructor.

Note: The commands learned in this lab section will be used in the subsequent laboratory
work.

Submitted By: Ali Murad


Submitted To: Muhib Khan
Operating System Lab

Carefully read the description of the corresponding lab. The lab outline contains background for
the lab and directions for doing the lab procedure. There may also be handouts or other materials
you have access to. By the help of a LiveCD of Ubuntu you can study to the corresponding lab
without making any changes to your machine. Answers of the preliminary Lab Questions must
be handled at the beginning of the laboratory. A full printable version of this sheet is available
online.

1. What is the overall purpose of the lab?

: To learn about Ubuntu operating system and learn commands of Ubuntu operating system and
how to move, rename a files and how to make a directories.

2. What is the meaning of the following command: “mv file1.txt file2.dat”


NAME
mv - move (rename) files

SYNOPSIS
mv [OPTION]... [-T] SOURCE DEST
mv [OPTION]... SOURCE... DIRECTORY
mv [OPTION]... -t DIRECTORY SOURCE...

DESCRIPTION
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

Mandatory arguments to long options are mandatory for short options


too.

--backup[=CONTROL]
make a backup of each existing destination file

-b like --backup but does not accept an argument

-f, --force
do not prompt before overwriting

-i, --interactive
prompt before overwrite

-n, --no-clobber
do not overwrite an existing file

If you specify more than one of -i, -f, -n, only the final one takes
effect.

Submitted By: Ali Murad


Submitted To: Muhib Khan
Operating System Lab

--strip-trailing-slashes
remove any trailing slashes from each SOURCE argument

-S, --suffix=SUFFIX
override the usual backup suffix

-t, --target-directory=DIRECTORY

3. What is the function of “rmdir” command?

NAME
rmdir - remove empty directories

SYNOPSIS
rmdir [OPTION]... DIRECTORY...

DESCRIPTION
Remove the DIRECTORY(ies), if they are empty.

--ignore-fail-on-non-empty

ignore each failure that is solely because a directory

is non-empty

-p, --parents
remove DIRECTORY and its ancestors; e.g., `rmdir -p a/b/c' is
similar to `rmdir a/b/c a/b a'

-v, --verbose
output a diagnostic for every directory processed

--help display this help and exit

--version
output version information and exit

Submitted By: Ali Murad


Submitted To: Muhib Khan
Operating System Lab

4. What Unix command is used to create a new directory?

NAME
mkdir - make directories

SYNOPSIS
mkdir [OPTION]... DIRECTORY...

DESCRIPTION
Create the DIRECTORY(ies), if they do not already exist.

Mandatory arguments to long options are mandatory for short options too.

-m, --mode=MODE
set file mode (as in chmod), not a=rwx - umask

-p, --parents
no error if existing, make parent directories as needed

-v, --verbose
print a message for each created directory

-Z, --context=CTX
set the SELinux security context of each created directory to CTX

--help display this help and exit

--version
output version information and exit

5. What symbol can be used to represent the users home directory?

The User Home Directory is represented by the symbol ~

~ refers to the home directory of the current user.

Signature >:_________________

Submitted By: Ali Murad


Submitted To: Muhib Khan

You might also like