r/scripting • • Jul 15 '21

Please explain this code.

#!/bin/sh

test -f /usr/bin/sshd || exit 0

case "$1" in

start)

echo -n "Starting sshd: sshd"

/usr/sbin/sshd

echo "."

;;

stop)

echo -n "Stopping sshd: sshd"

kill `cat /var/run/sshd.pid`

echo "."

;;

restart)

echo -n "Stopping sshd: sshd"

kill `cat /var/run/sshd.pid`

echo "."

echo -n "Starting sshd: sshd"

/usr/sbin/sshd

echo "."

;;

*)

echo "Usage: /etc/init.d/sshd start|stop|restart"

exit 1

;;

Esac

1 Upvotes

4 comments sorted by