Name: Hồ Hoàng Sơn
Student ID: 23521352
Class: [Link]
OS
LAB 1
CHECKLIST
1. Homework
1 2 3 4 5 6
Explanation
Your code
Results and discussions
*Notice: Export PDF file, name format:
<MSSV>_LAB1.pdf
1
2. Lab 1
1. Try to find out the computer hardware sudo unminimize
configuration and Ubuntu version of the VM by sudo apt-get install lshw
executing beside commands in the Terminal. Explain sudo lshw
the use of each command.
df -h
cat /etc/*release
Answer:
Sudo unminimize && sudo apt-get install lshw
For the first two commands `sudo unminimize` and `sudo apt-get install lshw`,
you don't need to do these on MacOS as they are related to Ubuntu specific
installation and optimization. MacOS uses Homebrew for package management
instead of `apt-get`.
Sudo lshw
Use “system_profiler SPHardwareDataType” in MacOS instead of “Sudo lshw”
This command displays information about disk space usage and available space
for file systems in a human-readable format.
2
df -h
3
cat /etc/*release
Use “sw_vers” instead of “cat/etc/*release”
This command provides information about the current MacOS version, including
ProductName, ProductVersion, and BuildVersion.
2. Execute, google, and explain usage of all commands in this section
Answer:
ls
Lists all files and directories in the current directory. Adding options (e.g., ls -l)
can show more details like file permissions, ownership, size, and modification
date.
4
cd
Changes the current directory. For example, cd /path/to/directory moves to the
specified directory. Typing cd alone returns to the home directory.
5
pwd
Prints the current working directory, showing the full path of the directory you're
currently in.
touch
Creates an empty file or updates the timestamp of an existing file. For example,
touch [Link] creates an empty file named [Link].
nano
Opens the nano text editor, allowing you to create or edit files directly in the
terminal. For example, nano [Link] opens [Link] in the editor.
6
mkdir
Creates a new directory. For example, mkdir new_folder creates a directory named
new_folder in the current location.
rm
Deletes files or directories. For example, rm [Link] deletes [Link]
7
cp
Copies files or directories. For example, cp [Link] new_file.txt copies [Link] to
new_file.txt.
mv
Moves or renames files and directories. For example, mv old_name.txt
new_name.txt renames the file. mv [Link] /new/path/ moves [Link] to a new
location.
8
echo
Outputs the given text or variable to the terminal. For example, echo "Hello,
world!" prints "Hello, world!" to the screen. It can also be used to write content to
files (e.g., echo "Hello" > [Link]).
cat
Concatenates and displays file content. For example, cat [Link] shows the content
of [Link] in the terminal. It can also be used to combine files (e.g., cat [Link]
[Link] > [Link])
3. Create a folder tree like below image:
Answer:
9
10
4. Google the way to find some files with “.html” extension in your entire system.
Copy one of them to Myweb.
Answer:
Use the `find` command to search for ".html" files:
find / -name "*.html" 2>/dev/null
This will search the entire filesystem starting from the root `/`
directory for files that have the ".html" extension. The `2>/dev/null`
part is used to suppress permission-denied errors while searching.
11
5. Remove the directory Myweb/scripts.
Answer:
To remove a directory and its contents, we can use the `rm` command
with the `-r` option (recursive) to ensure all files and subdirectories
are deleted.
6. Set the permision for Myweb/databases as below:
The owner has all permission
Other users have no permission
Answer:
To set the permissions for `Myweb/databases` such that the owner has all
permissions and other users have no permissions, you can use the following
`chmod` command:
chmod 700 ~/Documents/Myweb/databases
Explanation:
- `chmod`: Command to change file or directory permissions.
- `700`: Numeric permission setting where:
- `7` gives the owner read (4), write (2), and execute (1) permissions, totaling
to all permissions.
12
- The subsequent `0`s mean the group and others have no permissions.
- `~/Documents/Myweb/databases`: Specifies the path to the directory whose
permissions you want to change.
13