You are on page 1of 5

CT104H – Operating System

CAN THO UNIVERSITY


COLLEGE OF INFORMATION AND COMMUNICATION TECHNOLOGY
OPERATING SYSTEMS (CT104H)
LAB #1

Student name: Lê Nguyễn Nhật Minh ID:B2205994

- Submission: Students submit 1 file named StudentName_ID_CT104H_Lab01.pdf to the Google classroom


(where StudentName is the student’s name, and ID is the student’s ID).
- Instructions on how to present in the report file
⮚ For each question, students MUST provide the commands/scripts AND screenshots of the commands
used and/or the content of files/scripts, CLEARLY. Note: the screenshot needs to include the name of
the Ubuntu Virtual machine.
⮚ Student creates an Ubuntu Virtual machine named UbuntuID (ID is the student’s ID). For example, we
have a virtual machine named Ubuntu20043, such that the student ID is 20043.
Question 0: Navigate to your home directory
Answer: $cd

Study from the Linux CLI Fundamentals (Sections: Introduction to course, and Common Linux Commands),
the file An Introduction to the Linux Command Shell for Beginners, and the book Linux Bible of Christopher
Negus (Chapter 4: Moving around the Filesystem)

Solve all the questions from 1 to 10 in the Section Exercises of Chapter 4 (Linux Bible of Christopher Negus)
CT104H – Operating System
1. Create a directory in your home directory called projects. In the projects directory, create nine
empty files that are named house1, house2, house3, and so on to house9. Assuming there are lots
of other files in that directory, come up with a single argument to ls that would list just those nine
files.

mkdir ~/projects
touch ~/projects/house{1..9}

ls ~/projects/house{1..9}

2. Make the $HOME/projects/houses/doors/ directory path. Create the following empty files within
this directory path (try using absolute and relative paths from your home directory):
$HOME/projects/houses/bungalow.txt
$HOME/projects/houses/doors/bifold.txt
$HOME/projects/outdoors/vegetation/landscape.txt

mkdir -p $HOME/projects/houses/doors/
touch $HOME/projects/houses/bungalow.txt
touch $HOME/projects/houses/doors/bifold.txt
CT104H – Operating System

touch $HOME/projects/outdoors/vegetation/landscape.txt

3. Copy the files house1 and house5 to the $HOME/projects/houses/ directory.

cp ~/projects/house{1,5} ~/projects/houses/

4. Recursively copy the /usr/share/doc/initscripts* directory to the $HOME/ projects/ directory.


Maintain the current date/time stamps and permissions.

To copy /usr/share/doc/initscripts* to $HOME/projects/ I must have permission:

sudo su
<enter password>
cp -rp /usr/share/doc/initscripts* $HOME/projects/

5. Recursively list the contents of the $HOME/projects/ directory. Pipe the output to the less
command so you can page through the output.

ls -R ~/projects/ | less
CT104H – Operating System

6. Remove the files house6, house7, and house8 without being prompted.

rm -f ~/projects/house{6,7,8}

7. Move house3 and house4 to the $HOME/projects/houses/doors directory.

mv ~/projects/house{3,4} ~/projects/houses/doors/
CT104H – Operating System

8. Remove the $HOME/projects/houses/doors directory and its contents.

rm -r ~/projects/houses/doors

9. Change the permissions on the $HOME/projects/house2 file so it can be read and written by the
user who owns the file, only read by the group, and have no permission for others.

chmod 640 $HOME/projects/house2

10. Recursively change permissions of the $HOME/projects/ directory so nobody has write
permission to any files or directory beneath that point in the filesystem.

chmod -R a-w $HOME/projects/

You might also like