Professional Documents
Culture Documents
Inas Fadzlina Lab3a Dec 16
Inas Fadzlina Lab3a Dec 16
Inas Fadzlina Lab3a Dec 16
Learning Outcomes
By the end of this lab, students should be able to:
THEORY:
The command in managing directories are:
i. cd : change directory use to change between directories.
Syntax:
cd [Options] [Directory]
EXAMPLE OF DESCRIPTION
COMMAND
$ cd / Move to the / directory
$ cd /var/log Change to another folder
$ cd .. move back one folder
$ cd Quickly get back
$ cd Back to your home folder
EXAMPLE OF DESCRIPTION
COMMAND
$ ls List the contents of your home directory
$ ls ~ list everything in current directory:
$ ls al list everything in a vertical list:
$ ls -d */ List the directories in the current directory:
$ ls * list ALL subdirectories
iii. pwd : print working directory use to display the path of the current directory.
Syntax:
pwd [-LP]
iv. type : is a shell builtin that display the kind of command the shell will execute, given a particular
command
Syntax:
type [Options] [Command]
TOOLS/SOFTWARE:
- Ubuntu operating system
PROCEDURE:
2. To view the the home folder click on Places > Home Folder
Figure 1: Home folder of user zura
3. To view the directory structure of file system click on File System.
2. To display the kind of command the shell will execute with a particular command name.
$ type mkdir
Activity 4: Display the contents of the text files using cat, more, less, head and tail
3. Insert 15 lines of data in file try1, try2 and try3 that had been create. Double click on file to insert
data.
6. Type cat try1 try2>>try3 to combine the content of both file try1 and try2 in file try3 which is file
try3 already create.
$ cat try1 try2 >>try3
7. Type cat try1 try2 try3>>combine3 to combine the content of 3 file try1 try2 and try3 in file
combine3 which is file combine3 had not been create yet .
$ cat try1 try2 try3>>combine3
8. Type more combine3 to view file perusal filter for crt viewing.
$ more combine3
10. Type head try1 to view 10 first line of file (by default).
$ head try1
12. Type tail try1 to view the 10 last line of file (by default).
$ tail try1
3. Insert data in file grep1 using gedit. Double click the file then insert data example word search
4. To search text files for regular expressions using grep use command
$grep search grep1*
3. Wildcards can be combined with other characters to represent parts of strings. For example, to
list a web page file that use .html as extension file by using command
$ ls *.html
4. To list web page file that use .html as extension file and .txt file use command
$ find *.html *.txt
Note: Please delete file that had been create in this lab. Use command :
$ rm try1 try2 try3 combine3 grep1 grep2 a.html b.html c.txt d.txt
1. Draw the directory structure of your Linux File system start from /.
(2 marks)
3.
4
5
6
7
8
(7 marks)
4. Given 2 file name lab3a.txt and lab3b.txt. By using given file write the command of each below:
i) Combine file lab3a.txt with lab3b.txt.
Command :cat lab3a lab3b
ii) View 3 first line of file lab3a. .txt
Command : head-3 lab3a
iii) View 6 last line of file lab3b.txt
Command :tail-6 lab3b
iv) View file lab3b.txt in page by page.
Command :less lab3b
(4 marks)
v) Write a command to find text diploma in file programme.
Command: : grepdiplomaprogramme*
(1 marks)