Whenever you set up RHEL 9, the system comes with a minimal set of pre-installed packages and companies to maintain the system light-weight and safe.
Nonetheless, over time, as you put in new packages and companies, your system can turn into bloated and weak to safety threats.
On this article, we’ll talk about easy methods to disable and take away undesirable companies and packages on RHEL-based distributions akin to Rocky Linux, AlmaLinux, and Fedora, guaranteeing that your system stays safe and purposeful.
In case you are planning to make use of your newly put in RHEL system to host, let’s say, a small web site that runs on Apache or Nginx, or to supply community companies like DNS, DHCP, PXE boot, FTP server, and many others or different companies that don’t require to run Postifx MTA, CUPS and Avahi daemons, then why we must always hold all these pointless daemons put in and even operating in your server.
The principle exterior companies that your server actually requires to run after you carry out a minimal set up can be only a SSH daemon, in an effort to permit distant logins on the system, and, in some instances, NTP service, to precisely synchronize your server’s inner clock with exterior NTP servers.
Putting in Helpful System Utilities
After the set up finishes, login in your server with a root account or a person with root privileges and carry out a system replace, to be sure that your system is up-to-date with all packages and safety patches.
yum replace -y
yum improve y
The subsequent step can be to put in some helpful system utilities akin to net-tools (this bundle supplies the older however good ifconfig command), nano textual content editor, wget for file obtain and curl for URL transfers, lsof (to listing your open recordsdata), and bash-completion, which auto-completes typed instructions.
yum set up nano bash-completion net-tools wget curl lsof
Disable and Take away Undesirable Companies in Linux
Now you can begin disabling and eradicating pre-installed undesirable companies, however earlier than that, you’ll want to get a listing of all of your enabled and operating companies in your system.
Checking Enabled Companies
Earlier than disabling companies, it’s important to test which companies are at the moment enabled in your system.
systemctl list-unit-files –type=service –state=enabled
Pay attention to the companies that you just need to disable.
Figuring out Pointless Companies
Earlier than disabling and eradicating undesirable companies, you’ll want to establish which companies are mandatory and which of them could be safely disabled.
A technique to do that is to look at the listing of enabled companies and search for their descriptions to find out what they do.
For instance, the next command will present a listing of all enabled companies together with their descriptions:
systemctl list-unit-files –type=service –all –no-pager
You’ll be able to then look at every service’s description to find out whether or not it’s mandatory in your system.
One other strategy is to make use of a instrument like systemd-analyze to investigate your system’s boot time and establish companies which might be slowing down the boot course of.
systemd-analyze
systemd-analyze blame
The above command will show a listing of all operating systemd items (companies) sorted by the point they took to initialize.
Companies that aren’t vital to system operation and are slowing down the boot course of can typically be safely disabled.
Disable Pointless Companies
When you’ve recognized a service that’s not vital and is likely to be slowing down boot time, you’ll be able to disable and cease it utilizing the next instructions.
sudo systemctl disable <service_name>
sudo systemctl cease <service_name>
Whereas the companies that you’ll want to disable or take away will rely in your particular use case, there are a number of widespread companies that you could be need to contemplate disabling or eradicating on a minimal set up of RHEL.
Postfix
Postfix is a mail switch agent (MTA) that’s used to ship and obtain e mail in your system. In case you are not utilizing your system for e mail, you’ll be able to disable and take away this service.
sudo systemctl cease postfix
sudo systemctl disable postfix
sudo yum take away postfix
Avahi
Avahi is a service that’s used for zero-configuration networking, permitting units to find and talk with one another on the identical community.
If you don’t require this performance, you’ll be able to disable and take away avahi service.
sudo systemctl cease avahi-daemon.socket
sudo systemctl disable avahi-daemon.socket
sudo yum take away avahi-autoipd avahi-libs avahi-tools
Cups
The cups service is used for printing. In case your system doesn’t require printing capabilities, you’ll be able to disable and cease it:
sudo systemctl disable cups
sudo systemctl cease cups
suod yum take away cups
Eradicating Undesirable Companies
Along with eradicating undesirable companies, you might also need to take away any packages which might be now not wanted. Unused packages can take up disk area and doubtlessly create safety vulnerabilities.
First, listing the put in packages to establish which of them are related to undesirable companies:
rpm -qa
To seek out out which bundle supplies a specific service, use:
rpm -qf /usr/lib/systemd/system/<service_name>.service
To take away a bundle and its related recordsdata, use.
sudo yum take away <package_name>
Finest Practices for Disabling and Eradicating Companies
When disabling and eradicating companies, it’s important to comply with greatest practices to make sure that your system stays safe and purposeful.
Listed below are some tips to comply with:
Earlier than eradicating a service, disable it to forestall it from operating within the background, which could be completed utilizing the systemctl disable command.
Cease the service to forestall it from operating within the present session, which could be completed utilizing the systemctl cease command.
Take away any packages which might be now not wanted to unlock disk area and cut back safety vulnerabilities, which could be completed utilizing the yum take away command.
After disabling or eradicating companies, refresh the systemd daemon to make sure that the modifications take impact, which could be completed utilizing the systemctl daemon-reload command.
After eradicating companies, test for ghost companies that will nonetheless be operating, which could be completed utilizing the systemctl list-units command.
Conclusion
Disabling and eradicating undesirable companies and packages on RHEL is an important step in sustaining system safety and efficiency.
By following the steps outlined on this article, you’ll be able to be sure that your system stays safe and purposeful. Bear in mind to all the time comply with greatest practices when disabling and eradicating companies, and be cautious when eradicating packages to keep away from potential safety vulnerabilities.