When installing a Linux operating system, some unnecessary packets and applications are automatically installed without the user noticing. In this article, we'll discuss how to disable some of the unnecessary applications and services in your Linux system to protect your system resources.
First let's look at what services are running on the system. Use the following command:
Output results
Now let's use the following netstat command to quickly browse through processes (ports) that accept connections.
Output results
From the output above, you will find applications that do not need to run on the server, such as:
1. SMBD and NMBD
SMBD and NMBD are background processes for samba. Do you really need to output SMB sharing on Windows or other machines? If not, why are these processes running?
You can turn off the Power-on startup settings the next time the machine is started, so you can safely close or disable these processes.
2. Telnet
Do you need to use the Internet or a local area network for communication in text form? If not, shut down the process when the machine starts.
3. Rlogin
Do you need to log on to another host over the network? If you do not need to, then turn off the startup function of the process when the machine is started.
4. rexec
Remote Process Execution rexec allows you to execute shell commands on a remote computer. If you do not need to execute the shell command on the remote machine, close the process.
5. FTP
Do you need to transfer files from one host to another on the network? You can stop the FTP service if you don't need it.
6. AutoMount
Do you need to automatically mount a different file system and eject the network file system? If not, why do you want to run this process, and why do you want this application to occupy your resources? Turn off its auto start feature.
7. Named
Do you need to run the Domain name server (DNS)? If not, you should turn off the process and release your resources. Close the running process first, and then turn off the boot up setting.
8. LPD
LPD is the background process for the printer. If you don't need to print from the server, the process consumes your system resources.
9. Inetd
Do you run inetd service? If you are running stand-alone applications, such as SSH,SSH will use other standalone applications, such as MySQL, Apache, and so on. If you do not need inetd, it will be closed at the next automatic start.
Portmap
Portmap is an open Network computing remote Procedure call (ONC RPC) that enables background processes Rpc.portmap and rpcbind. If these are running, it means that you are running Server for NFS. If you don't notice that the NFS server is running, it means your system resources are being consumed.
How to kill a process in a Linux system
You can use the Kill PID command to kill a process running in Linux. But before we run the KILL command, we have to understand the PID of the process. For example, I want to find the PID for the "CUPSD" process.
Then the "CUPSD" process pid is 1511. Run the following command to kill the PID.
How to disable Linux services
For Red Hat distributions such as Fedora and CentOS, use the "chkconfig" script to enable and disable services running on a Linux system.
For example, disable the Apache Web server when the system starts.
For debain distributions such as Ubuntu, Linux Mint, and other Debian distributions, use a script called UPDATE-RC.D.
For example, use the following command to disable the Apache service when the system is enabled. Here the "-f" option represents mandatory.
After making these changes, the system will not run any of these unnecessary processes the next time it starts, saving us resources for the system. The server will be more practical, fast, and secure.