Useful Commands

Remote Reboot

  • net rpc shutdown -r -t 1000 -c “system is going to shutdown ” -I <ip address> -U administrator

Remote Services

  • net rpc service list -I IPADDRESS -U USERNAME
  • net rpc service stop SERVICENAME -I IPADDRESS -U USERNAME
  • net rpc service start SERVICENAME -I IPADDRESS -U USERNAME

Raid Checking

  • cat /proc/mdstat – get the raid disk
  • mdadm –detail /dev/md0 – check the raid status
  • e2fsck -n /dev/md0 – full disk check

Directory Usage

  • du ./* –max-depth=0 -m | sort -nr | head -n 10

SSH Tunnel Control

  • ssh -M -S my-ctrl-socket -fnNT -L 50000:localhost:3306
  • ssh -S my-ctrl-socket -O check
Master running (pid=3517)
  • ssh -S my-ctrl-socket -O exit
Exit request sent.

Display Log Files By Revision

  • Linux -
    cat $(ls -rv /var/log/auth.log*) | grep do something or other
  • Windows -
    for /f %i in ( 'dir buncha.logs* /o:d /b' ) do cat %i | grep -i "lookingfor" >> found.txt

Testing crontab command


Add the following line to the crontab, e.g. using crontab -e

* * * * *  /usr/bin/env > /home/username/cron-env

Create a shell script which executes a command in the same environment as cron jobs run:


. "$1"
exec /usr/bin/env -i "$SHELL" -c ". $1; $2"


run-as-cron <cron-environment> <command>


run-as-cron /home/username/cron-env 'echo $PATH'

Note that the second argument needs to be quoted if it requires an argument. The first line of the script loads a POSIX shell as interpreter. The second line sources the cron environment file. This is required to load the correct shell, which is stored in the environment variable SHELL. Then it loads an empty environment (to prevent leaking of environment variables into the new shell), launches the same shell which is used for cronjobs and loads the cron environment variables. Finally the command is executed.

 commands.txt · Last modified: 2017/03/14 09:15 by bpienig
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Recent changes RSS feed Driven by DokuWiki