Professional Documents
Culture Documents
Lab 2A - Linux Command - 2021125721 - Muhammad Shafiq Haqime
Lab 2A - Linux Command - 2021125721 - Muhammad Shafiq Haqime
Lab 2A - Linux Command - 2021125721 - Muhammad Shafiq Haqime
Lab Exercise 2A
Introduction to Linux Operating System
(10 marks)
Name: Muhammad Shafiq Haqime bin Mohd Isa Student No: 2021125721
Objectives
At the end of this lab exercise students should be able to:
● Identify basic information about the operating system
● Navigate around the file system using command ls, pwd, mkdir, cd, cat
● Explain and assign the required permission to a file or directory
● Explain the syntax for command in unix/linux operating system
● Demonstrate the operations to files i.e create, copy, rename and remove.
● Demonstrate the symbolic and hard link operations.
Instructions: Complete this Lab exercise and answer all the questions. Submit next week.
PART A
Important note: You can learn more about any Linux commands by using the man command. Try
using this to learn more about the echo command: man echo
1. a) What is the prompt of your Linux/Unix that you are currently use? : dollar sign_ (the last
character in the prompt?) _”$”_.
Do you know what is the shell that you are currently using? : Ubuntu
2. Type the following command at the command prompt and write the output produced.
a. whoami
Output: qime
b. date
Output: Sabtu 12 Nov 2022 01:08:04 +08
c. hostname
Output: qime-virtual-machine
d. ls
Output: Desktop Documents Downloads Music Pictures Public snap
Templates Videos
e. ps
Output:
PID TTY TIME CMD
2545 pts/0 00:00:00 bash
3550 pts/0 00:00:00 ps
RY’2019 Page: 1
f. uname
Output: Linux
g. pwd
Output: /home/qime
Explore the ls command by using the “man ls” command to see the options of what
type of list that you want.
b) What the command to ls does? : Display all the files name in the directory
Did you see the directory that you have just created in a)? : Yes
What option you should use to see the difference between a file and a directory? :
cd ITT420 <enter>
pwd <enter> What you see?: Directory path for ITT420 file
Explain what the above commands do: cat command is entered to open the argument file,
along with several data to be input into the file.
b) We can use the echo command and a feature called command output redirection to create
simple text files. Execute the following command:
echo “this is the first lab using and learning Linux in ITT420” > lesson1
This time use command more to view the content of lesson1. Type: more lesson1. You
can see the differences between cat & less or more if the content of the file is more
RY’2019 Page: 2
than 1 page. Create a file using man followed by any Linux command and redirect the
output to a file namely lesson2.
c) Use the mkdir, cd, and pwd commands to make another directory inside ITT420 /
Itt420 /itt420 directories.
Using man mkdir, what is the option that you can use to create sub-directories in a
directory? (e.g. you want to create directories in ITT420 / Itt420 / itt420 directories without
entering the directory?) : mkdir -p ITT420/{Itt420,itt420}
5. Previously we have used cat command in question number 4. Execute the following cat
command:
What is the difference between the cat command executed in question number 4 and number
5?:
The difference is cat command in question 4 is to input the data into the file, while cat
command in question 5 is to open and read the files to standard output.
Explain what does the cat command actually do: cat command function to read data from the
file and gives their content as output.
Now use the less command to replace the cat command as 5. Can you find the differences
between cat and less?
6. Check what default permission given to Kamus1 file by using below command and write how
the output produced.
ls –l Kamus1
a) From the web or from man command, find the meaning of each displaying permission
when we use ls –l command (there are basically three permissions i.e. r, w and x) and
what option you should use to see all the permissions? :
PART B
mv File1 File2
RY’2019 Page: 3
Describe what has happened to File1.
File1 is rename to File2
e. Execute the following command:
mv File2 Folder1
Describe what has happened to File2.
File2 has been move into Folder1
f. Based on the series of command executed above, explain what does the command mv
do exactly?
mv command is used to move a file or directory into one directory or another, or
rename the file or directory
rm File3
Observe what has happened to File3.
File3 is removed from the directory list.
d. Execute the following command:
rm Folder2
If you get an error message, write down the error message.
rm: cannot remove 'Folder2': Is a directory
By using man, find out the option that will enable you to execute the above command
successfully.
We can use rmdir to remove empty directory, eg : rmdir Folder2.
f. From man pages, what is option “r” for? Try to use it and write down the command
and see the result.
_____________________________________________________________________
RY’2019 Page: 4
4. a. In your home directory, create a file called File4
b. Execute the following command:
cp File4 File5
cp Folder4 Folder5
ln –s File6 File7
c. Describe what has happened to File6 and File7.
File6 is linked with File7
d. Execute the following command:
No content is read.
file File6
b. Try out the above command with other file and folder inside your home folder. Explain
what is the function of the command file? What are the types of files that are exist in
Linux Operating System? List out and describe them.
Command file is used to determine type of a file. There are several type of file in
Linux Operating System, which are:
- Regular File (PNG Image data, ASCII Text, RAR archive data, etc)
- Directory File
- Block Files
- Character File
- Pipe Files (FIFO)
- Symbol Link Files
- Socket Files
Continue explore by trying other commands. There are abundance of tutorial for
beginners in learning Linux/Unix operating system. Have fun. ☺
RY’2019 Page: 6