LAB 03 – Command line in Linux
Exercise 1:
1. Go to user directory with the command: cd ~
2. Create a directory naming by your name, for example: anhtuan, thanhvan, …
3. In your directory, create a subdirectory naming by your subject: OS_N, then in the OS_N
directory continuously create two subdirectories with the name: OS and N.
4. In OS directory, you create the follows.
a. A subdirectory naming HW
b. A file naming test1 with the content as “He dieu hanh”
5. In N directory, you create the following directories and files:
a. HW directory
b. Assgn directory
c. An empty test5 file
6. Copy test1 file to N directory with the name is test4
7. Delete test1 file in OS directory
8. Add more content into test5 file
9. Back to root directory
Exercise 2:
Explain the meaning of the following commands in Linux, and try to run them in your console.
1. dpkg
2. free
3. hostname
4. ifconfig
5. sudo
6. cat /proc/cpuinfo
7. free –m
8. fdisk –l
Exercise 3:
1. Display your current working directory: ....................................................................................... 2.
Change to new directory /tmp:.....................................................................................................
3. Go back to HOME directory: ........................................................................................................
4. List detail of your directory content (included hidden files): .......................................................
5. Do list and redirect the result of the list command on content /usr directory to usr.txt file: .....
......................................................................................................................................................
6. Sort on data input is the usr.txt file in the reverse order: ............................................................
7. show content of /usr/bin directory and pause on each screen: ..................................................
8. Search recursive on the /etc directory for all files in which contain ‘log’ word: .........................
9. What is command to count on number of lines in /etc/profile file: ............................................
10. How many number of lines in the /etc/profile file: .....................................................................
Answer above questions & capture screen of you comand-line executed!
Exercise 4:
- Create a file named user.txt. Then, you add n usernames (each in one line, n>=5).
- Display the content of file user.txt
- Display list of n sorted usernames in your file and store that sorted list into a new file named
suser.txt
Count the number of users in your file and display it.
Submission:
You should capture the result screen of each exercise and include in your completed document
file.Create the directory with a name like <class>-<name><roll number>-Lab-01, e.g. SE0905-
QuangTV-SE03456-Lab01
Copy all your exercise files to that folder.
Compress the folder to .zip/.rar file (with the same name) and upload to LMS.