0%

0/1 Lessons

Introduction to Linux Server Operating Systems

• 30min

0 / 3 lessons complete

Linux Server Installation and Lab Setup

• 23min

0 / 6 lessons complete

Working with the Linux Command Line Interface

• 1hr 30min

0 / 12 lessons complete

User and Group Management

• 44min

0 / 7 lessons complete

Linux Storage

• 30min

0 / 6 lessons complete

Linux Administration Basics

• 53min

0 / 8 lessons complete

Linux Networking

• 47min

0 / 8 lessons complete

Course Conclusion

• 5min

0 / 1 lessons complete

Process Management

Instructions

Q&A (0)

Notes (0)

Resources (0)

Saving Progress...

Resources

There are no resources for this lesson.

Notes can be saved and accessed anywhere in the course. They also double as bookmarks so you can quickly review important lesson material.

Create note

In this lesson, you will learn how to manage processes on a Linux server. You will learn tools like ps, top, and kill. We will use the nginx package as our example. To get started, go ahead and install the nginx package with the command below:

sudo apt install nginx

Understanding NGINX as a Process

When NGINX is running on your Ubuntu Server, it operates as a process. This process can be viewed, managed, and terminated if necessary, using Linux commands. Knowing how to view and kill processes is an extremely important skill that I want to make sure you understand - so we will cover that in this lesson.

The top utility

The top command in Linux is an incredibly useful tool for monitoring system performance and managing processes. It provides a real-time, dynamic view of your system's resource usage, including CPU, memory, and process information. In this lesson, we'll focus on some essential skills you should have when using top, with a special emphasis on searching for process names.

Opening top

To start top, simply type the following command in your terminal:

top

Navigating the top Interface

Once top is running, you'll see a display showing a list of the system's currently running processes, along with information about system resources. The top portion shows overall system statistics, while the bottom portion lists individual processes.

Sorting Processes

By default, top sorts processes based on CPU usage, but you can sort by other criteria (you must use shift to capitalize each of the letters below):

  • Press M to sort by memory usage.
  • Press P to sort back by CPU usage.
  • Press T to sort by the time the processes have been running.

Searching for Process Names

One key skill in top is searching for specific processes by name. This is particularly useful when you're monitoring a specific application or service. To search for a process:

  1. Press L (capital L). This opens a search prompt at the bottom of the top interface.
  2. Type the name of the process you're looking for, like nginx.
  3. Press Enter. top will then highlight the first process that matches your search query.

If there are multiple instances of the process, you can press L and enter the name again to cycle through them.

Killing Processes from top

If you find a process that needs to be terminated, you can do so directly from top:

  1. Press k. This opens a prompt asking for the PID of the process you want to kill.
  2. Enter the PID of the process. You can find this in the list of processes.
  3. Press Enter. top will then ask for a signal to send. If you press Enter again without typing a signal number, it sends SIGTERM (signal 15), which asks the process to terminate gracefully.
  4. To forcefully kill a process (like using kill -9), type 9 and then press Enter.

Forcefully kill all the nginx processes, then exit top using the instructions below.

Exiting top

To exit top, simply press q. This will return you to the command line. Check the status of nginx to make sure it was stopped:

paulh@ubuntu-server:~$ systemctl status nginx
× nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; disabled; vendor preset: enabled)
     Active: failed (Result: signal) since Tue 2023-12-05 20:37:57 UTC; 9s ago
       Docs: man:nginx(8)
    Process: 74006 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0>
    Process: 74007 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 74008 (code=killed, signal=KILL)
        CPU: 20ms

Then you can start nginx back up with the command below:

Server Academy Members Only

Sorry, this lesson is only available to Server Academy Full Access members. Become a Full-Access Member now and you’ll get instant access to all of our courses.

0 0 votes
Lesson Rating
Subscribe
Notify of
profile avatar
0 Comments
Inline Feedbacks
View all comments