could anyone explain what the following line of code does
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
and how is it different from
test -f /var/run/syslogd.pid && kill -HUP `cat /var/run/syslogd.pid`
[I know it should restart syslogd, but is there a difference between the two? bit of a linux noob, sorry]
/bin/kill -HUP <PID>– sends SIGHUP signal to process identified by<PID>(process identifier). Sending this signal to deamons (or services if you prefer) usually instructs them to reread (read again) their configurationcat /var/run/syslogd.pid 2> /dev/null– reads the/var/run/syslogd.pidfile (which contains PID of the syslogd daemon) and prints it to standard output (file descriptor =0(zero)). The2> /dev/nullpart of it redirects standard error stream (file descriptor =2(two)) to/dev/nullto discard all error messages that occured while reading/var/run/syslogd.pidtest -f /var/run/syslogd.pid– tests if the file/var/run/syslogd.pidexists. If it exists it (usually) means that the daemon (in this case syslogd) is up and running.To summarise:
/dev/nullis a special device file that discards (ignores) everything that is written to it (like a bottomless well). Sometimes used to discard error messages (like in your case here).