(OS) LAB 1 Template
(OS) LAB 1 Template
OS
LAB 1
CHECKLIST
1. Homework
1 2 3 4 5 6
Explanation
Your code
Results and discussions
1
2. Lab 1
Answer:
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.
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 file.txt creates an empty file named file.txt.
nano
Opens the nano text editor, allowing you to create or edit files directly in the
terminal. For example, nano file.txt opens file.txt 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 file.txt deletes file.txt
7
cp
Copies files or directories. For example, cp file.txt new_file.txt copies file.txt to
new_file.txt.
mv
Moves or renames files and directories. For example, mv old_name.txt
new_name.txt renames the file. mv file.txt /new/path/ moves file.txt 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" > file.txt).
cat
Concatenates and displays file content. For example, cat file.txt shows the content
of file.txt in the terminal. It can also be used to combine files (e.g., cat file1.txt
file2.txt > combined.txt)
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.
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