Vous êtes sur la page 1sur 6

LAB 2: Managing Files and directories in

Linux System
Program Learning Outcome (PLO 2)
Demonstrate strong analytical and critical thinking skills to troubleshoot and solve problems
within realistic constraints by applying knowledge, principles and skills in Information
Technology

Course Learning Outcome (CLO 2)
Use efficiently the open source commands to perform specific given task and open source software
operating system to manage computer system. (P, !"#
Learning Outcomes
$y the end of this lab, students should be able to%
1. &anage directories with !'I.
2. !reate and view files using !'I.
3. (ork with files and directories using !'I
THEORY:
The command in managing directories are%
i. cd % change directory use to change between directories.
ii. ls % list short use to list the specified files.
iii. pwd % print working directory use to display the path of the current directory.
!reate file and directory using
i. touch% create file)files.
ii. mkdir% create directory)directories.
*iew a file using the following commands%
i. cat% +llows you to look, modify or combine a file.
ii. less% use to display the content of a file page by page.
iii. head% use to view only the first few lines of a file.
iv. tail% Delivers the last part of the file.
&anipulate files and directory using%
i. copy % to copy file or directory
cp source destination
ii. move% rename or move one or more files to another directory
mv source destination
Delete file and directory using !'I.
i. rmdir % to remove directory
rmdir directoryname
ii. rm % to delete file
rm filename
'ink files using !'I.
The ln command creates a link. + link is a reference to a file. Through a link, you can access
a file from anywhere in the file system using different names for it. This means that the file
itself e,ists only once on the system, but it can be found under different names.
There are two kinds of links in 'inu,%
i. -ard link % ln source_file link_name
ii. .ymbolic link % ln /s source_file link_name
TOOLS/SOFTWARE:
- Ubuntu, 0edora or other open source operating system.
PROCEDURE:
Activity 1: Moving aroun ir!ctori!"
1. Launch terminal in ubuntu.
2. Type pwd command to show the name of working directory
$pwd
3. To list the content of current working directory us ls command
$ls
4. Type cd to change working directory
$cd
Activity #: Cr!at! $i%!/$i%!" u"ing t&! touc& co''an
1. Launch terminal in ubuntu.
1. Type touch filename to create a file
$ touch try
3. Type touch filename to create 4 files
$ touch try{1..4
4. Type touch filename to create 3 file
$ touch try! try" try#
2. Type 1! lines of data in try1 and try2.
Activity (: Cr!at! ir!ctory/ir!ctori!" u"ing t&! ')ir co''an
1. Launch terminal in ubuntu.
2. Type mkdir directory name to create a directory
$ mkdir book
3. Type mkdir directory name to create ! directory
$ mkdir book{1..!
Activity *: Manipulate files and directory using copy and move command
1. Launch terminal in ubuntu.
2. Type cp try1 try2 to copy file try1 to try2.
$cp try1 try2
3. Type cp try2 book1 to copy file try2 to directory book1.
$cp try2 book1
4. Type m$ command to mo$e the file or directory.
$m$ try1 %ocuments
Activity +: ,i!- $i%! u"ing co''an
1. Launch terminal in ubuntu.
2. Type cat try1 to $iew the entire file.
$ cat try1
3. Type cat try1 try2 to combine both file.
$ cat try1 try2
4. Type less try1 to $iew the last part of the file.
$ less try1
!. Type head try1 to $iew 1& first line of file.
$ head try1
". Type tail try1 to $iew the 1& last line of file.
$ tail try1
Activity .: Delete file and directory using CLI
1. Launch terminal in ubuntu.
2. Type rmdir book2 book3 book4 book! to delete directory book2 book3 book4 book!.
$rmdir book2 book3 book4 book!
3. Type rm 'rf book1 to remo$e not empty directory
$rm (rf book1
4. Type rm try1 to delete file.
$ rm try1
!. Type rm try1 to delete file.
$ rm try{1..!
". Type rm try1 to delete file.
$ rm try" try#
Activity /: Link files using CLI
1. Launch terminal in ubuntu.
2. Type ln try1 newtry1 to create hard link for source file.
$ln try1 newtry1
3. Type ln 's try2 newtry2 to create symbolic link for source file.
$ln 's try2 newtry2
4. Type ln (s book1 newbook1 to create symbolic link for directory.
$ln (s book1 newbook1
Stu!nt0" 1a'!:
R!gi"tration 1u'2!r:
C%a"":
La2 E3!rci"! # 4#5 Mar)"6
1. )rite the command to change the working directory to home directory
cd**************************************************************** +1 marks,
2. )hat is the deference-s between rm command and rmdir command in term of function.
rm rmdir
%eleting directory .file To delete file
to remo$e directory
/0ample of command
rm flename
rmdir directoryname
+4 marks,
3. )rite 2 command to create 4 file name 12!&13 12!&23 12!&3 and 12!&4.
i, **touch 12!&1 12!&2 12!&3
12!&4**************************************************
ii, *********************************************************** +2
marks,
4. )rite the command to copy file 12!&1 to %esktop
******************cd 12!&1 %ekstop********************************************
+1 marks,
!. 2rint screen what you get from the 4cti$ity !
*************************************************************** +2 marks,
". List the step to create a directory name L452 then delete the directory.
i, ***********************************************************
ii, *********************************************************** +4
marks,
#. )rite the command line to link 12!&1 file by using symbolic link from 6ome
directory to %ocuments directory with a same filename 12!&1.
i, *******************************************************
ii, *******************************************************
iii, ******************************************************* +!
marks,
7. List the step to link files 12!&2 using 8autilus.
i, ***********************************************************
ii, *********************************************************** +1
marks,

Vous aimerez peut-être aussi