In: Computer Science
Linux Commands
8.How would you find out information about systemdon your Linux workstation?
9.A user would like to put the firefoxprogram in the background –what would you type into the command prompt to do this?
10.For the program in above, how would you bring it back into the foreground?
11.What is the fork()function call?
12.In Linux what command sequence do we enter to stop a program?
13.What is the UIDcolumn in the output of the command ps -ef?
14.What is a PIDand PPID? What is the relationship? Show an example from the process table.
15.What are signals, how can they be used?
16.A process has a PIDof 6789, what command would you enter at the terminal toterminatethe process?
17.How can you kill a processes run by the user tim? Why can’t a normal user kill another users processes?
18.What is the /procfile system used for?
19.For a given process run the fuserand lsof commands? What can you learn about a process using these commands?
20.A user wants to start a program every 5 minutes–what would you do to facilitate this ?
8. Use systemctl status
9. Use
nohup firefoxprogram &
10. Use
jobs
and then use fg <job_id> to bring it to
foreground
11. The purpose of fork() is to create a child process of the
caller process.
Hence you can create subprocess using fork()
12. We use Ctrl + C to stop a process.
13. The UID in the ps -ef output refers to the owner of the process.
14. PID is the process id of the process and PPID is the process
id of the parent process for the running process
Here, the process with PID 96 has a PPID 1 which means process with PID 1 is the parent process of process with PID 96
15. Signals are event generated by some processes triggered by
specific conditions.
They can be used to communicate with other processes or child
processes to trigger another event on the timeline.
16. Use kill 6789
17. Use su - tim && kill -9
<PID>, the -9 is used to instruct kill the process
started by another user.
It is not possible for normal users to kill another process started
by different user to make sure there is autonomity in a system and
also for security reason as to prevent another users to interfere
with other user's work.
18. The /proc file is the control and information centre of the kernel, it is created dynamically at the time of boot up and dissolved at the time of shutdown. It contains information about all the processes started and running.
19.
Using fuser we can find which process is using a directory, file
or socket/port.
Using lsof we can find which files are opened. Stands foe list of
open files. Indirectly can help to see which files are currently
used by processes
20. You can write a shell script for the program or use the watch command:
watch -n 300 <program_name> sync
300 specifies time in seconds, sync takes care of the output being shown and cleared