In Centos 7 and earlier, SysV manage Linux services. To list such services,
config --list
Centos 7 and 8 uses Systemd to manage Linux services. The syntax for this command is
systemctl [OPTIONS...] COMMAND [UNIT...]
Centos 7 was a transition phase towards the newer Systemd, and it maintained a mix of service types.
Here are a list of common command to check Linux services.
List active systemd services
systemctl
List all systemd services
systemctl -a
List only SysV services (centos 7 and older)
systemctl list-unit-files
List by service types
systemctl list-units --type service
systemctl list-units --type mount
Where
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
Check status of a service
systemctl status sshd.service
sudo systemctl status nfs-server.service
To stop or start or restart a service
sudo systemctl stop nfs-server.service
sudo systemctl start nfs-server.service
sudo systemctl restart nfs-server.service
To determine service is active or enabled the following will return 0 (active) and non zero (disabled)
systemctl is-active sshd
systemctl is-enabled sshd
systemctl is-active nfs-server
systemctl is-enabled nfs-server
To list a service and its dependencies;
systemctl list-dependencies nfs-server
List services and their number of running task, CPU percentage, memory usage and I/O continuously
systemd-cgtop
List services as above once
systemd-cgtop -n 1
To sort, use the following based on the column titles
systemd-cgtop -t
systemd-cgtop -c
systemd-cgtop -m
systemd-cgtop -i
List services and their open ports
netstat -a
List services that use TCP and UDP and their open ports
netstat -tulpn
Display which user is used for a filename
fuser . -v
Display running service
top
Display running services in pretty formatting and enable F1-F10 commands.
htop
No comments:
Post a Comment