The pgrep command is used to find processes by various criteria, such as user name, group name, process ID, command name, etc. The -u option specifies the user name or user ID to match. Therefore, the command pgrep -u bob will show all processes owned by the user bob. The output will be a list of process IDs, one per line. To show more information about the processes, such as command name, arguments, state, etc., the -l, -a, and -f options can be used. For example, the command pgrep -l -u bob will show the process ID and the command name for each process owned by bob. References:
pgrep - FreeBSD, the manual page for the pgrep command on FreeBSD.
How to use pgrep and pkill commands in Linux - Linuxize, a tutorial on how to use the pgrep and pkill commands in Linux.
Question 2
Which line in a cron job runs myscript once per hour?
Options:
A.
***** /pathto/myscript
B.
0 * * * * /pathto/myscript
C.
* 0 * * * /pathto/myscript
D.
* * o * * /pathto/myscript
E.
* * * o * /pathto/myscript
Answer:
B
Explanation:
Explanation:
The cron job syntax consists of five fields that specify the time and date of execution, followed by the command or script to run. The fields are: minute, hour, day of month, month, and day of week. Each field can have a specific value, a range, a list, a wildcard (), or a step value. The wildcard () means any possible value for that field. The option B sets the minute field to 0 and the hour field to *, which means the script will run at the 0th minute of every hour, regardless of the day, month, or weekday. This is equivalent to once per hour. The other options are either invalid syntax or do not match the desired frequency. For example, option A sets all fields to *, which means the script will run every minute of every hour of every day, month, and weekday. Option C sets the minute field to * and the hour field to 0, which means the script will run every minute of the 0th hour, or once per day at midnight. Option D has a typo (o instead of *) and option E sets the day of month field to o, which is not a valid value. References:
crontab - FreeBSD crontab(5) Manual Page1
Crontab Explained in Linux [With Examples] - Linux Handbook2
Question 3
How often does? match the preceding expression in a regular expression?
Options:
A.
Two or more times
B.
Exactly one time
C.
Any number of times
D.
Zero or one times
E.
One or more times
Answer:
D
Explanation:
Explanation:
The question mark (?) is a special character in regular expressions that modifies the preceding expression to match zero or one times. For example, the regular expression colou?r matches both color and colour, but not colouur or colr. The question mark is also used to make an expression non-greedy, meaning that it will match the shortest possible string instead of the longest. For example, the regular expression <.?> matches the first pair of angle brackets in a string, while <.> matches the entire string enclosed by the outermost pair of angle brackets. References: