10. Processes and System Services

Ace your homework & exams now with Quizwiz!

Binary Executable

A binary executable is a program written in a programming language that is compiled into a binary file that the CPU can execute.

Internal shell commands

A command that is built into the shell executable.

cupsenable

Activates a disabled printer. e.g. cupsenable printer7 activates printer7 and allows it to print jobs in its queue.

10.5.6 Time Maintenance Facts

Applications and services, especially those that are used for security purposes, require accurate time. This lesson covers the following topics: General considerations Clock and time files and utilities

10.1.10 Practice Questions

CIST 2431

10.3.10 Practice Questions

CIST 2431

Syntax for cron Jobs

Each entry in the /etc/crontab or /var/spool/cron/username file uses a specific format. The table below illustrates the syntax for a typical cron job and provides additional examples. The asterisk (*) is a wildcard that is equal to any value.

cupsaccept

Enables a printer's print queue. e.g. cupsaccept printer7 enables the print queue for printer7.

Browsing

Enables server broadcasts. The default is On. e.g. Browsing On

lpoptions

Sets the default printer. Options include: -d specifies the default printer for all users. -l displays current option settings for a printer. *Users can use the ~/.lpoptions file to set their own default printer values. Include the single line default printer_name to specify the default printer. lpoptions -d printer7 specifies printer7 as the default printer for all users.lpoptions -l printer7 displays the current option settings for printer7.

Common Unix Print System (CUPS )

Software a Linux system uses to print from applications.

System time

Software running within the operating system which is used to set and keep the system's time.

10.3.8 anacron Facts

Some distributions use anacron with cron to automate the running of tasks. The two services function in much the same way. This lesson covers the following topics: Differences between cron and anacron anacron fields

System Process

System processes (also known as daemon processes) are started by the operating system, usually when it boots. However, users can also load daemon processes by manually starting a daemon using its init script or by using the systemctl command.

Parent Process ID (PPID)

The PPID identifies the process that spawned (or started the current process. The process that spawned the new process is known as the parent process; whereas the spawned process is known as the child process.

Period

The Period field specifies the recurrence interval in days. For example: 1 means the task recurs daily. 7 means the task recurs weekly. 30 means the task recurs every 30 days. @monthly means the task recurs once per calendar month.

What information about print jobs does the lpq utility display? (Select TWO). The name of the application that submitted the job. The username of the person who submitted the job. The printer serial number. The amount of ink or toner left in the printer. A numerical job ID that can be used to manipulate the job from other utilities.

The username of the person who submitted the job A numerical job ID that can be used to manipulate the job from other utilities. The job ID and job owner are both displayed by lpq. Unless the application embeds its own name in the print job, that information won't be present. Most Linux printer drivers and utilities, including lpq, lack the ability to query ink or toner status or display the printer's serial number.

Terminate a Running Process

The following commands can be used to terminate a running process.

at -d jobnumber atrm jobnumber

Remove jobs from the at queue. Use spaces to separate multiple jobs. e.g. at -d 2 3 removes jobs 2 and 3 from the at queue. atrm 4 removes job 4 from the at queue.

lprm

Removes jobs from the print queue. If executed by a regular user, the command removes only that user's jobs; if executed by the superuser, the command removes all print jobs. -P specifies a printer name. -U specifies an alternative username. - cancels all print jobs. lprm -P printer7 6 removes job number 6 from the print queue of printer7.lprm - removes all jobs from the default printer.lprm removes the current job from the default printer.

at now

Run the command immediately.

pkill

Searches for processes that match the search criteria specified and then sends them a kill signal. e.g. pkill -SIGTERM -f top searches through all of the running processes for those with "top" somewhere in their name and sends them the SIGTERM signal.

ntpq -p displays the status of the ntpd daemon.

Traces how the time consumer receives time from the provider. It lists the time provider's name, its stratum, and its time offset from the system clock on the local system. e.g. ntptrace traces how the time consumer is receiving time from the provider.

10.1.8 View Process Information

Type ps aux | less at the prompt to answer the following questions: What is the PID for the hald process? 1194 What is the state of the ps aux process? running What is the percentage of memory used by process ID 2156? 2.3 Which command invoked process ID 1857? python

ntpdate

Updates the current time on a computer. ntpdate must be run as root; it will not function if the ntpd daemon is currently running. *ntpdate is deprecated; use ntpd in its place. e.g. ntpdate 0.pool.ntp.org updates the system time using a time provider from the NTP pool.

Coordinated Universal Time (UTC)

The primary time standard by which the world regulates clocks and time.

Processor Numbering

All processes are assigned unique process ID numbers randomly from a list of available numbers. Linux processes use the following identifiers:

Foreground

Any command or task you run directly from a terminal and wait for it to complete. No other commands can run from the terminal until the process terminates.

You are using the cupsctl command to configure the /etc/cups/cupsd.conf file. Which cupsctl option will enable sharing of the locally connected printer to other computers on the network?

--share-printers Use cupsctl --share-printers to enable the sharing of local printers with other computers. Use cupsctl to configure the /etc/cups/cupsd.conf file. When used with no options, the command displays current settings. Be aware of the other cupsctl options: --remote-admin enables remote administration of the server. --remote-printers enables the display of remote printers shared via CUPS. Use --no in front of a command to disable an option.

Which hwclock option sets the system time to the current hardware clock time?

-s hwclock -s or hwclock --hctosys sets the system time to the current hardware clock time. Use hwclock to view and set the hardware clock time and synchronize the hardware clock and the system time. Other hwclock options include the following: -a, --adjust adds or subtracts time from the hardware clock to account for systematic drift since the last time the clock was set or adjusted. -r, --show displays the current hardware clock time. hwclock assumes -r if no options are used. --set--date sets the hardware clock time and date. -w, --systohc sets the hardware clock based on the system time. --localtime sets the hardware clock to local time. -u sets the hardware clock to UTC time.

You want to use the date command to set the system time UTC time. Which date option should you use? -d -s -u -g

-u Use date -u or date --utc to manually set the system time to UTC time. Coordinated Universal Time (UTC), formerly known as Greenwich Mean Time (GMT), is a method for identifying a common time between devices regardless of their physical location in the world. Other date options include the following: -d shows the current date and time. (date assumes -d if no options are used.) -s sets the date and time.

Your Linux system uses the Line Printer Daemon (LPD) to manage print jobs. What is the full path to the file you should use to edit the LDP configuration?

/etc/lpd.perms When using LPD, the configuration file is located at /etc/lpd.perms.

cancel

Cancels print jobs. Options include the following: -P specifies a printer. -U specifies an alternative username. e.g. cancel HPLJ5-11 cancels print job 11 on the default printer.cancel -P printer7 printer7-11 cancels print job 11 on printer7.cancel -P printer7 -U jsmith cancels all print jobs for the user jsmith on printer7.

cupsreject

Disables a printer's print queue. *This does not clear the print queue. The printer itself will continue processing queued print jobs, but cupsd will not allow any new jobs to enter the queue. e.g. cupsreject printer7 disables the print queue for printer7.

Postscript Printer Descriptions (PPD)

Files that the cupsd daemon uses to determine printer capabilities.

/etc/localtime

Identifies the current time zone file used on the system. This file is a symbolic link to the appropriate time zone file in the /usr/share/zoneinfo directory. Relinking this file to a different time zone file changes the system's time zone. e.g. ln -s /usr/share/zoneinfo/time_zone_file /etc/localtime creates a symbolic link to the time zone file that permanently alters the time zone for the entire system.cp -s /usr/share/zoneinfo/time_zone_file /etc/localtime accomplishes the same result as the example above.

/var/spool/cron/username

If permitted, each user can create a personal crontab file located at /var/spool/cron/username.

Waiting - Uninterruptible sleep

Process: D Description: Uninterruptible sleep. This is a processes that cannot be killed or interrupted with a signal.

cupsdisable

Keeps a printer from printing. Jobs are still added to the queue, and are printed when the printer is re-enabled. e.g. cupsdisable printer7 keeps printer7 from printing the jobs in its queue.

MaxJobsPerUser

Limits the number of active print jobs for a single user. The default is 0, meaning no restriction. e.g. MaxJobsPerUser 100

crontab

Manages the /var/spool/cron/username crontab file. Be aware of the following options: -e edits the crontab file for the current user in vi. -l displays the contents of the current user's crontab file. -r removes the current user's crontab file. -u username specifies a different user for the -e, -l, and -r options. e.g. crontab -e edits the crontab of the current user. crontab -eu username edits the crontab file of the specified user. crontab -l lists the cron jobs for the current user. crontab -lu username lists the cron jobs for the specified user. crontab -r -u username removes the crontab file of the specified user. crontab -r removes the crontab file of the current user. crontab /home/user/cronjobs creates a crontab file using the cronjobs file for the current user.

ntpd

Manages the NTP daemon from the command line. Options include: -q does a one-time synchronization with a time provider. It is similar to ntpdate. -g allows the NTP daemon to ignore insane time restrictions for the first synchronization. -c specifies the name and path of the configuration file. The default is /etc/ntp.conf. e.g. ntpd -qg updates the current time on the computer and ignores insane time restrictions. ntpd -c ~/ntp/ntpconfig.txt changes the configuration file that NTP uses to ~/ntp/ntpconfig.txt.

UTC offset

The amount of time that local time is ahead of or behind Coordinated Universal Time (UTC).

anacron Fields

The anacron daemon uses the /etc/anacrontab file. This file uses the following fields:

Background

The area in which a task can run while other processes run in the foreground.

10.4.8 Print a File

You are the administrator of a server, and you have root privileges. The IT manager has asked you to install the cups package to enable printing on the server. In this lab, your task is to complete the following: Use dnf to install the cups package. After the installation is complete, print the sales document in /home/wadams. Complete this lab as follows: At the prompt, type dnf install cups and press Enter to install the cups package. Press Y and press Enter to confirm the installation. Type lpr /home/wadams/sales and press Enter to print the sales document.

CUPS Command Line Tools

You can use the following command line tools to manage CUPS printers and print jobs:

If a system is down at the time a recurring regularly scheduled task is supposed to run, which task scheduling service will run the task when the system is back up again? recron at cron anacron

anacron If a system is down at the time a recurring regularly scheduled task is supposed to run and anacron was used to schedule the task, then anacron will run the task when the system is back up again. If a system is down at the time a recurring regularly scheduled task is supposed to run and cron was used to schedule the task, then the task will be skipped, and it won't be run until the next time it is scheduled to run. The at daemon can only be used to schedule a single occurrence of a task to be run at a specific time in the future. If the system time is down when the task was supposed to run, it will not be run. There is no recron service on Linux.

What should you enter at the command prompt to remove tasks 2 and 3 in the at queue?

atrm 2 3 Use at -d or atrm followed by the task number(s) of the jobs you want to remove from the at queue. Use spaces to separate multiple jobs. For example, atrm 2 3 removes jobs 2 and 3 from the at queue.

You have a gedit process with a job ID of 6. Which command would you enter at the command prompt to send the process to the background?

bg 6 bg 6 sends the process with job ID 6 to the background.

Which command could you use to verify whether a crontab file exists for the thobbs user? crontab -r -u thobbs crontab -l -u thobbs crontab -a -u thobbs crontab -e -u thobbs

crontab -l -u thobbs Use the crontab -l -u user option to see whether this file exists. Use the -e option to edit the crontab, use -r to remove it, and use -a to append to the existing file.

You are configuring the /etc/cups/cupsd.conf file. Which command should you use to prevent remote printers from being displayed on the local system? cupsctl --no-share-printers cupsctl --remote-printers cupsctl --no-remote-printers cupsctl --no-remote-admin

cupsctl --no-remote-printers Use cupsctl --no-remote-printers to prevent the display of remote printers shared via CUPS. Use cupsctl to configure the /etc/cups/cupsd.conf file. Use --no in front of a command to disable an option. When used with no options, the command displays current settings. Be aware of the following cupsctl options: --remote-admin enables remote administration of the server. --remote-printers enables the display of remote printers shared via CUPS. --share-printers enables the sharing of local printers with other computers.

You have several processes running in the background, as shown by the jobs command below: [1]+ Running gedit & [2]+ Stopped crontab e Which command will bring the gedit program to the foreground? fg [1] bg 1 fg 1 fg edit

fg 1 Use the fg command followed by the job ID ( 1, 2, 3, etc.) to bring a job to the foreground. The job ID is shown within brackets from the jobs command output. Use the bg command to send processes to the background.

Which of the following commands manages the NTP daemon from the command line? ntpdate insserve ntp ntpd ntpq

ntpd Use ntpd to manage the NTP daemon from the command line. ntpd options include the following: -q does a one-time synchronization with a time provider. It is similar to ntpdate. -g allows the NTP daemon to ignore insane time restrictions for the first synchronization. -c changes the default configuration file. insserv ntp configures the NTP daemon to start at boot time on BSD systems only. ntpdate updates the current time on a computer. ntpq queries the status of the NTP daemon.

A developer calls you with a problem. He was trying to debug a new daemon and mistakenly placed it on the production machine instead of on a lab machine. To ensure that the CPU gives preference to other processes, you need to lower the daemon's priority. The PID number is 2345. Which command would you use to decrease the daemon's priority? renice -n 10 2345 renice -n 0 2345 renice -n -10 2345 nice -n 0 2345

renice -n 10 2345 Use renice -n 10 2345 to decrease the priority of process 2345. The renice command assigns a new priority to a process that has already started using the process's PID. Be aware of the following: Values range from 19 (lowest priority) to -20 (highest priority). The higher the number, the lower priority the job receives in the system. Zero (0) is the default nice value for processes not executed with the nice command. Use the nice command to start a process with a higher or lower priority.

You want to configure the NTP daemon to receive time from pool.ntp.org. What entry should you place in the /etc/ntp.conf file?

server pool.ntp.org server pool.ntp.org configures the NTP daemon to synchronize the time with the cluster of time servers at pool.ntp.org. Use the /etc/ntp.conf to configure the time providers on the NTP client. Each entry in the file begins with server and then the address of the time provider. server 127.127.1.0 represents the local host address and sets the system time to the hardware clock if no other time providers are available.

Shell scripts

A script is a text file that contains one or more commands. When the shell reads the file, it executes the commands as if they were entered through the keyboard.

10.5.3 Time Zone Facts

A time zone is a geographic region of the world that has the same standard time. This lesson covers the following topics: General considerations Linux clocks UTC offset Time zone tools and files

Your system time is over thirty minutes different than the time on the NTP time provider. When you use the ntpd command, the time is not updated. Which ntpd option should you include?

-g NTP does not adjust times when time discrepancies are larger than 17 minutes. This is known as insane time. Use ntpd -g to allow the NTP daemon to ignore insane time restrictions for the first synchronization. Other ntpd options include the following: -q does a one-time synchronization with a time provider. It is similar to ntpdate. -c specifies the name and path of the configuration file. The default is /etc/ntp.conf.

You need to set the system date and time using the date command. Which date option should you use? -s -u -d -utc

-s Use date -s to set the date and time. Use date to view and manually set the system time. Be aware of the other date options: -d shows the current date and time. date assumes -d if no options are used. -u, utc specifies UTC time.

Which lpr option should you use to change the page width of the print job? -r -P -h -w

-w Use lpr -w to set the page width of a printable document. Use lpr to send a job to the print queue (putting print jobs into the queue is called spooling). Other common lpr options include the following: -#n prints n number of copies. -h prints without using a banner page. -P printer prints to the named printer. -r removes the job from the queue after printing.

What is the full path and filename of the file that is used to schedule tasks for the anacron daemon?

/etc/anacrontab/ /etc/anacrontab is the full path and filename of the file that is used to schedule tasks for the anacron daemon.

You want to keep the gshant user from using the at command. What is the full path and filename of the file you should edit?

/etc/at.deny /etc/at.deny specifies users who cannot use the at command, whereas /etc/at.allow specifies users who can use the at command.

Which file should you edit if you want to permit specific users to edit their respective crontab file, but deny all other users on the system from editing their crontab file? /etc/cron.deny /etc/cron.permit /etc/cron.allow /etc/crontab

/etc/cron.allow The /etc/cron.allow file includes users who can edit their personal crontab file. If /etc/cron.allow file exists, only users listed therein are allowed to edit /var/spool/cron/username. The /etc/crontab (cron table) file holds entries that direct commands to execute at a specific time for the whole system. The cron daemon only checks the file of the current user. The /etc/cron.deny file excludes users who can edit their personal crontab file. If /etc/cron.deny file exists, users listed therein are not allowed to edit their personal crontab file. There is no /etc/cron.permit file.

You want to keep the gshant user from editing his respective crontab file in /var/spool/cron, but still allow all other users on the system to edit their respective crontab file. What is the full path and filename of the file you should edit?

/etc/cron.deny The /etc/cron.deny file excludes users who can edit their personal crontab file. If /etc/cron.deny file exists, users listed therein are not allowed to edit their personal crontab file.

Which file should you edit to schedule a task to execute every week on Saturday? /etc/cron.monthly /etc/cron.weekly /etc/cron.daily /etc/cron.hourly

/etc/cron.weekly Use the /etc/cron.weekly file to execute scripts on a weekly interval. Use: /etc/cron.hourly to execute scripts on an hourly interval. /etc/cron.daily to execute scripts on an daily interval. /etc/cron.monthly to execute scripts on an monthly interval.

You are managing system time on your Linux computer, and you need to change the settings to point to a local NTP server IP address. What is the full path and filename of the file you should edit?

/etc/ntp.conf Use /etc/ntp.conf to configure the time providers on the NTP client. Each entry in the file begins with server and then the address of the time provider. For example, server 0.fedora.pool.ntp.org synchronizes the time with the Fedora time server pool. The 127.127.1.0 server represents the local host address and sets the system time to the hardware clock if no other time providers are available.

What is the full path and filename of the file you should use to configure the hardware clock to use UTC automatically?

/etc/sysconfig/clock Use /etc/sysconfig/clock to Configure the hardware clock to use UTC or local time automatically. The file acts as a configuration file that sets the HWCLOCK setting to control whether the clock uses local or Coordinated Universal Time (UTC): HWCLOCK -u specifies that the system use UTC. HWCLOCK --localtime specifies that the system use local time. Managing a large group of computers in different time zones is less complex if HWCLOCK is set to use UTC.

What is the full path and filename for the file on a Debian Linux distribution that displays the time zone settings?

/etc/timezone Use /etc/timezone to display the time zone settings on Debian computers. /etc/timezone identifies the current time zone by region and zone.

anacron creates a timestamp file that tells you the last time a regularly scheduled job was run. What is the full path and name of the directory that contains these timestamp files? /var/jobs/anacron/ /etc/cron.d/anacrontab/ /var/spool/anacron/ /etc/anacron.d/

/var/spool/anacron/ anacron creates a timestamp file in the /var/spool/anacron/ directory every time a regularly scheduled job is run so you can see the last time a given job ran. The /var/ directory is the standard directory for log files of this nature.

What is the complete path to the directory that will hold the crontab file for the gshant user account?

/var/spool/cron/ /var/spool/cron holds a personal crontab file for specific user accounts. The gshant user account will have /var/spool/cron/gshant as the personal crontab file. The cron daemon only checks the file of the current user.

In the following example, anacron is configured to run the /usr/bin/dbcleanup command once a day:

1 30 dbcleanup.log /usr/bin/dbcleanup If the system is down when the anacron job is supposed to run, the command will be automatically executed approximately 30 minutes after the system comes back up. The anacron daemon adds a random number of minutes to the value specified in the Delay field of each entry in the anacrontab file. The actual number of minutes added is constrained by the RANDOM_DELAY setting within the /etc/anacrontab file. By default, this setting is set to a value of 45, which allows the anacron daemon to add a random number of minutes between 0 and 45 to the delay time for each entry in the anacrontab file.

You are editing the crontab file and want an entry to run every hour at five minutes past the hour. Which of the following entries will accomplish this task? 5 * * * * /home/emmett/example.sh * 5 * * * /home/emmett/example.sh * *5 * * /home/emmett/example.sh * * * 5 * /home/emmett/example.sh * * * * 5 /home/emmett/example.sh

5 * * * * /home/emmett/example.sh To run the command every hour at a specific minute, place the minute value (5) in the first field. The first field of the crontab entry holds the minute specification. The second field is used for hours. The third field identifies the day of the month. The fourth field specifies the months during which to run.

When using CUPS:

> Most Linux distributions install CUPS by default; however, if CUPS is not installed, use yum, zypper, or apt-get to install the CUPS package. > Use the init script or the systemctl command to restart CUPS after making configuration changes. > To access the web-based CUPS administration utility, go to http://localhost:631 or http://127.0.0.1:631.

Be aware of the following details:

> Some distributions use separate files in the /etc/cron.d directory in addition to lines in the /etc/crontab file. > The cron daemon (crond) is managed using its init script in the /etc/rc.d/init.d/ or /etc/init.d/ script directory on init-based distributions. For systemd-based distributions, it is managed using the crond.service file and the systemctl command.

Backend

A CUPS backend provides the interface between the scheduler and the printer hardware. CUPS supports several types of backends including: Parallel Serial USB When the cupsd daemon starts, it queries each backend to identify all printers attached to the computer. The backends provide the cupsd daemon with printer information including make, model, and capabilities for each connected printer. Backends are located at /usr/lib/cups/backend.

Spool

A CUPS spool is a directory on the print server that holds print jobs while waiting for the printer to become available. When, an application generates a print job and sends it to the cupsd daemon, the daemon saves the job in the spooling directory. Print queue and filter information from the print job are saved in /var/spool/cups. The file is named c, concatenated with a print job number assigned by the daemon. The document to be printed is also saved in /var/spool/cups. This file is named d concatenated with the same print job number.

Hardware clock

A chip on the system's motherboard used to set the system's time.

Spool

A directory on the print server that holds print jobs while waiting for the printer to become available.

10.5 System Time Configuration

As you study this section, answer the following questions: How can you view the current hardware clock time? What is drift? How do you synchronize time on a Linux network? How does stratum help to provide accurate time? What is the difference between stepping and slewing? Key terms for this section include the following:

10.4 Print Management

As you study this section, answer the following questions: What is the function of the cupsd daemon on the server? How can you access the web-based administration tool for the CUPS server? What is the file used to configure CUPS? Which commands can you use to remove print jobs from the queue? Which command is necessary to activate a printer queue? How can you display all the printer queues on the system? In this section, you will learn to: Print a file. Remove a print job. Key terms for this section include the following:

General Considerations

Be aware of the following details: > Services that communicate with other computers require that the clocks on all the computers are synchronized within a small degree of variance. > A timestamp is a record attached to an event or an action that identifies the time when the event took place. Timestamps are used to: - Record when security events, such as logon or system changes, occur. - Identify the correct sequence of events. For example, if a database record is changed from two different computers, the timestamp associated with the changes are used to identify which change took place first (or last).

You have an anacrontab file with the following settings: RANDOM_DELAY=35 START_HOURS_RANGE=17-23 #period in days delay in minutes job-identifier command 1 5 cron.daily nice run-parts /etc/cron.daily 7 20 cron.weekly nice run-parts /etc/cron.weekly @monthly 50 cron.monthly nice run-parts /etc/cron.monthly Between which hours of the day will tasks scheduled with anacron start to run? If the system was down during the time period a weekly task was scheduled to run, what is the minimum amount of time anacron will wait to run a task after the system is back up? If the delay for daily tasks is 5 minutes, how much time will anacron add to the delay of 5 minutes before it runs the scheduled daily task?

Between which hours of the day will tasks scheduled with anacron start to run? Between 5:00 p.m. and 11:00 p.m. If the system was down during the time period a weekly task was scheduled to run, what is the minimum amount of time anacron will wait to run a task after the system is back up? 20 minutes If the delay for daily tasks is 5 minutes, how much time will anacron add to the delay of 5 minutes before it runs the scheduled daily task? A randomly chosen number of minutes between 0 and 35 Scheduled tasks will start to run between hour 17 (which is 5:00 p.m.) and hour 23 (which is 11:00 p.m.). Tasks will run between 5:00 p.m. and 11:00 p.m. 2. If the system was down during the time period a weekly task was scheduled to run, 20 minutes is the minimum amount of time anacron will wait to run the task after the system is back up. Remember that with a random delay set at 35 minutes, anacron will add between 0 and 35 minutes to that 20-minute delay. 3. If the delay for daily tasks is 5 minutes, anacron will add between 0 and 35 minutes to the 5-minute delay before it runs the scheduled daily task. This means the scheduled task will start between 5 and 40 minutes after the system comes back up again.

A user sends two print jobs to the Marketing printer (the default printer). She notices the printer is stalled on the first document and uses the lprm - command. What will be the result? The first job will be deleted. Both of her jobs will be deleted. All jobs in the queue, including those for other users, will be deleted. Nothing. She must identify the job number in the command. Nothing. She must identify the print queue in the command.

Both of her jobs will be deleted. The lprm - command deletes all jobs in the print queue. Because the command is issued by a user, only that user's jobs will be deleted. The default printer will be assumed if it is not explicitly stated in the command. To remove only the first job in the queue, the user should use the lprm command (without -).

10.4.10 Practice Questions

CIST 2431

10.5.10 Practice Questions

CIST 2431

10.4.4 CUPS Facts

CUPS (Common Unix Print System) provides a common printing interface across a local network, masking differences among the printing systems on each computer. CUPS is widely deployed by nearly every current Linux distribution to manage printing. This lesson covers the following topics: About CUPS CUPS components How CUPS processes print jobs cupsd parameters CUPS command line tools

Client

CUPS clients send files to the print server. The client's cupsd daemon automatically listens for broadcasts from CUPS servers, and can connect to those servers over a network connection.

Filters

CUPS filters convert print jobs from the default Printer Description Language (PDL) into languages used and understood by specific printers. By default, Linux creates print jobs using Adobe's PostScript PDL. However, many printers are not PostScript compatible. CUPS filters convert print jobs into a PDL supported by the printer. Filters are located at /usr/lib/cups/filter.

About CUPS

CUPS is the software you use to print from applications like word processors, email readers, photo editors, and web browsers. It converts the page descriptions produced by your application (such as where to put a paragraph or where to draw a line) into something your printer can understand and then sends the information to the printer for printing. Since every printer manufacturer does things differently, printing can be very complicated. CUPS does its best to hide this from you and your application so that you can concentrate on printing and less on how to print. Generally, the only time you need to know anything about your printer is when you use it for the first time, and even then CUPS can often figure things out on its own. The first time you print to a printer, CUPS creates a queue to keep track of the current status of the printer (everything OK, out of paper, etc.) and any pages you have printed. Most of the time the queue points to a printer connected directly to your computer by means of a USB port. However, it can also point to a printer on your network, a printer on the Internet, or multiple printers depending on the configuration. Regardless of where the queue points, it will look like any other printer to you and your applications. Every time you print something, CUPS creates a job which contains the queue you are sending the print to, the name of the document you are printing, and the page descriptions. Job are numbered (queue-1, queue-2, and so forth) so you can monitor the job as it is printed or cancel it if you see a mistake. When CUPS gets a job for printing, it determines the best programs (filters, printer drivers, port monitors, and backends) to convert the pages into a printable format and then runs them to actually print the job. When the print job is completely printed, CUPS removes the job from the queue and moves on to any other jobs you have submitted. You can also be notified when the job is finished, or if there are any errors during printing, in several different ways.

Server

CUPS servers broadcast the availability of their printers on the network. The cupsd daemon runs on the server and handles both network and local print functions.

timedatectl

Can be used to query and change the system clock and its settings. With no options, this command lists information on the system's current date and time, as well as time-related settings. A few options for this command include: > set-time yyyy/mm/dd hh/mm/ss changes the date and time according to the parameters entered. > list-timezones lists the available time zones recognized on your system. > set-timezone region/area sets the system time zone to the specified value > set-local-rtc x where x is the value of 0 or 1. Configures the real-time clock (RTC) to either maintain the RTC in universal time or to maintain the RTC in local time instead. *Remember that the <img> tag does not need the closing </img> tag, but the <blockquote> tag does need the closing </blockquote> tag. > set-ntp true/false Controls whether NTP based network time synchronization is enabled. e.g. timedatectl set time "2019-12-02 13:40:15" sets the date and time to 2 Dec 2019 and 1:40:15 pm. timedatectl list-timezones shows all the known time zones available. timedatectl set-timezone America/Denver changes the time zone used by the mountain time zone in the United States . timedatectl set-local-rtc 0 the value of zero tells the system to maintain the RTC in universal time timedatectl set-ntp true enables NTP-based time synchronization.

TZ=time_zone export TZ

Changes the time zone environment variable. Use the file names in the /usr/share/zoneinfo directory to select the appropriate names for time zones. *Environment variable changes are only permanent if they are added to a shell configuration file similar to ~/.bashrc or ~/bash_profile. e.g. TZ='America/Denver'export TZ

tzselect

Changes the value of the time zone (TZ) environment variable. When executed, the utility prompts you to select a region, then a country, and so on until it has enough information to determine the time zone. Only the root user can invoke the tzselect utility. To use tzselect: 1. Enter tzselect. 2. Enter the number from the list that corresponds to the correct continent or ocean. 3. Enter the number from the list that corresponds to the correct region. 4. Enter the number from the list that corresponds to the correct timezone. 5. Press 1 to confirm the setting. *Use the tzconfig command on Debian-based Linux distributions instead of tzselect.

UTC Offset

Clocks on a Linux computer can use local time or UTC time. The following table describes these and explains how to calculate a UTC offset:

cupsctl

Configures the /etc/cups/cupsd.conf file. When used with no options, the command displays current settings. Options include: --remote-admin enables remote administration of the server. --share-printers enables the sharing of local printers with other computers. --remote-printers enables the display of remote printers shared via CUPS. *Use --no in front of a command to disable an option. e.g. cupsctl displays the settings of the cupsd.conf file.cupsctl --remote-admin enables remote administration of the server.cupsctl --no-share-printers will prevent the sharing of local printers.

insserv ntp (init) or systemctl enable ntpd (systemd)

Configures the NTP daemon to start at boot time (BSD systems only.) e.g. systemctl enable ntpd starts the NTP daemon automatically on system boot.

/etc/ntp.conf

Configures the time providers where the ntpd daemon should get its time from. > Each entry in the file begins with server followed by the address of the time provider. > The server 127.127.1.0 entry identifies the local host address and sets the system time to the hardware clock if no other time providers are available. e.g. server 0.fedora.pool.ntp.org synchronizes the time with the Fedora time server pool. server 192.168.1.10 synchronizes the time with a computer at the specified IP address. server 127.127.1.0 synchronizes the time with the hardware clock on the local computer.

/etc/timezone

Configures the time zone on Debian-based distributions. /etc/timezone identifies the current time zone by region and zone.

/etc/sysconfig/clock

Configures the time zone on some distributions, such as openSUSE. The syntax is: TIMEZONE="timezone" e.g. TIMEZONE="America/Denver"

/usr/share/zoneinfo

Contains time zone configuration files and directories, with each file identifying a specific time zone. > Files are typically organized in subfolders based on continent (such as Australia) or major country (such as US). > Individual files identify a major city in the time zone (such as Perth) or a specific region (either a division of the country or a country within the continent). > Information in the file identifies the UTC offset and any rules for daylight savings time. *Depending on the distribution, time zone files might be located at /usr/lib/zoneinfo. e.g. ls /usr/share/zoneinfo displays the names for time zones that Linux uses. Additional settings are located in the subdirectories.

Coordinated Universal Time (UTC)

Coordinated Universal Time (UTC), formerly known as Greenwich Mean Time (GMT), is a method of identifying a common time between devices regardless of their physical location in the world. > UTC is adjusted periodically to match the rotation of the earth by adding leap seconds. Leap seconds are required because the official duration of a second does not exactly match the earth's rotation (but it is very close). > UTC matches time to the rotation of the earth using a single fixed point in Greenwich, England. A line drawn from the North Pole to the South Pole that passes through Greenwich is called the prime meridian. > It is preferable for Linux systems to use UTC (not local time). This ensures that a single method of keeping time is used, regardless of the physical location of the computer. It also ensures that timestamps on files, within logs, and on database records remain consistent, especially on networks with hosts residing in multiple time zones. > Time expressed using UTC is identified by adding UTC or Z to the time. For example, 09:30 UTC is the same as 09:30Z or 0930Z. UTC is also called Zulu time.

cupsd Parameters

The cupsd daemon is configured using the /etc/cups/cupsd.conf file. The following are common parameters in /etc/cups/cupsd.conf:

A Linux system can determine the time and date in which of the following ways? (Select TWO). It can use SMTP to set the time. It can set the system clock to the local time. It can use NNTP to set the time. It can use NTP to set time.

It can set the system clock to the local time. It can use NTP to set time. Linux systems can determine the local time in different ways. They can follow the traditional PC method of setting the system clock to the local time. One of the best ways to set the time and date is to use NTP (network time protocol) to automatically synchronize the date and time with time servers on the network/internet. NNTP (network news transfer protocol) and Simple Mail Transfer Protocol (SMTP) are not used to set the time.

General Considerations

Keep the following in mind when working with NTP: > To view events as the NTP daemon starts: - Use one terminal to start the daemon, and use another terminal with the tail command to view the daemon log at /var/log/ntp on init-based distributions. - Use one terminal to start the daemon, and use another terminal with the journalctl -f command running on systemd-based distributions. > The time used by the computer is adjusted to account for network delay and other inaccuracies detected in the received time. The amount of error that the algorithm identifies is called the drift. The drift is calculated over time and typically saved on the computer to quickly identify accurate time, compensated by the drift amount. > The computer continues to poll the time servers to ensure that the system time remains synchronized. > If configuration changes are made to the /etc/ntp.conf file, those changes won't take effect until the NTP daemon is restarted using the systemctl restart ntpd command.

MaxClients

Limits the number of concurrent client connections to the CUPS server. The default is 100. e.g. MaxClients 50

MaxCopies

Limits the number of copies of a document that can be printed for a single print job. The default is 100. e.g. MaxCopies 50

Linux Clocks

Linux systems keep time using two clocks:

Which of the following lines in the /etc/cups/cupsd.conf file will configure CUPS to listen for print jobs coming in on the server's network interface with the IP address 192.168.0.1 through the IPP port? Listen 192.168.0.0:631 Listen localhost:631 Listen 192.168.0.1:631 Listen *:631

Listen 192.168.0.1:631 Listen 192.168.0.1:631 listens for print jobs sent to 192.168.0.1 through the IPP port 631. The Listen section of the /etc/cups/cupsd.conf file specifies the network addresses the server uses when listening for print jobs. Listen localhost:631 listens only for print jobs from the local computer. Listen *:631 listens for print jobs sent to any address. Listen 192.168.0.0:631 listens for print jobs sent to the 192.168.0.0:631 network.

crontabfile

Loads a crontab job from a file. Write the file using the crontab syntax. *This command overwrites the current crontab. e.g. crontab /home/user/cronjobs creates a crontab file using the cronjobs file for the current user.

Local time

Local time is the current time in a local time zone. It is designated using the number of hours ahead or behind UTC time. For example the local time for the Mountain Time Zone in the United States is UTC -7. The default setting for several hardware clocks in a system BIOS is often local time.

How NTP Works

NTP uses a hierarchy of clocks and computers for synchronizing the current time. NTP: > Gradually synchronizes time in increments. > Allows computers to be a time consumer and a time provider simultaneously, allowing computers to synchronize time hierarchically. > Runs on IP port 123. > Uses strata to define time providers in a hierarchy (levels of time providers): - Stratum 0 devices are accurate clocks (such as atomic clocks) that provide the official UTC time. - Stratum 1 devices get their time from Stratum 0 devices. - Stratum 2 devices receive their time from stratum 1 devices, and can also provide time to other devices. > Supports up to 256 strata, with lower devices getting time from higher devices and providing time to devices in a lower stratum. > Can be configured to use a pool of time servers at pool.ntp.org. > Uses stepping to quickly make large adjustments to close wide time discrepancies; usually about once every 60 seconds. > Uses slewing to make smaller incremental time adjustments at a rate of about every 15 - 17 minutes. Slewing occurs when time discrepancies are under 128ms. > Does not adjust time when time discrepancies are larger than 17 minutes. This is known as insane time. > Logs time synchronization events in: - The /var/log/ntp file on init-based distributions. - In the system journal on systemd distributions.

Which of the following statements best describes the effects of having only the gshant user account listed in the /etc/at.allow file? Only gshant can use the at command. Only gshant and root can use the at command. All users but gshant can use the at command. Only root can use the at command.

Only gshant and root can use the at command. In this case, only gshant and root can use the at command. at uses configuration files to specify standard user accounts that can and cannot use the at command. /etc/at.allow specifies users who can use the at command. /etc/at.deny specifies users who cannot use the at command.

Ctrl+z

Pauses a running process and sends it to the background. A job ID number is assigned to the process.

lpq

Queries a print queue. This command displays job numbers and users who own the print jobs. Specify a username or a job number to see information about specific print jobs or print jobs for a specific user. Common lpq options include: -a shows the contents of all queues. -l gives a verbose (long) listing. -P specifies a specific printer's queue. -U specifies an alternative username. lpq -P Printer7 shows all print jobs and print job numbers for printer7.lpq -l tjones 56 shows a long listing of user tjones' job number 56.

ntpq -p

Queries the status of the NTP daemon. The output displays the following information for each time provider: remote specifies the IP address of the current time provider. refid specifies the type of the time provider. st shows the stratum of the time provider. when shows the last synchronization time. poll shows the synchronization interval. reach lists the last time NTP queried the time provider. delay displays the network lag time between the time provider and the client (in milliseconds). offset specifies the time difference between the local system clock and the time provider (in milliseconds). jitter specifies the size of time discrepancies (in milliseconds). e.g. ntpq -p displays the status of the ntpd daemon.

What does the lprm command do? Remove jobs from the line printer print queue. Redirect output to the line printer print queue. Send e-mail about the line printer status. Reschedule jobs for the line printer print queue.

Remove jobs from the line printer print queue. The lprm command deletes jobs from a print queue for a particular printer. lprm does not redirect output or reschedule print jobs or send email status.

lp

Sends a file to be printed to a CUPS printer. The syntax is lp -d printer_name filename. The following options are supported by the lp command: -n x prints x copies of the document. -m emails a confirmation message when the job is finished printing. -q x sets the priority of the print job to x. -o landscape prints the document in landscape format. -o sides=2 prints the document on both sides of the paper for printers that support duplexing. e.g. lp -d HPLJ5 mydocument sends the file named mydocument to the printer named HPLJ5.

lpr

Sends a job to the print queue (putting print jobs into the queue is called spooling). Common lpr options include: -#n prints n number of copies. -h prints without using a banner page. -P printer prints to the named printer. -r removes the job from the queue after printing. -w sets the page width of a printable document. lpr mydoc prints the mydoc file to the default queue.lpr -P printer7 mydoc sends the print job to the printer7's print queue.lpr -#33 mydoc prints 33 copies of the prospectus file.

Differences Between cron and anacron

The differences between cron and anacron are: > The cron daemon assumes that the Linux operating system will remain up and running 24 hours a day, seven days a week. If a system is not powered on when a scheduled cron job should run, it is skipped. > The anacron service compensates for times when the system is powered off. If a job is scheduled in anacron while the system is powered off, then the missed job will automatically run when the system comes back up.

For what purpose would you edit the /etc/localtime file? Change the value of the time zone (TZ) environment variable. Set the hardware clock time. Set the system date and time. Set the current time zone.

Set the current time zone. Use /etc/localtime (found typically on RPM distributions or /etc/timezone for Debian based distributions) to see the current time zone and change the time zone. The /etc/localtime file identifies the current time zone file used on the system. This is a symbolic link to a time zone file in the /usr/share/zoneinfo directory. Replacing this link changes the time zone. Use date to view and manually set the system date and time. Use hwclock to view and set the hardware clock time and synchronize the hardware clock and the system time. Use tzselect to change the value of the time zone (TZ) environment variable.

netdate

Sets the system time to match the time on a server running the time daemon on the network. The time provider must be running the time service on UPD port 37. e.g. netdate 192.168.1.10 sets the time on the local computer to match the time on the time server at 192.168.1.10.

BrowseAllow

Specifies computers and networks that can send print jobs. e.g. BrowseAllow all accepts all print jobs.BrowseAllow 192.168.1.0/255.255.255.0 allows print jobs from the 192.168.1.0 domain with a subnet of 255.255.255.0.BrowseAllow *.mynetwork.com allows print jobs from all computers on the domain.

BrowseDeny

Specifies computers that cannot send print jobs. e.g. BrowseDeny all rejects all print jobs. Other options are identical to BrowseAllow.

BrowseAddress

Specifies the address CUPS servers use to broadcast servers. This must be set for broadcasts to work. The default is no setting. Check this first if CUPS clients do not receive broadcasts. e.g. BrowseAddress 192.168.2.255:631BrowseAddress printserver.mynetwork.com:631

LogLevel

Specifies the error severity level to be logged. You can specify: none for no logging. error to log errors only. warn to log errors and warnings. info to log errors, warnings, and print requests (default). debug to log most cupsd messages. debug2 to log all cupsd messages. e.g. LogLevel warn

Listen

Specifies the network addresses the server uses when listening for print jobs. e.g. Listen 192.168.10.1:631 listens for print jobs sent to 192.168.10.1:631.Listen *:631 listens for print jobs sent to any address.Listen localhost:631 listens only for print jobs from the local computer.

User

Specifies the user who the cupsd process will run as. The default is lp. e.g. User lp

BrowseOrder

Specifies whether the server allows or denies print jobs by default, then specifies the order in which the BrowseAllow and BrowseDeny parameters are checked. e.g. BrowseOrder allow,deny denies by default, then checks the BrowseAllow parameter, and then the BrowseDeny parameter.BrowseOrder deny,allow allows by default, then checks the BrowseDeny parameter, and then the BrowseAllow parameter.

Group

Specifies which group cupsd will run as. The default is lp. e.g. Group lp

rcntp start (init) or systemctl start ntpd (systemd)

Starts the NTP daemon. e.g. systemctl start ntpd starts the NTP daemon.

System time

System time keeps time using software running within the operating system. > Time on the system clock is measured as the number of seconds that have elapsed since 12:00 AM on Jan 1, 1970. > By default, when the computer boots, it initially sets the system time using the current time from the hardware clock. > After the operating system is running, the system time is the only clock used by applications and services. The hardware clock is ignored. > Changing the system time does not automatically change the hardware clock, although you can change the system time and change the hardware clock to match.

Scheduler

The CUPS scheduler is a specialized web server created by the cupsd daemon that handles Internet Printing Protocol (IPP) print requests on IP port 631. The scheduler can process print requests that originate from the local computer system or from remote systems over the network. The scheduler also provides a web-based administration interface that is used to manage all of the components in the CUPS system.

CUPS Components

The CUPS service is provided by the cupsd daemon. CUPS employs the following components:

Command

The Command field specifies the command or script that should be run.

Delay

The Delay field specifies the time (in minutes) that the anacron daemon should wait before executing a missed job after the system starts back up.

Job-identifier

The Job-Identifier field specifies a name that will be used for the job's timestamp file. The identifier must be unique for each anacron job. The timestamp file is created in the /var/spool/anacron directory and contains a single line with a timestamp that indicates the last time the particular job was run.

10.4.7 Printer Management Facts

The Line Printer Daemon (LPD) is the older print management daemon for Linux systems. Although CUPS has replaced LPD for the most part, most LPD commands are also supported by the cupsd daemon. This lesson covers the following topic: LPD and CUPS commands

10.5.9 NTP Facts

The Network Time Protocol (NTP) is used to synchronize system time between computers over a network connection. This lesson covers the following topics: How NTP works NTP files and utilities General considerations

Postscript Printer Descriptions (PPD)

The Postscript Printer Descriptions (PPD) are files that the cupsd daemon uses to determine printer capabilities. These files are located at /etc/cups/ppd.

UTC offset

The UTC offset identifies the amount of time that local time is ahead of or behind Coordinated Universal Time (UTC). > Local time in each time zone is identified by the UTC offset. For example: > Time zones used in the United States are UTC-05 (Eastern), UTC-06 (Central), UTC-07 (Mountain), and UTC-08 (Pacific), with time being behind UTC. > Time zones used in Europe and Asia are ahead of UTC. For example, time in Germany is UTC+01, and time in Japan is UTC+09. > To convert UTC to local time, add time based on the UTC offset (UTC + offset). For example, if UTC is 06:00: > Local time in New York (UTC-05) would be 01:00 (06:00 + - 5:00 = 1 am). > Local time in Los Angeles (UTC-08) would be 22:00 the previous day (10 pm). > Local time in Japan (UTC+09) would be 15:00 (3 pm). > To convert local time to UTC, subtract time based on the UTC offset (UTC - offset). For example: > If the local time in New York (UTC-05) is 14:00, UTC is 19:00 (14:00 - - 5:00 = 14:00 + 5:00). > If the local time in Japan (UTC+09) is 14:00, UTC is 5:00 (14:00 - + 9:00). > UTC does not change for daylight savings time; however, the offset used by a time zone will change. During daylight savings time, add one hour to the UTC offset. For example: > Standard time in New York is UTC-05; daylight time in New York is UTC-04. > Standard time in Germany is UTC+01; daylight time in Germany is UTC+02.

10.4.9 Remove a Print Job

The bcassini user sent a document called baby1 to the printer. The document is a large photo file that is taking up the printing resources, and jobs behind baby1 can't print. In this lab, your task is to: Use lpq to find the baby1 print job number. Use lprm print job number to delete print job from the print queue. Complete this lab as follows: At the prompt, type lpq and press Enter. Type lprm 1 and press Enter.

How CUPS Processes Print Jobs

The following are the steps CUPS uses when processing print jobs: The client sends the print job to the cupsd daemon on the server. The daemon creates the files and places them in the queue. Print jobs pass through the filters and are converted to the appropriate PDL. The backend sends the print job to the printer. The backend notifies the cupsd daemon when the job is completed, and the job is removed from the queue.

LPD and CUPS Commands

The following table describes commands associated with LPD and CUPS:

Time Zone Tools and Files

The following table describes the tools and files used to determine and change time zone settings:

Hardware clock

The hardware clock keeps time using a chip on the system's motherboard. > The hardware clock runs independently of any software. The clock does not require access to the CPU or system RAM to run. > Soft power from the power supply and the CMOS battery ensures that the clock continues to run when the computer is turned off or even unplugged. > The hardware clock is sometimes called the real-time clock (RTC), BIOS clock, CMOS clock, or time of year (TOY) clock. > The current hardware clock time is stored in the /proc/driver/rtc file.

You have connected a new printer to a systemd-based Linux server. You cannot print to the new printer from a user workstation on the network. What tasks should you complete on the server first? (Select TWO.) Use systemctl status cups to make sure the CUPS printing service is running. Use rpm -qi printd or dnf list printd to make sure the print daemon is installed. Use rpm -qi cups or dnf list cups to make sure the CUPS daemon is installed. Use service cupsstatus to make sure the CUPS printing service is running. Use the command service printer restart to restart the print service.

Use systemctl status cups to make sure the CUPS printing service is running. Use rpm -qi cups or dnf list cups to make sure the CUPS daemon is installed. When you connect a printer to a server and you want to share that printer with users on the network, you must first complete the following: Install the CUPS package on the server. You can use rpm -qi cups or dnf list cups to make sure the CUPS daemon is installed. If the package is not installed, use dnf install cups to install it. Make sure the CUPS daemon is running. You can use systemctl status cups to make sure CUPS printing service is running. If the service is not running, enter systemctl start cups.

cron Commands

Use the following commands to manage cron task scheduling.

Clock and Time Files and Utilities

Use the following files and utilities to manage the hardware clock and system time:

NTP Files and Utilities

Use the following files and utilities to manage time using the NTP:

date

Used to view and manually set the system time. e.g. date shows the current local time and the time zone.

User Process

User processes start when a user executes a program file. For example, a user starts a user process when she executes the grep command.

lpc

Views and manage printers and print queues. Subcommands for lpc include: status shows the current state of a printer. clean removes all files from a print queue. restart attempts to restart a printer daemon for a printer. lpc status printer7 displays the current state of printer7.lpc clean all empties the print queues for all printers.

date

Views and manually sets the system time. Options include: -d [date] displays the date specified by date. Use now to display the current date. -s sets the date and time. -u, --utc specifies UTC time. e.g. date -s "11/20/2020 15:48:00" sets the time and date to 3:48:00 PM on November 20, 2020. date -su "11/20/2020 15:48:00" sets the UTC time and date to 3:48:00 PM on November 20, 2020 date -d 01jan2014 displays the specified date. date -u shows the current UTC time.

hwclock

Views and sets the hardware clock time and synchronize the hardware clock and the system time. Options include: -a, --adjust adds or subtracts time from the hardware clock to account for systematic drift since the last time the clock was set or adjusted. -r, --show displays the current hardware clock time. hwclock assumes -r if no options are used. --set --date= sets the hardware clock time and date. -s, --hctosys sets the system time to the current hardware clock time. -w, --systohc sets the hardware clock based on the system time. --localtime sets the hardware clock to local time. -u, --utc sets the hardware clock to UTC time. e.g. hwclock -w sets the hardware clock time to match the system time. hwclock --set --date="2/24/2020 16:45:05" -utc sets the hwclock time to 4:45:05 PM on February 24, 2020 on UTC time. hwclock -s sets the system time to match the hardware clock. hwclock -u sets the hardware clock time to UTC time.

/proc/driver/rtc

Views the hardware clock time. e.g. cat /proc/driver/rtc displays the hardware clock time.

lpstat

Views the status of a printer. Options include: -t shows all information for all printers on the network. -u shows print jobs for a specific user. lpstat -t shows all information about all printers.lpstat -t printer7 shows all information for printer7.lpstat -t -u jsmith shows all information for all print jobs for the user jsmith.

General Considerations

When dealing with time zones, be aware of the following details: > The time zone ensures that daylight hours fall within a certain time period, regardless of the area of the world. > In many areas, daylight savings time (DST) moves clocks ahead by one hour from the standard time zone time during "summer" when there are more daylight hours. Not all locations observe daylight savings time. For example, areas along the equator typically do not because the number of daylight hours does not vary significantly throughout the year. > The local time is the time used in your physical location, adjusting for the time zone and daylight savings time (if used). > As you change your physical location, the local time can also change based on the time zone used in that area. > Time zone names used in the United States (Eastern, Central, Mountain, Pacific) are not part of the official time zone standards, but are useful in comparing time between different parts of the country. In the United States, the time zone names can also reflect whether or not daylight time is in effect. > Eastern Daylight Time (EDT) identifies the Eastern time zone, observing daylight standard time. > Mountain Standard Time (MST) identifies the Mountain time zone, not observing daylight standard time.

10.3.9 Configure Crontab

You're the IT administrator for a small corporate network. You want a specific task to run on the CorpData server automatically. In this lab, your task is to: Use crontab to create a crontab file for the root user. Add parameters to the file that will run the /bin/updatedb command every Tuesday and Saturday morning at 2:30 a.m. Complete this lab as follows: > At the prompt, type crontab -l and press Enter to view the current crontab file. > Type crontab -e and press Enter to create a new crontab file. > Press 1 to chose the nano editor. > Press Enter. > Press Enter to create a new line in the editor. > On the new line, type 30 2 * * 2,6 /bin/updatedb. > Press Ctrl + O to write out (save) your changes. > Press Enter to accept the file name. > Press Ctrl + X to exit the editor. > Type crontab -l and press Enter to view the current crontab file.

Which of the following commands removes a job from the at queue? (Select TWO. Each answer is an independent solution.) atrm at -l at -d at -f atq

atrm at -d at -d or atrm removes a job from the at queue. Use commas to separate multiple jobs. For example: at -d 2,3 removes jobs 2 ad 3 from the at queue. atrm 4 removes job 4 from the at queue. Use at -f to schedule tasks in a file to run at the designated time (like a shell script, for example). Use at -l or atq to list the tasks in the at queue for the current user. When run as root, atq or at -l lists all the jobs in queue. When run as a user other than root, at lists only the jobs for the user.

Which of the following commands removes print job 11 from the hp7 printer? lprm 11 cancel -U hp7 11 cancel -P hp7 11 cancel 11

cancel -P hp7 11 cancel -P hp7 11 cancels print job 11 on hp7. Use cancel to cancel print jobs. Options include -P, which specifies a printer, and -U, which specifies a user name. lprm 11 removes the job from the default print queue, not hp7.

After logging in as root, you need to manage the crontab files for your Linux system. Which command should you use to edit the crontab file for the gshant user account? crontab -ue gshant crontab -ul gshant vi /etc/crontab crontab -ur gshant

crontab -ue gshant Use crontab -ue gshant to edit the crontab file for the gshant user account. Use crontab to manage the /var/spool/cron/username crontab file. Be aware of the following options: -u username specifies a user for the -e, -l, and-r options. -e edits the crontab file in vim for the current user. -l displays the contents of the crontab file. -r removes the crontab file. Use vi /etc/crontab to open and edit the /etc/crontab file in Vim. The /etc/crontab file holds entries that direct commands to execute at a specific time. The/etc/crontab file is for custom task schedules that run system-wide, can only be edited by the root user, and runs each entry as the root user.

Which of the following NTP configuration utilities is deprecated and should be avoided when possible? ntpd ntpq ntpdate ntptrace

ntpdate ntpdate is deprecated; use ntpd in its place. ntpdate updates the current time on a computer. ntpdate: Must be run as root. Will not function if ntpd is currently running. ntpd manages the NTP daemon from the command line. ntpq queries the status of the NTP daemon. ntptrace displays the next stratum up from the time provider.

You want to configure CUPS from a web browser. Which URL address and port should you enter within the web browser's address field?

http://127.0.0.1:631 Use http://127.0.0.1:631 or http://localhost:631 to access the web-based CUPS administration utility. localhost or 127.0.0.1 represents the local system. :631 signifies that the browser should connect on port 631. Port 631 is important, since it is where the daemon listens for an HTTP connection.

You need to set the hardware clock to the same value as the system clock. Which command should you use? hwclock -a hwclock -s hwclock -w hwclock -r

hwclock -w hwclock -w or hwclock --systohc sets the hardware clock time to the current system time. Use hwclock to view and set the hardware clock time and synchronize the hardware clock and the system time. Other hwclock options include the following: -a, --adjust adds or subtracts time from the hardware clock to account for systematic drift since the last time the clock was set or adjusted. -r, --show displays the current hardware clock time. hwclock assumes -r if no options are used. --set--date sets the hardware clock time and date. -s, --hctosys sets the system time to the current hardware clock time. --localtime sets the hardware clock to local time. -u, --utc sets the hardware clock to UTC time.

After a severe lightning strike nearby, a number of processes seem to be running on the server in runaway mode. Which utility terminates these processes by name, and not just by process ID number? endall down closeproc killall

killall Use the killall utility to terminate processes by name. down, endall, and closeproc are not actual Linux commands.

You need to create a symbolic link to the /usr/share/zoneinfo/EST time zone file that permanently alters the time zone for the system. What should you enter at the command prompt to accomplish this task?

ln -s /usr/share/zoneinfo/EST /etc/localtime Use one of the following commands to create a symbolic link to the /usr/share/zoneinfo/EST time zone file that permanently alters the time zone for the system: ln -s /usr/share/zoneinfo/EST /etc/localtime cp -s /usr/share/zoneinfo/EST /etc/localtime The /etc/localtime file identifies the current time zone file used on the system. This is a symbolic link to a time zone file in the /usr/share/zoneinfo directory. The /usr/share/zoneinfo directory contains a set of timezone configuration files, with each file identifying a specific time zone. Files are typically organized in subfolders based on continent (such as Australia) or major country (such as United States). Individual files identify a major city in the time zone (such as Perth) or a specific region (either a division of the country or a country within the continent). Information in the file identifies the UTC offset and any rules for daylight savings time. Depending on the distribution, time zone files might be located at /usr/lib/zoneinfo.

Which of the following commands removes all files from the print queue? lpc remove lpc clear lpc status lpc clean

lpc clean lpc clean removes all files from a print queue. Use lpc to view and manage printers and print queues. Subcommands for lpc include the following: status shows the current state of a printer. clean removes all files from a print queue. restart attempts to restart a printer daemon for a printer. There are no lpc clear or remove options.

Which command will show the contents of ALL the print queues on your Linux system?

lpq -a Use lpq -a to display the contents of all queues. Use lpq to query a print queue. This command displays job numbers and users who own the print jobs. Other common lpq options include the following: -l gives a verbose (long) listing. -P specifies a specific printer's queue. -U specifies an alternative username.

You want to send the yearend.txt file to the acctg printer. Which command should you use? lpq -P acctg yearend.txt lpr -P acctg yearend.txt lpq yearend.txt lpout -P acctg yearend.txt

lpr -P acctg yearend.txt Use the lpr -P acctg yearend.txt command to redirect the file to printer acctg. lpq is for checking on the status of a print queue and does not direct files to printers. There is no command or utility called lpout.

What should you enter at the command prompt to print 23 copies of the comparables file on the homeprint printer?

lpr -P homeprint -#23 comparables Use lpr -P homeprint -#23 comparables to print 23 copies of the comparables file on the homeprint printer. Use lpr to send a job to the print queue (putting print jobs into the queue is called spooling). Common lpr options include the following: -#n prints n number of copies. -P printer prints to the named printer. -h prints without using a banner page. -r removes the job from the queue after printing. -w sets the page width of a printable document.

Which command should you use to change the time zone (TZ) environment variable? (Select TWO). netdate date tzselect tzconfig

tzselect tzconfig Use tzselect or tzconfig to change the value of the time zone (TZ) environment variable. When executed, the utility prompts you to select a region, then a country, and so on until it has enough information to determine the time zone. The tzconfig command is used on Ubuntu Linux distributions in place of tzselect. netdate sets the system time to match the time on a time server on the network. date manually sets the system time.

What is the default nice value for a process not executed with the nice command?

0 Zero (0) is the default nice value for processes not executed with the nice command. To start a command with a higher or lower priority, use nice. To assign a new priority to a process that has already started, use renice.

Be aware of the following when working with processes:

> Either the init or the systemd process is the first process started by the kernel. depending upon the distribution. These processes: - Always have a PID of 1. - Spawn all additional processes the operating system needs at boot time. > Forking occurs when a parent process spawns a child process that is identical to the parent. An example of forking is the subshell that the shell creates when a user runs a command at the shell prompt. The command runs within the subshell. When the command completes, the subshell it ran within is destroyed. > A zombie process is one where the process was finished and hasn't released the child process' PID number. Zombie processes can linger in the system, consuming resources and PIDs. A zombie process may eventually clear up on its own. if it doesn't, you may need to manually kill the parent process. > A single-threaded CPU can run only one process at a time.

at

A command that schedules another command to be run once at a particular time.

cron

A command used to schedule commands at a specific time.

Parent process ID

A number that identifies the process that spawned (or started) the current process.

Process ID (PID)

A number that uniquely identifies each process.

Processor Types

A process refers to a program that is loaded into memory and is currently running on the system CPU. The following file types can creates processes on a Linux system.

Binary executable

A program compiled into a binary file that the CPU can execute.

nohup &

Allows a command or shell script to continue running in the background after logging out from a shell. *nohup does not automatically put the command it runs in the background; use the ampersand (&) symbol to start a process in the background. e.g. nohup gedit & starts the gedit process in the background and leaves it running after logging out of the shell.

Internal Shell Commands

An internal shell command is a command built into the shell executable.

10.2.9 Stop a Zombie Process

As a part of your daily maintenance, you scan for and kill any zombie processes on the system. In this lab, your task is to: Use the ps aux command to find zombie processes. Zombie processes have a Z in the STAT column of the ps aux output. Use kill -9 PID to terminate the zombie processes. Use ps aux | more or ps aux | less to see all of the processes. Use the following commands to stop the processes: > Use the ps aux command to find zombie processes as follows: - At the prompt, type ps aux | less to view the list of processes. - Use the up/down arrows to find the processes with status z. - Type q to exit the process list and return to the command prompt. > Terminate the processes as follows: - Type kill -9 1301 and press Enter. - Type kill -9 1570 and press Enter. - TYpe kill -9 1980 and press Enter.

Process States

As a process executes, it changes states according to its circumstances. These states can be viewed using the ps aux command and will be identified by one or more letters The most common state are:

10.2 Process Management

As you study this section, answer the following questions: What is the difference between a process running in the foreground and a process running in the background? Which commands can be used to move processes between the foreground and the background? How can you change the priority of a process? What is the range for nice values? What number would be the highest priority for a nice value? Which termination signal is sent by the Ctrl+z key combination? In this section, you will learn to: Stop a zombie process. Switch a process between the foreground and background. Key terms for this section include the following:

10.3 Task Management

As you study this section, answer the following questions: Which script controls the at daemon? Which files control access to the at command? What is the main difference between using at and cron to schedule a job? Which files control access to the cron command? Where is the system-wide crontab file located? How can you edit personal crontab files? In this section, you will learn to: Configure crontab. Key terms for this section include the following:

10.1 Processes

As you study this section, answer the following questions: Which types of files can create processes on a Linux system? What is the difference between user processes and daemon processes? How are system processes usually identified? Which process is always assigned the same process ID number? What is the major difference between how top and ps display system processes? In this section, you will learn to: Use top to monitor Linux processes. Use ps to troubleshoot a Linux system. Use pgrep to view process information. Key terms for this section include the following:

renice

Assigns a new nice value to a running process using the PID of the process. The command can contain multiple PIDs separated by a space to give them all the same priority number. The nice values assigned are identical to those used with the nice command. You can use several options with renice: -n specifies a priority. -u specifies a user. -g specifies a group. e.g. renice -5 3346 assigns a nice value of -5 to the process with a PID of 3346. This raises the priority of the process from the default. renice 7 2266 3902 assigns a nice value of 7 to both processes. This lowers the priority of both processes from the default. renice 5 -u userbob sets the nice value of all processes owned by userbob to 5.

fg

Brings a job to the foreground. e.g. fg 1 brings the job with job ID 1 to the foreground.

10.2.11 Practice Questions

CIST 2431

While editing a script using gedit, you discover that you no longer have access to your current terminal session and need to check the values of some variables the script is using. Which of the following commands will send the gedit process to the background so you can regain access to the current terminal? Ctrl+C Ctrl+Z bg Ctrl+Alt+F2

Ctrl+Z Ctrl+Z will pause the gedit process and send it to the background, allowing access to terminal. Ctrl+C will send a break signal to the process to terminate. Ctrl+Alt+F2 will switch to a virtual terminal tty2. This will not accomplish the desired task. bg will send a process to the background; however, in this case, there is no access to the terminal command line to enter the command.

After running ps -ef, you notice a number of processes that display getty. You are not familiar with that process and want to make sure it is not malicious, so you check the man pages and find that is a valid Linux process that manages physical or virtual terminals (TTYs). What should you do NEXT? Check the log files to see what getty has been accessing. Immediately terminate all processes associated with getty. Determine the process is not a concern. Check the /etc/passwd file to see if there is a user named getty allowed on the system.

Determine the process is not a concern. A getty process represents a terminal that does not currently have a user. It is normal to see many getty processes on a system that is configured for more than one terminal.

ps

Displays a snapshot of currently running processes in ascending order based on the PID. By default, the ps command displays the following information: > PID > Name of the shell session where the process is running (TTY) > CPU time the process has used (TIME) > The command used to invoke the process (CMD) Be aware of the following ps options: -A, e shows all processes. -a shows processes owned by other users and attached to a terminal (e.g., foreground processes). -f shows detailed information for processes. -u shows processes by user ID. -l shows the processes in long format, and the process state (under the STAT column). The process states include: - sleeping (S) - running (r) - traced (t) by another process - zombie (Z) -x shows processes that are not attached to a terminal. Use this option to view daemon processes that begin during system boot. e.g. ps -Au jsmith shows all processes owned by the user jsmith.ps -elf shows detailed information about all processes in long format.ps aux shows detailed information about all processes.

10.2.10 Bring an Application to the Foreground

Explore putting a process in the background and then bringing it back to the foreground. In this lab, complete the following tasks: At the prompt, type ping localhost & to launch ping in the background. Ping continues to show on the screen, but you can still interact with the console. Press CTRL + C to stop the ping. What happens? Type cd /. Type ls. What happens? Type fg. Press CTRL + C. What happens? Complete this lab as follows: > At the prompt, type ping localhost & and press Enter to launch ping in the background.Ping continues to run in the background and its output will show on the screen. You can still interact with the console and run other commands in the foreground. > Press CTRL + C. This would normally stop the ping. The command is not recognized because ping is in the background. > Type cd / and press Enter. Notice that other commands entered in the foreground. > Type ls and press Enter.Notice that the output of ls is interspersed with the output of ping running in the background. > Type fg and press Enter to bring the ping command back to the foreground.Ping is now running in the foreground and the console will not allow other commands to be run. > Press CTRL + C. The ping command is now terminated since it is in the foreground.

Keep Running a Process After Logging Out

In addition to killing a running process, you may encounter situations where a process must be kept running even after the user has logged out of the system. Normally, when a user logs out of the terminal session, Linux sends a SIGHUP signal to all the programs associated with that shell session. In response, each process will respond as it is programmed to when it receives a SIGHUP signal. However, a process can be told to ignore SIGHUP signals, which will allow it to remain running even if the user logs out of the shell session where it was started.

During the process of troubleshooting a resource issue on a server, the technician entered the following command and received the output showing zombie processes. [user@centos7]#ps aux |grep Z USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND ljenkins 2346 0.0 0.0 0 0 ? Z 08:44 0:02 [kdmflush] ljenkins 3365 0.0 0.0 0 0 ? Z 08:64 0:14 [bioset] ljenkins 3812 0.0 0.0 0 0 ? Z 09:31 0:05 [bioset] ljenkins 4957 0.1 0.0 0 0 ? Z 10:16 0:35 [email-client] ljenkins 5276 0.1 0.0 0 0 ? Z 12:04 0:45 [email-client] What should the technician do NEXT to resolve the issue with zombie processes? Kill each of the PIDs listed in the command output. Kill any child processes. Nothing. The systemctl process will clean up the processes automatically each week. Kill the parent process.

Kill the parent process. A zombie process has finished executing and exited, but its parent wasn't notified that the child process was finished and hasn't released the child process's PID number. Zombie processes can linger in the system, consuming resources and PIDs. A zombie process may eventually clear up on its own. If it doesn't, you may need to manually kill the parent process. Killing any child processes doesn't fix the problem. Killing each of the PIDs doesn't fix the problem. systemctl does not automatically clean up processes each week.

at -latq

List the tasks in the at queue for the current user. When run as root, atq or at -l lists all the jobs in the at daemon's queue. When run as a user other than root, at lists only the jobs for the current user. e.g. atq shows all jobs in the at queue.

10.2.8 Process Termination Facts

Normally, users should use the exit function (which is coded into nearly all programs) to end a running process. For example, the Ctrl+c key sequence is used to exit the top program. However, processes occasionally hang and refuse to exit properly. This lesson covers the following topics: Terminate a running process Keep running a process after logging out

Running

Process: R Description: The process is either running (it is the current process in the system) or is waiting for the CPU to process it.

Waiting - Sleep

Process: S Description: Interruptible sleep (waiting for an event to complete)

Stopped

Process: T Description: The process has been stopped or suspended.

Zombie

Process: Z Description: The process has finished executing and exited, but the process' parent didn't get notified that the child process was finished and hasn't released the child process' PID number.

You need to manage a process in the foreground by pressing Ctrl+C on the keyboard. Which signal code is sent to the process? SIGINT SIGHUP SIGTERM SIGKILL

SIGINT The Ctrl+C key sequence sends a SIGINT interrupt signal to the process. SIGHUP stops and restarts the process with the same process ID number. This also causes the process to reload its configuration file. SIGKILL invokes a hard kill of the process that may not allow the process to unhook its resources. This means that RAM and other resources allocated to the process usually remain allocated to the process. SIGTERM stops the process after allowing it to unhook its resources.

at time date

Schedule the command to run at a specific time and date. Options and syntax include: today tomorrow month # MMDDYY MM/DD/YY DD.MM.YY e.g. at 12:12AM starts the command the next time the clock reads 12:12 AM. at 12:12AM September 1 starts the command at 12:12 AM on September 1. at 12:00AM 01/01/2016 starts the command at 12:00 AM on January 1, 2016. at 12:00AM 01012016 starts the command at 12:00 AM on January 1, 2016. at 12:00AM 01.01.2016 starts the command at 12:00 AM on January 1, 2016.

at now + number time_period

Schedule the command to run at the designated time in the future. Use: minutes hours days months e.g. at now + 6 days starts the command 6 days after the time the command is issued. at now + 1 months starts the command 1 month after the time the command is issued.

at -f filename time

Schedule the tasks listed in the specified file to run at the designated time. e.g. at -f /home/user/mycommands now + 3 hours starts the jobs listed in the mycommands file in three hours from the time the command is issued.

bg

Sends a job to the background. e.g. bg 3 sends the job with job ID 3 to the background.

nice

Starts a process and customize its priority on the system by manipulating the process's nice value. Be aware of the following: > Each process running on a Linux system has a priority (PR) and nice (NI) value associated with it. > The PR value represents the process's kernel priority. The higher the PR value, the lower the priority of the process. The lower the PR value, the higher the process's priority. > The NI value is factored into the kernel calculations that determine the PR value of a process. Changing the NI value associated with a process also changes its PR value. > NI values range from 19 (lowest priority), to -20 (highest priority). The higher the NI value, the lower the process's priority.The lower the NI value, the higher the process's priority. > Use -n to specify the priority value. If no value is specified, the process starts with a nice value of 10 by default. > Zero (0) is the default nice value for processes not executed with the nice command. *To keep users from abusing the nice command, standard users are not allowed to specify a nice value less than 0. Only root can assign a nice value that is a negative number. e.g. nice -n 7 gedit starts gedit with a nice value of 7. This runs the process with a lower priority than the default. nice -n -9 gedit starts gedit with a nice value of -9. This runs the process with a higher priority than the default.

command &

Starts a process in the background, leaving the shell available for other commands. When running a process in the background, the shell displays the following information: The job ID in brackets The process ID (PID) e.g. gedit & starts the gedit process in the background.

kill

Terminates a process using a process ID (PID) number and a specific kill signal. Kill signals can be sent using a term or a numeric value. Options include the following: -SIGHUP, -1 tells the process to shut down and restart. When it restarts, the process will have the same PID it had when the kill signal was sent. -SIGINT, -2 stops a process as if the Ctrl+c key combination had been used. This option is recommended as the first choice when a process will not stop with its exit function or init script. -SIGKILL, -9 forces a process to stop when it is unresponsive to other options for exiting or killing it. Running this option does not give the process a chance to clean up any resources that it is using, such as memory. Resources allocated to the process usually remain allocated to it until it is restarted. This option should only be used as a last resort. -SIGTERM, -15 stops the process cleanly by giving it a chance to release the resources allocated to it. This is the default signal used by the kill command if no signal is specified. This option can be tried if the -2 option fails to kill the process. -l lists all of the signals that are available for the kill command. e.g. kill -1 6754 shuts down and restarts the process. kill -9 6754 forces the unresponsive process to stop running. kill -SIGKILL 6754 (which has the same effect as using -9) forces the unresponsive process to stop running. kill 6754 stops the process with PID 6754 using the default SIGTERM signal.

killall

Terminates processes the same way as the kill command, using their command name instead of their PID. This command uses the same signal commands that kill uses. e.g. killall atd kills all processes named atd. killall -9 atd uses a hard kill to stop the atd process.

/etc/cron.allow

The /etc/cron.allow file identifies users who are allowed to create their own cron jobs. If /etc/cron.allow file exists, then only users listed within it are allowed to create a crontab file in /var/spool/cron/username. All other users are denied, and the /etc/cron.deny file is ignored.

/etc/cron.deny

The /etc/cron.deny file identifies users who are not allowed to create cron jobs. If the /etc/cron.deny file exists, only the users listed within it are not allowed to edit /var/spool/cron/username. Everyone else is allowed. This file is only processed if the /etc/cron.allow file does not exist.

/etc/crontab

The /etc/crontab (cron table) file holds entries that direct commands to execute at a specific time. The /etc/crontab file: Is used to schedule custom tasks that run system wide. Can only be edited by the root user. *crond runs tasks scheduled in the /etc/crontab file as the root user.

Process ID (PID)

The PID uniquely identifies each process. System-started processes typically have low numbers, while user-started processes have higher numbers.

10.3.3 at Command Facts

The at daemon (atd) schedules tasks to occur once at a specific time in the future. This lesson covers the following topics: About the at daemon (atd) at daemon commands

About the at Daemon

The at daemon: Is managed using: > The atd init script in the /etc/rc.d/init.d/ or /etc/init.d/ script directory on init-based distributions. > The atd.service file and the systemctl command on systemd-based distributions. Uses configuration files to specify standard user accounts that can and cannot use the at command. > /etc/at.allow specifies users who can use the at command. > /etc/at.deny specifies users who cannot use the at command. *If the at.allow file exists, then only users listed in the file are allowed to create at jobs. The at.deny file is ignored. If at.allow does not exist, then just the users listed in at.deny are blocked from creating at jobs. Everyone else is allowed to create jobs. Be aware of the follow general steps when using the at utility: 1. Enter at time. The at> prompt is displayed 2. Enter each command you want to run at the at> prompt, one command per line. Press Enter after each command. 3. Press Ctrl+d to exit the at> prompt.

10.3.6 cron Facts

The cron daemon (crond) schedules tasks to run in the future on a regular basis. This lesson covers the following topics: cron configuration files Syntax for cron jobs cron commands

/etc/cron.directory

The cron daemon executes the scripts found in each of the following directories at the specified interval for the whole system: /etc/cron.hourly /etc/cron.daily /etc/cron.weekly /etc/cron.monthly

cron Configuration Files

The following configuration files are used with cron:

Adjusting Process Priorities

The following table describes ways to adjust process priorities.

Moving Processes between the Foreground and the Background

The following table describes ways to move processes between the foreground and the background.

Viewing Processes Using pgrep

The pgrep command combines the functionality of the ps command and the grep command into one single command or utility. When you run pgrep, you can specify certain selection criteria that you want the command to look for. The command then searches through all the current running processes, and then outputs a list of only those processes that match the criteria that you specify.

pgrep

The pgrep command includes many options. The following are a few of the more useful options: -f searches for a specific process name. -p 0nly match processes whose parent process ID is listed. -u only match processes whose effective user ID is listed (the user that owns the process). e.g. pgrep -l -u jsmith show all the process owend by jsmith (-u) in long (-l) format.

Mario, a technician, executed pgrep -u sally and received the following result: 1036 Which of the following describes the result? The PID for the process named sally. The process ID of the process that was executed by the user sally. The permission ID for the user Sally. The UID for the user sally located by searching the entire file system for active processes.

The process ID of the process that was executed by the user sally. pgrep -u sally returns the number of any processes that the user Sally started. The other options do not describe the results.

Viewing Processes Using ps

The ps command is used to provide information about the currently running processes, including their process identification numbers (PIDs).

at Daemon Commands

The table below lists the most common commands for managing tasks with the at command:

Viewing Processes Using top

The top command displays the activity of your Linux processor and also displays tasks managed by kernel in real-time.

top

The top command: > Returns Process ID (PID), uptime, load, CPU status, memory, and priority information for processes. > Is useful in situations where you need to continuously monitor processes. When using top, press: h to display the help screen. f to add or remove columns from the chart. F to show a list of sortable columns, then press the key of the letter next to the column to be sorted. u to specify processes for a specific user. You can use the -u option with top to display only those processes owned by a particular user. e.g. top -u gshant starts top by monitoring only the gshant user.

10.1.3 Process Facts

This lesson covers the following topics: Processor types Processor numbering Process states

10.1.9 Process Display Facts

This lesson covers the following topics: Viewing processes using top Viewing processes using ps Viewing processes using pgrep

at time_of_day

Use time of day keywords to run the command. Options are: Midnight (12:00 AM) Noon (12:00 PM) Teatime (4:00 PM) e.g. at midnight starts the command the next time the clock reads 12:00 AM.

screen

Uses multiple shell windows from within a single SSH session. Using screen, you can: Keep processes running while you access the shell prompt through an SSH connection to enter additional commands. Keep an SSH shell active even if the network connection is closed or goes down. Disconnect and reconnect to a shell session from multiple locations without having to stop and then restart whatever processes were running. The screen package must be installed on the system before it can be used. After screen is installed, launch it by entering screen at the shell prompt. A shell prompt is displayed within a window inside the screen. Each window functions like a normal shell session. Within screen, pressing Ctrl+a causes whatever is typed by the user to be sent to the screen process instead of to the shell: > Pressing Ctrl+a ? causes the screen help to be displayed. > Pressing Ctrl+a c causes a new screen window to be created. The old window remains active along with any processes that were running within it. > Pressing Ctrl+a n toggles between open windows in screen. > Pressing Ctrl+a d detaches the screen window and returns the user to the original shell prompt. Whatever was running in the window remains running. In fact, the user can completely log out, and everything will keep running within the detached window. > Entering screen -r reattaches a detached screen window. If multiple detached screen windows exit, the user will be prompted to specify which one to reattach to.

jobs

Views background jobs and their associated job ID numbers. The job ID number is specific to the terminal session. Each opened terminal has its own set of jobs and job ID numbers. Jobs from one terminal cannot be managed from a second terminal using job ID numbers. jobs's options function as follows: -c prints the command name for each process in jobs. -g only print the group id of each job. -l only the last job to be started is printed. -p print the process id for each process in all jobs. e.g. jobs -p %p display the process ID or jobs for the job whose name begins with "p".

10.2.5 Process Management Facts

When a process is running in the foreground, no other commands can be run from that terminal until the foreground process terminates. Therefore, it is important to know how to move processes to the background to allow addition commands to be run. This lesson covers the following topics: Moving processes between the foreground and the background Adjusting process priorities

What command would you enter at the command prompt to start the gedit program in the background?

gedit & gedit & starts the gedit program in the background. The ampersand (&) symbol starts a process in the background, leaving the shell available for other commands.

What is the result of the nohup gedit & command? gedit will start after logging out of the shell. gedit will start in the background and terminate after logging out of the shell. gedit will start in the foreground and terminate after logging out of the shell. gedit will start in the background and persist in the background after logging out of the shell.

gedit will start in the background and persist in the background after logging out of the shell. nohup gedit & starts the gedit process in the background and leaves it running after logging out of the shell. nohup: Allows a command or shell script to continue running in the background after logging out from a shell. Does not automatically put the command it runs in the background. Use the ampersand (&) symbol to start a process in the background.

A developer calls you with a problem. She was trying to debug a new daemon and mistakenly placed it on the production machine instead of on a lab machine. It has now entered runaway mode. The PID number is 2345. She attempted to stop the process with the standard kill command, but it had no effect. Which command would you use to assure that the process will terminate? kill -NOW 2345 kill 2345 -NOW kill 2345 -9 kill -9 2345

kill -9 2345 Use kill -9 2345 to terminate PID 2345 with the strongest signal possible (-9). The other choices presented do not have the syntax required to terminate the runaway process.

A service specialist from your company calls you from a customer's site. He is attempting to install an upgrade to the software, but it will not install; instead, it he receives messages stating that he cannot install the program until all non-core services are stopped. You cannot remotely access the machine, but the representative tells you that there are only four processes running, and their PID numbers are 1, 10, 100, and 1000. With no further information available, which command would you recommend the representative run? kill 1 kill 10 kill 100 kill 1000

kill 1000 As a system starts, it assigns PID numbers to the processes that are spawned and increments the numbers. The first processes to start have the lowest PID numbers. A PID of 1000 indicates that many other processes came before it, and it probably isn't a critical application. Lower PID numbers are likely to be critical processes.

Which of the following commands starts the gedit program with a priority one above the default nice priority? nice -n -1 gedit nice -n 1 gedit nice -n -19 gedit nice -n -20 gedit

nice -n -1 gedit nice -n -1 gedit starts the gedit process with a priority one above the default. Zero (0) is the default nice value for processes not executed with the nice command. The nice command starts a command with a higher or lower priority. Nice values range from 19 (lowest priority) to -20 (highest priority). The higher the number, the lower priority the job receives in the system. Use -n to specify the priority value. If no value is specified, the process starts with 10 as the default.

What would you enter at the command prompt to start the gedit process with the highest priority possible?

nice -n -20 gedit nice -n -20 gedit starts the gedit process with a highest priority possible. The nice command starts a command with a higher or lower priority. Nice values range from 19 (lowest priority) to -20 (highest priority). The higher the number, the lower priority the job receives. Use -n to specify the priority value. If no value is specified, the process starts with 10 as the default. Zero (0) is the default nice value for processes not executed with the nice command.

The /sbin/grpck process is not responding and needs to be killed. There are multiple instances that were spawned and need to be terminated. Which of the following commands will terminate all instances of the grpck process? pkill -SIGTERM -f grpck ps -A | grep grpck pkill -HUP 2583 ps aux | grep "grpck"

pkill -SIGTERM -f grpck pkill searches for processes that match the search criteria specified and then send them a kill signal. pkill -SIGTERM -f grpck will send the terminate signal to all processes named grpck. ps -A | grep grpck displays all processes that include the name grpck. pkill -HUP 2583 will force the reload of a configuration file for process ID 2583. ps aux | grep "grpck" will list process information for any process that includes the term grpck.

You have recently answered calls from a number of users who cannot access the mail server. Which utility would you use to quickly see if the sendmail service is running? ps ifconfig netstat uptime

ps Use the ps utility to show the running processes and see if the sendmail service is running. netstat will check to see if the sendmail service is listening for traffic. uptime displays how long the system has been running. ifconfig creates and views IP configuration for network interfaces.

You want to view all currently-running processes that include getty in the process name. Which command would you use? ps -a | grep getty ps -a | find getty ps -A | find getty ps -A | grep getty

ps -A | grep getty Use ps -A | grep getty. Use the -A option to search all processes. Use grep to search the output of a command. Use -a to search only processes in the current session that are not owned by the current user. Use find to search files.

Which command displays all the processes that are running in the most detail? ps -ef ps -A ps -a ps -e

ps -ef Use the -ef option with ps to show all the processes that are running in the most detail. The -a option removes obvious items (such as your shell) from the display. The -A and -e options work the same way to display all processes, but not in the most detail.

Which command displays the PPID? ps -u ps -f ps ps -A

ps -f the ps -f command shows all possible details for processes, including the PPID (parent process ID, the PID from which another process has been spawned). When used alone, ps returns process information associated with the current user and terminal. The -u option returns process information by user ID. The -A option shows all the processes.

A user is experiencing some slowness and wants to view an interactive listing of running processes to see if there is a process that is causing the problem. Which of the following commands displays an interactive listing of running processes? (See exhibit.) uptime top free pstree

top The top command displays an interactive listing of running processes. free displays the amount of free and used memory, but is not interactive. pstree displays processes in a tree format, but is not interactive. uptime displays information about how long the system has been active or running.

You need to see a listing of running processes and system status such as memory and CPU usage. Which command will produce the listing? cpustat -a top systat -al ps -A

top The top command produces a interactive listing of the top running processes plus the status of memory and CPU usage. The ps -A command produces a listing of all running processes, but no information about memory or CPU. There are no systat or cpustat commands.

Which command would you use to look for a potential resource hog on a workstation? uptime free renice top

top Use the top utility to see the current state of the system and sort the output by CPU utilization (or memory). This lets you find a resource hog. uptime displays how long the system has been running. free displays amount of free and used memory in the system. renice assigns a new priority to a process that has already started using the process's PID.

You need to determine the priority of several processes. Which command should you enter to identify the process ID and nice value for each process? renice jobs nice top

top top displays an interactive listing of processes with Process ID (PID), uptime, load, CPU status, memory, and nice value information. jobs displays the active jobs and their job ID numbers. nice starts a command with a higher or lower priority. renice assigns a new priority to a process that has already started.


Related study sets

Geometry 1.11: Use Algebra to Describe Geometry 2

View Set

Dynamic Routing Protocol Homework

View Set