Leason 5 - Managing Kali Linux Services
Last updated
Last updated
and listens by default on port 80. To start the HTTP service in Kali, we can use systemctl as we did when starting the SSH service, replacing the service name with “apache2”:
As with the SSH service, we can verify that the HTTP service is running and listening on TCP port 80
with the ss and grep commands.
systemctl
is a command-line utility in Unix-like operating systems, particularly in Linux distributions that use the systemd system and service manager. It is used to examine and control the systemd system and service manager. Here are some common uses and options for systemctl
:
Start a Service
Starts the specified service immediately.
Stop a Service
Stops the specified service immediately.
Restart a Service
Stops and then starts the specified service.
Reload a Service
Reloads the configuration of the specified service without restarting it.
Enable a Service
Configures the service to start automatically at boot.
Disable a Service
Prevents the service from starting automatically at boot.
Check the Status of a Service
Displays the current status of the specified service, including whether it is running, its PID, and recent log entries.
List All Services
View All Units (Services, Mounts, Sockets, etc.)
View All Active Units
View Unit Files
Lists unit files and their enabled/disabled state.
Mask a Service
Links the specified service to /dev/null
, preventing it from being started manually or automatically.
Unmask a Service
Removes the link created by mask
, allowing the service to be started.
Show Service Logs
Displays the logs for the specified service.
Start the Apache HTTP Server
Enable MySQL to Start at Boot
Check the Status of the SSH Service
List All Running Services
Restart the Networking Service
Using systemctl
, you can manage and monitor services, sockets, devices, and other systemd units efficiently, giving you powerful control over the system's initialization and service management.
SSH Service
The Secure SHell (SSH)43 service is most commonly used to remotely access a computer, using a secure, encrypted protocol. The SSH service is TCP-based and listens by default on port 22. To start the SSH service in Kali, we run systemctl with the start option followed by the service name (ssh in this example)
When the command completes successfully, it does not return any output but we can verify that the SSH service is running and listening on TCP port 22 by using the ss command and piping the output into grep to search the output for “sshd”
he command sudo ss -anple
is used in Unix-like operating systems to display detailed information about socket connections. Here's a breakdown of what each part of the command does:
sudo
: This command runs the following command with superuser (root) privileges. It's required because accessing detailed information about network connections often requires elevated permissions.
ss
: The ss
command is used to dump socket statistics. It is a modern replacement for the older netstat
command.
a
: This option tells ss
to show all sockets, including listening (waiting for incoming connections) and non-listening (connected) sockets.
n
: This option ensures that the addresses are not resolved into hostnames. It shows numerical addresses instead, which can be quicker and avoids potential issues with DNS resolution.
p
: This option includes the process information for each socket, showing which process is using each socket.
l
: This option restricts the output to listening sockets only.
e
: This option displays extended socket information, which may include additional details like memory usage or TCP socket flags.
If we want to have the SSH service start automatically at boot time (as many users prefer), we simply enable it using the systemctl command. However, be sure to change the default password first!
SSH Service
The Secure SHell (SSH)43 service is most commonly used to remotely access a computer, using a secure, encrypted protocol. The SSH service is TCP-based and listens by default on port 22. To start the SSH service in Kali, we run systemctl with the start option followed by the service name (ssh in this example)
When the command completes successfully, it does not return any output but we can verify that the SSH service is running and listening on TCP port 22 by using the ss command and piping the output into grep to search the output for “sshd”
he command sudo ss -anple
is used in Unix-like operating systems to display detailed information about socket connections. Here's a breakdown of what each part of the command does:
sudo
: This command runs the following command with superuser (root) privileges. It's required because accessing detailed information about network connections often requires elevated permissions.
ss
: The ss
command is used to dump socket statistics. It is a modern replacement for the older netstat
command.
a
: This option tells ss
to show all sockets, including listening (waiting for incoming connections) and non-listening (connected) sockets.
n
: This option ensures that the addresses are not resolved into hostnames. It shows numerical addresses instead, which can be quicker and avoids potential issues with DNS resolution.
p
: This option includes the process information for each socket, showing which process is using each socket.
l
: This option restricts the output to listening sockets only.
e
: This option displays extended socket information, which may include additional details like memory usage or TCP socket flags.
If we want to have the SSH service start automatically at boot time (as many users prefer), we simply enable it using the systemctl command. However, be sure to change the default password first!