What is Package?
A package is usually referred to an application but it could be a GUI application, command line tool or a software library (required by other software programs). A package is essentially an archive file containing the binary executable, configuration file and sometimes information about the dependencies.
What is Package Manager?
A package manager in Linux is a software tool that automates the process of installing, updating, configuring, and removing software packages on a Linux system. It simplifies the management of software by handling dependencies, version tracking, and installation tasks. Package managers are integral to the package-based distribution model of many Linux distributions.
There are several package managers in use across various Linux distributions, and each distribution typically has its own package management system. Here are a few examples:
APT (Advanced Package Tool):
Used by Debian-based distributions, including Debian, Ubuntu, and derivatives.
Commands:
apt-get
,apt
,aptitude
.
YUM (Yellowdog Updater Modified):
Used by Red Hat-based distributions, including CentOS, Fedora, and RHEL.
Commands:
yum
,dnf
(in newer distributions).
zypper:
Used by openSUSE and SUSE Linux Enterprise.
Command:
zypper
.
Pacman:
Used by Arch Linux and Arch-based distributions.
Command:
pacman
.
Portage:
Used by Gentoo Linux.
Command:
emerge
.
Dpkg:
The low-level package management tool used by Debian-based distributions.
Commands:
dpkg
,apt-get
utilizesdpkg
as a backend.
RPM (RPM Package Manager):
The low-level package management tool used by Red Hat-based distributions.
Commands:
rpm
,yum
utilizesrpm
as a backend.
What is Systemd?
systemd
is a system and service manager for Linux operating systems. It is designed to be a replacement for the traditional Unix init system and other init-related tools. systemd
is now the default initialization system for a significant number of Linux distributions, including popular ones such as Ubuntu, Fedora, CentOS, and others.
What is the Linux Systemctl Command?
Now, imagine you have a remote control for your Linux system – that’s what systemctl
is. It’s like your boss for telling the system what to do. With this tool, you can start, stop, or restart services (think of them like programs running in the background). Want something to start automatically when your computer turns on? systemctl
helps with that too. It’s also good for checking how things are going – like looking at logs or figuring out what other things a service needs to work properly. So, if you’re in charge of a Linux system, systemctl
is your go-to tool for keeping things organized and running well.
Syntax of systemctl
command :-
systemctl [command] [service]
[command] \= The action we want to perform (start, stop, enable, disable, etc.)
[service] = The name of the service we want to perform the action on.
Options available in systemctl
command
Options | Description | Syntax |
–version | This option displays the version number of the systemctl command. | systemctl --version |
–help | This option displays the help manual for systemctl, including a list of available options and commands | systemctl --help |
–type | The argument in this case should be comma-separated list of unit types such as service and socket. | systemctl --type=service |
–all | This option lists all available units, including those that are inactive. | systemctl --all |
–failed | This option lists all units that have failed. | systemctl --failed |
–user | talk to service manager of calling user, instead of system. | systemctl --user |
–force | This option forces the service to start or stop, even if it has dependencies that are not yet started or stopped. | systemctl stop --force httpd.service |
–no-block | This option starts or stops the service without blocking the shell, allowing the user to continue to use the shell while the service is starting or stopping. | systemctl start --no-block httpd.service |
–state | This option is used to filter the output based on the specified unit state. You can specify one or more-unit states separated by commas, such as active, inactive, failed, and activating. | systemctl list-units --state=failed |
-r, –recursive | This option is used to show units of local containers as well. | systemctl list-units --recursive |
–show-types | This option is used to show the types of sockets along with showing sockets. | systemctl list-sockets --show-types |
–job-mode= | This option controls how to deal with already queued jobs in case of queuing a new job. There are three available modes: | systemctl isolate graphical.target --job-mode=replace |
-i, –ignore-inhibitors | This option is used to ignore inhibitor locks when requesting a system shutdown or sleep state. | systemctl poweroff --ignore-inhibitors |
-q, –quiet | This option is used to suppress the printing of results of various commands and the hints about the truncated lines. | systemctl daemon-reload --quiet |
–no-wall | This option is used to not send a wall message before power-off, halt, or reboot. | systemctl halt --no-wall |
Task:-
Check the status of docker service in your system
Read about the commands systemctl vs service
systemctl:
Description:
systemctl
is a more modern and feature-rich command that is part of thesystemd
system and service manager.
Functionality:
It is a central tool for controlling the
systemd
system and its services.Manages system services, targets, sockets, devices, and more.
Provides extensive features for service control, status monitoring, and configuration.
Usage Examples:
# View the status of a service systemctl status service_name # Start, stop, or restart a service systemctl start service_name systemctl stop service_name systemctl restart service_name # Enable or disable a service at boot systemctl enable service_name systemctl disable service_name
Additional Features:
Dependency tracking for services.
Detailed service status information.
Integration with the
systemd
logging system.
service:
Description:
service
is a simpler and older command that is often associated with traditional SysV init systems.
Functionality:
It is a wrapper script designed for backward compatibility with SysV init scripts.
Primarily used for starting, stopping, and restarting services.
Usage Examples:
# Start, stop, or restart a service service service_name start service service_name stop service service_name restart # Check the status of a service service service_name status
Limitations:
Limited capabilities compared to
systemctl
.Provides basic service management without advanced features.