2

I have a few servers with an application for some clients, and I want to make an application available for the client to view the server and application status, and to be able to restart some services.

I already have done the major part of it, replacing the login shell of a ssh user with a custom shell script that presents him a menu with some options to do that. The menu is launched automatically with sudo (with NOPASSWD) once he logs in, because the script needs to restart system services. The problem is that I'd like him to view the output of top or htop, but I don't want him being able to kill or renice processes and maybe other things that both top and htop permits. I just want him viewing the output of top.

Is there any option, flag or equivalent command?

Carlos Campderrós
  • 773
  • 2
  • 6
  • 17

1 Answers1

9

There is top's secure mode, when it is invoked as

top -s

In that mode the user can't change the refresh delay of top, kill or renice processes.

If you want to make it system wide instead of on a per-invocation basis, you may use the /etc/toprc file with the following contents:

s
3.0

Only two lines: first one to set secure-mode, and the second to set the refreshing delay. You can have a ~/.toprc, but its syntax is different from the system-wide /etc/toprc and you can't set secure mode in there.

I can't find a similar option in htop.

Carlos Campderrós
  • 773
  • 2
  • 6
  • 17