To find out if the Network File System (NFS) service is running on a Linux or Unix server, you can use the systemctl command with the status subcommand. This command will display the current status of the NFS service, including whether it is running or not.
For example:
$ systemctl status nfs-server
● nfs-server.service - NFS server and services
Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; enabled; vendor preset: disabled)
Active: active (exited) since Mon 2021-01-04 11:25:23 EST; 1h 36min ago
Docs: man:nfsd(8)
https://sourceware.org/systemd/man/systemd.exec.html
https://sourceware.org/systemd/man/systemd.resource-control.html
Main PID: 722 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/nfs-server.service
└─725 rpc.idmapd
Jan 04 11:25:23 server systemd[1]: Starting NFS server and services...
Jan 04 11:25:23 server systemd[1]: Started NFS server and services.
In this example, the systemctl status nfs-server command shows that the NFS service is running and active.
Alternatively, you can also use the systemctl command with the is-active subcommand to check the status of the NFS service. This will return active if the service is running, and inactive if it is not.
For example:
$ systemctl is-active nfs-server active
Note that the systemctl command is only available on systems that use the Systemd init system, which is the default init system on most modern Linux distributions. If you are using a different init system, such as SysVinit or Upstart, you will need to use a different method to check the status of the NFS service.