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

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

Directory Usage

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

Apache Access Log - IP Address Usage

cat access.* | awk '{ print $1 }' | sort | uniq -c | sort -n

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.

Memory Usage

Convert Video Files

  • MKV → MPG
    ffmpeg -i "file.mkv" -c:a copy -c:v copy "file.mp4"

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

Network Fun

  • Scan a network for mac addresses -
    nmap -sn <subnet>.0/24
  • Get a mac addresses from an IP address -
    arp -a <ipaddress>

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: 2018/06/12 01:40 (external edit)
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