Home > Articles

This chapter is from the book

Managing Linux Applications and Services

Test Objective Covered:

  1. Manage Linux applications.

As we discussed in Chapter 2, "Introduction to SUSE Linux," one of the key functions of an operating system is to provide a platform where applications and services can run. To effectively manage a Linux system, you need to know how to install and uninstall packages, start and stop services, and manage running processes.

Installing Linux Packages

You're probably already familiar with installing an application on a Windows system. Typically, you insert an installation CD in the system's CD drive. An AUTORUN.INF file automatically starts the installation program, usually named SETUP.EXE.

Installing an application on a Linux system is a little bit different. There are three different ways applications are typically distributed and installed on SUSE Linux:

  • By extracting files from a tarball archive and running an installation script

  • By using the rpm command

  • By using the YaST Control Center

Many applications are installed using tarball distribution files. As we discussed in the previous chapter, Linux uses the tar and gzip utilities to combine multiple files into a single tape archive file (the tar file) and then compress them into a gzip file (the tarball file). Six sample tarball files are shown in Figure 3.25.

Figure 3.25Figure 3.25 Typical tarball files.

Using the tar –zxvf command, you can extract these archives into their component files. At this point, the distribution should contain an install script that you can run to install the application.

In Figure 3.26, the vmware-linux-tools.tar.gz tarball from Figure 3.25 has been extracted to the vmware-tools-distrib directory. Within this directory is a file named vmware-install.pl. Running this file will install the vmware-tools application.

Figure 3.26Figure 3.26 A tarball install script.

Linux applications are also frequently distributed as Red Hat Package Manager (RPM) files. These files require that you use the rpm utility, included in many Linux distributions.

NOTE

Not all Linux distributions include the rpm utility. Distributions based on Debian Linux use the Debian Package Manager instead. Red Hat and SUSE use rpm.

The advantage of using RPM packages instead of tarballs is the fact that many applications are dependent on other applications or services being installed on the system. The rpm utility can query the RPM package to be installed to identify its dependencies. It can then check the host system and make sure these dependencies have been installed prior to installing the new package.

If they aren't installed, rpm will warn you of the missing dependencies, giving you the opportunity to install them before proceeding. This can save you a great deal of trouble. Many years ago when I was first learning Linux, I installed an application from a tarball file. The readme file that accompanied the application didn't list any dependencies. However, when I tried to run it for the first time, it reported a missing application it was dependent on and halted execution.

I downloaded and installed the missing application and tried to run the application a second time. It again reported another missing dependency and exited. I installed this application. Guess what happened when I tried to run the application for the third time? It did it again. There was yet another dependency missing. After a great deal of work, I finally got the application running.

You won't experience this type of problem with RPM packages. All missing dependencies will be reported right up front so you can take care of them all at once.

To install an RPM package, do the following:

  1. Open a terminal session and change to the root user account using the su – command.

  2. Navigate to the directory where the RPM package is stored.

  3. At the session prompt, enter

In this mode, the application will be installed with no progress indicator on the screen. If you would like to see a progress indicator as the package is installed, use rpm with the –ihv switch.

Another advantage of RPM packages is the fact that they are quite easy to uninstall. To do this, enter rpm –e package_name. Notice that installing requires that you use the package filename, whereas uninstalling requires that you use the package name. For example, if I were installing an NTP package on my system, I would use the package file name, ntp-4.1.1-1.i386.rpm, with the rpm utility.

However, if I were to uninstall this package at a later date, I would use the package name, ntp, with the rpm utility.

You can also use the YaST Control Center to install RPM packages. The left column holds the Software option, as shown in Figure 3.27.

To install a package in YaST, complete the following steps:

  1. Double-click Install or remove software. The screen shown in Figure 3.28 appears.

  2. Select the package you want to install.

  3. Click Accept.

If you want to install a package other than the one that came with your SUSE distribution, you will need to use the Change source of installation option under Software in the YaST Control Center (shown in Figure 3.27) to point to the directory where the RPM package is stored.

Figure 3.27Figure 3.27 The Software option in the YaST Control Center.

Figure 3.28Figure 3.28 Selecting a package to install.

Managing Linux Services

A key skill you will need when managing a Linux system (and when taking your CLE exam) is starting and stopping Linux services. Before covering this topic, we need to discuss the difference between a service and an application. The distinction is rather thin between these two concepts. Generally speaking, an application is a program that the end user interacts with in some way. The Mozilla web browser, for example, is an application. The YaST Control Center is also an application.

A Linux service, on the other hand, is a program that runs continuously in the background. Users generally don't see an interface, nor do they generally interact with the program. For example, the Apache web server is a Linux service. The Network Time Protocol (NTP) is also a service. Linux services are usually referred to as daemons.

Services are usually installed in the same way as regular applications. They may be distributed as tarballs or as rpm files.

With that said, you need to know how to start and stop services on your Linux system.

In the /etc/init.d directory on your SUSE server, you will find scripts that are used to start and stop services, as shown in Figure 3.29.

Figure 3.29Figure 3.29 Script files in the init.d directory.

TIP

On a Red Hat Linux system, these scripts are found in /etc/rc.d/init.d.

To start a service on your SUSE Linux system, open a terminal session, change to the root user account, and change to the /etc/init.d directory. Then enter ./service_name start at the shell prompt.

For example, if you wanted to start the Tomcat applet server on your system, you would enter ./tomcat start.

You can stop a service by entering ./service_name stop. For example, to stop the tomcat server, you would enter ./tomcat stop.

If you need to bring the service down and restart it, you can enter ./service_name restart.

NOTE

Not all Linux distributions and not all services support the restart option.

You can also perform these same tasks without first changing to the /etc/init.d directory. On a SUSE Linux system, you can prepend rc before the service name. For example, if your current directory is /var and you need to stop the Tomcat service, you can enter rctomcat stop. The start and restart options work with this shortcut as well.

TIP

On a Red Hat Linux system, you can do the same thing by entering service service_name start|stop|restart. For example, to stop the Tomcat service on a Red Hat system without changing to /etc/rc.d/init.d, you would enter service tomcat stop.

As you administer your Linux system, you will discover that there are some services you want started every time the system boots. Others you will want to only start when you need them. Configuring the default state for services is done with the chkconfig command. This command specifies at which runlevels a given Linux service will be automatically started.

A runlevel is a Linux mode of operation. There are six Linux runlevels:

  • 0—System shutdown.

  • 1—System started with only a single user allowed and networking enabled.

  • 2—System started with multiple users enabled and most services disabled.

  • 3—System started, multiple users enabled, and most services enabled except for the X Window System. If you boot your system to a nongraphical shell prompt, you are in runlevel 3.

  • 4—Unassigned. This runlevel can be custom-configured by the system administrator.

  • 5—System started, multiple users enabled, and most services enabled, including the X Window System. If your system boots to a graphical login, you are in runlevel 5.

  • 6—System restart.

Using chkconfig utility, you configure the default state for a service at a specific runlevel. The syntax for this utility is chkconfig service_name levels.

For example, to configure the Tomcat service to automatically start on runlevels 3 and 5, you would open a terminal session, change the root user, and enter chkconfig tomcat 35.

TIP

On a Red Hat system, the syntax for chkconfig is slightly different. To configure Tomcat to automatically start at runlevels 3 and 5 on this system, you would enter chkconfig –35 tomcat on.

You can also configure the default system runlevel and services that are automatically started by editing the /etc/inittab file.

Managing Linux Processes

When a Linux service or application is currently running, it is said to be a process. Each Linux process is assigned a unique process ID (PID). Most Linux distributions include a utility to let you view processes that are currently running. On a SUSE system, you can use the top utility. Simply open a terminal session and enter top at the shell prompt.

When you do, the screen shown in Figure 3.30 is displayed.

Figure 3.30Figure 3.30 Running processes displayed in the top utility.

Notice in the top display that the running service or application is displayed in the COMMAND column. In the PID column, you can view the PID assigned to the process. You can also view assorted information about the process, such as how long it has been running, how much memory is it consuming, and how much CPU time is it consuming.

You can use the commands in Table 3.3 to format the way the information in top is displayed and to manage the running processes.

Managing Processes in the top Utility

Command

Result

c

Displays the full path in the COMMAND column.

P

Sorts the display by CPU usage.

M

Sorts the display by memory usage.

N

Sorts the display by PID.

T

Sorts by time running.

A

Sorts by age.

k

Kills a running task. (This is very useful if you encounter a process that is hung.)

q

Exits the top utility.


You can also kill a running process from the command line using the kill command. To use this utility, you need to know the PID of the process you want to kill. You also need to know the signal you want to send. To see a list of valid signals, enter kill –l. There are 63 different possible signals, but two of the most useful are #15 (TERM) and #9 (KILL). If you don't supply a signal number, TERM is used by default.

The syntax for the kill command is kill –s signal pid. If you're trying to stop a hung process, you should try using kill with the TERM signal first. If that doesn't work, you should next try the KILL signal.

For example, let's suppose I'm running xclock on my GNOME desktop and for some reason it has hung. The PID for xclock is 9541. To kill it using the TERM signal, I could enter kill 9541 or kill –s 15 9541.

You can also use the killall command to stop a hung process. This utility is a little more brutal than the kill command. It sends a signal to any process that is using the specified name.

As with the kill command, you can send a specific signal or just use the default of TERM. Instead of a PID, you need to supply killall with the name of the process you want to kill. To send a simple killall with the TERM signal, you would enter killall service_name at the shell prompt. For example, if the Tomcat service were to hang, you could enter killall tomcat at the shell prompt.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020