Lab2 SE181589
Lab2 SE181589
man -sudo
o bg: Puts a suspended or background job into the background, allowing it to continue running.
Syntax: bg jobID
bg jobID1 jobID2 ... jobIDn
fg: Brings a job to the foreground, making it the active process in the terminal.
Syntax: fg jobID
fg jobID1 jobID2 ... jobIDn
bg %1 is used to resume the sleep command as a background job
fg %sleep is used to bring the sleep command to the foreground
o who: Displays a list of logged-in users with their usernames, terminal, and login time.
Syntax: who [OPTION]
who -q: Displays only the total number of logged-in users.
chmod -R 644 /hdh/windows/98: Set the permission of the folder 98 and all the files it contains
to mode 644
top: Displays real-time information about system processes and resource usage.
top
top -u se183682: Filters and displays processes owned by the user "se183682".
kill: Sends a signal to terminate or control a process specified by its process ID (PID).
Syntax: kill [OPTIONS] PID
kill 4436: kill the process top
• Capture the terminal screen using the “grep “nhu nui” thoca.txt” and give your
explanation the result. (Notes: thoca.txt is the file in above tutorial)
Explanation:
The command grep "nhu nui" thoca.txt is used to search for the string "nhu nui" in the contents
of the file thoca.txt.
When this command is run, grep will open the thoca.txt file and search for the occurrence of
the exact string "nhu nui" in its contents. If a line within the file contains the specified pattern,
grep will output that line to the terminal with the string “nhu nui” in red color.
• Submit the C/C++ files and objects files as the below content then capture the
result of the program and explanation your result that you get
Result:
Explanation:
The program declare an int variable “ret” to store the value returned by the system() function.
The code system(“man ls”) represents a command to be executed by the operating system's
shell. The line “man ls” displays the manual page for the "ls" command in Unix-like systems.
The system() function executes the command by invoking the shell, and it returns the exit status
of the command as an integer value.
The return value of the system() function is assigned to the ret variable.
Finally, the main() function returns the value stored in ret as the exit status of the program.