{"id":13392,"date":"2019-04-01T23:39:28","date_gmt":"2019-04-01T23:39:28","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=13392"},"modified":"2019-04-01T23:39:28","modified_gmt":"2019-04-01T23:39:28","slug":"how-to-stop-and-disable-unwanted-services-from-linux-system","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/01\/how-to-stop-and-disable-unwanted-services-from-linux-system\/","title":{"rendered":"How to Stop and Disable Unwanted Services from Linux System"},"content":{"rendered":"<p>We build a server according to our plan and requirements, but what are the intended functions while building a server to make it function quickly and efficiently. We all know that while installing a Linux OS, some unwanted Packages and Application gets installed automatically without the knowledge of a User.<\/p>\n<div id=\"attachment_5766\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2014\/03\/remove-unwanted-services-from-linux.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5766\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2014\/03\/remove-unwanted-services-from-linux.png\" alt=\"Remove Unwanted Services From Linux\" width=\"442\" height=\"317\" aria-describedby=\"caption-attachment-5766\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-5766\" class=\"wp-caption-text\">Remove Unwanted Services From Linux<\/p>\n<\/div>\n<p>When building a server we need to ask ourselves what we actually need from the box. Do I need a\u00a0<strong>Web Server<\/strong>\u00a0or a\u00a0<strong>FTP Server<\/strong>, a\u00a0<strong>NFS Server<\/strong>\u00a0or a\u00a0<strong>DNS Server<\/strong>, a\u00a0<strong>Database Server<\/strong>\u00a0or something else.<\/p>\n<p>Here in this article, we will be discussing some of these unwanted applications and services which you might not needed but they are installed by default during OS installation and unknowingly start eating your system resources.<\/p>\n<p>Lets first know what kind of services are running on the system using the following commands.<\/p>\n<pre>[avishek@tecmint]# ps ax<\/pre>\n<h5>Sample Output<\/h5>\n<pre>  PID TTY      STAT   TIME COMMAND\r\n    2 ?        S      0:00 [kthreadd]\r\n    3 ?        S      0:00  \\_ [migration\/0]\r\n    4 ?        S      0:09  \\_ [ksoftirqd\/0]\r\n    5 ?        S      0:00  \\_ [migration\/0]\r\n    6 ?        S      0:24  \\_ [watchdog\/0]\r\n    7 ?        S      2:20  \\_ [events\/0]\r\n    8 ?        S      0:00  \\_ [cgroup]\r\n    9 ?        S      0:00  \\_ [khelper]\r\n   10 ?        S      0:00  \\_ [netns]\r\n   11 ?        S      0:00  \\_ [async\/mgr]\r\n   12 ?        S      0:00  \\_ [pm]\r\n   13 ?        S      0:16  \\_ [sync_supers]\r\n   14 ?        S      0:15  \\_ [bdi-default]\r\n   15 ?        S      0:00  \\_ [kintegrityd\/0]\r\n   16 ?        S      0:49  \\_ [kblockd\/0]\r\n   17 ?        S      0:00  \\_ [kacpid]\r\n   18 ?        S      0:00  \\_ [kacpi_notify]\r\n   19 ?        S      0:00  \\_ [kacpi_hotplug]\r\n   20 ?        S      0:00  \\_ [ata_aux]\r\n   21 ?        S     58:46  \\_ [ata_sff\/0]\r\n   22 ?        S      0:00  \\_ [ksuspend_usbd]\r\n   23 ?        S      0:00  \\_ [khubd]\r\n   24 ?        S      0:00  \\_ [kseriod]\r\n   .....<\/pre>\n<p>Now, let\u2019s have a quick look at the processes accepting connection (ports) using the\u00a0<a href=\"https:\/\/www.tecmint.com\/20-netstat-commands-for-linux-network-management\/\" target=\"_blank\" rel=\"noopener\">netstat command<\/a>\u00a0as shown below.<\/p>\n<pre>[avishek@tecmint]# netstat -lp<\/pre>\n<h5>Sample Output<\/h5>\n<pre>Active Internet connections (only servers)\r\nProto Recv-Q Send-Q Local Address               Foreign Address             State       PID\/Program name   \r\ntcp        0      0 *:31138                     *:*                         LISTEN      1485\/rpc.statd      \r\ntcp        0      0 *:mysql                     *:*                         LISTEN      1882\/mysqld         \r\ntcp        0      0 *:sunrpc                    *:*                         LISTEN      1276\/rpcbind        \r\ntcp        0      0 *:ndmp                      *:*                         LISTEN      2375\/perl           \r\ntcp        0      0 *:webcache                  *:*                         LISTEN      2312\/monitorix-http \r\ntcp        0      0 *:ftp                       *:*                         LISTEN      2174\/vsftpd         \r\ntcp        0      0 *:ssh                       *:*                         LISTEN      1623\/sshd           \r\ntcp        0      0 localhost:ipp               *:*                         LISTEN      1511\/cupsd          \r\ntcp        0      0 localhost:smtp              *:*                         LISTEN      2189\/sendmail       \r\ntcp        0      0 *:cbt                       *:*                         LISTEN      2243\/java           \r\ntcp        0      0 *:websm                     *:*                         LISTEN      2243\/java           \r\ntcp        0      0 *:nrpe                      *:*                         LISTEN      1631\/xinetd         \r\ntcp        0      0 *:xmltec-xmlmail            *:*                         LISTEN      2243\/java           \r\ntcp        0      0 *:xmpp-client               *:*                         LISTEN      2243\/java           \r\ntcp        0      0 *:hpvirtgrp                 *:*                         LISTEN      2243\/java           \r\ntcp        0      0 *:5229                      *:*                         LISTEN      2243\/java           \r\ntcp        0      0 *:sunrpc                    *:*                         LISTEN      1276\/rpcbind        \r\ntcp        0      0 *:http                      *:*                         LISTEN      6439\/httpd          \r\ntcp        0      0 *:oracleas-https            *:*                         LISTEN      2243\/java         \r\n....<\/pre>\n<p>In the above output, you notice that some of the applications you may not needed on your server but they are still running as follows:<\/p>\n<h4>1. smbd and nmbd<\/h4>\n<p>smbd and nmbd are daemon of Samba Process. Do you really need to export smb share on windows or other machine. If not! why are these processes running? You can safely kill these processes and disable them from starting automatically when machine boots the next time.<\/p>\n<h4>2. Telnet<\/h4>\n<p>Do You need bidirectional interactive text-oriented communication over internet or local area network? If not! kill this process and turn-off it from starting at booting.<\/p>\n<h4>3. rlogin<\/h4>\n<p>Do you need to log in to another host over network. If not! Kill this process and disable it from starting automatically at boot.<\/p>\n<h4>4. rexec<\/h4>\n<p>The Remote Process Execution aka rexec lets you execute shell commands on a remote computer. If you don\u2019t require to execute shell command on a remote machine, simply kill the process.<\/p>\n<h4>5. FTP<\/h4>\n<p>Do you need to transfer files from one host to another host over Internet? If not you can safely stop the service.<\/p>\n<h4>6. automount<\/h4>\n<p>Do you need to mount different file systems automatically to bring up network file system? If not! Why is this process running? Why are you letting this application to use you resource? Kill the process and disable it from starting automatically.<\/p>\n<h4>7. named<\/h4>\n<p>Do you need to run NameServer (DNS)? If not what on earth is compelling you to run this process and allow eating up your resources. Kill the running process first and then turn-off it from running it at boot.<\/p>\n<h4>8. lpd<\/h4>\n<p>lpd is the printer daemon which makes it possible to print to that server. If you don\u2019t need to print from the server chances are your system resources are being eaten up.<\/p>\n<h4>9. Inetd<\/h4>\n<p>Are you running any inetd services? If you are running stand alone application like ssh which uses other stand alone application like Mysql, Apache, etc. then you don\u2019t need inetd. better kill the process and disable it starting next time automatically.<\/p>\n<h4>10. portmap<\/h4>\n<p>Portmap which is an Open Network Computing Remote Procedure Call (ONC RPC) and usages daemon rpc.portmap and rpcbind. If these Processes are running, means you are running NFS server. If NFS server is running unnoticed means your system resources are being used up un-necessarily.<\/p>\n<h3>How to Kill a Process in Linux<\/h3>\n<p>In order to kill a running process in Linux, use the \u2018<strong>Kill PID<\/strong>\u2018 command. But, before running Kill command, we must know the\u00a0<strong>PID<\/strong>\u00a0of the process. For example, here I want to find a PID of \u2018<strong>cupsd<\/strong>\u2018 process.<\/p>\n<pre>[avishek@tecmint]# ps ax | grep cupsd\r\n\r\n1511 ?        Ss     0:00 cupsd -C \/etc\/cups\/cupsd.conf<\/pre>\n<p>So, the PID of \u2018<strong>cupsd<\/strong>\u2018 process is \u2018<strong>1511<\/strong>\u2018. To kill that PID, run the following command.<\/p>\n<pre>[avishek@tecmint]# kill -9 1511<\/pre>\n<p>To find out more about kill command with their examples, read the article\u00a0<a href=\"https:\/\/www.tecmint.com\/how-to-kill-a-process-in-linux\/\" target=\"_blank\" rel=\"noopener\">A Guide to Kill Command to Terminate a Process in Linux<\/a><\/p>\n<h3>How to Disable a Services in Linux<\/h3>\n<p>In\u00a0<strong>Red Hat<\/strong>\u00a0based distributions such as\u00a0<strong>Fedora<\/strong>\u00a0and\u00a0<strong>CentOS,<\/strong>\u00a0make use of a script called \u2018<a href=\"https:\/\/www.tecmint.com\/chkconfig-command-examples\/\" target=\"_blank\" rel=\"noopener\">chkconfig<\/a>\u2018 to enable and disable the running services in Linux.<\/p>\n<p>For example, lets disable the Apache web server at the system startup.<\/p>\n<pre>[avishek@tecmint]# chkconfig httpd off\r\n[avishek@tecmint]# chkconfig httpd --del<\/pre>\n<p>In\u00a0<strong>Debian<\/strong>\u00a0based distributions such as\u00a0<strong>Ubuntu<\/strong>,\u00a0<strong>Linux Mint<\/strong>\u00a0and other Debian based distributions use a script called\u00a0<strong>update-rc.d<\/strong>.<\/p>\n<p>For example, to disable the Apache service at the system startup execute the following command. Here \u2018<strong>-f\u2019<\/strong>option stands for force is mandatory.<\/p>\n<pre>[avishek@tecmint]# update-rc.d -f apache2 remove<\/pre>\n<p>After making these changes, The system next time will boot without these UN-necessary process which in-fact will be saving our system resource and the server would be more practical, fast, safe and secure.<\/p>\n<p>That\u2019s all for now. I\u2019ll here we again with another interesting article.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/remove-unwanted-services-from-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We build a server according to our plan and requirements, but what are the intended functions while building a server to make it function quickly and efficiently. We all know that while installing a Linux OS, some unwanted Packages and Application gets installed automatically without the knowledge of a User. Remove Unwanted Services From Linux &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/01\/how-to-stop-and-disable-unwanted-services-from-linux-system\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Stop and Disable Unwanted Services from Linux System&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13392","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13392","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=13392"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13392\/revisions"}],"predecessor-version":[{"id":13393,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13392\/revisions\/13393"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=13392"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=13392"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=13392"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}