Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
commands [2018/01/19 19:49]
bpienig [Network Fun]
commands [2018/12/20 20:17] (current)
bpienig
Line 2: Line 2:
  
 ===== Remote Reboot ===== ===== Remote Reboot =====
-  * net rpc shutdown -r -t 1000 -c "​system is going to shutdown " -I <ip address> -U administrator+<​code>​ 
 +net rpc shutdown -r -t 1000 -c "​system is going to shutdown " -I <ip address> -U administrator 
 +</​code>​
 ===== Remote Services ===== ===== Remote Services =====
-  * net rpc service list -I IPADDRESS -U USERNAME +<​code>​ 
-  ​* ​net rpc service stop SERVICENAME -I IPADDRESS -U USERNAME +net rpc service list -I IPADDRESS -U USERNAME 
-  ​* ​net rpc service start SERVICENAME -I IPADDRESS -U USERNAME+net rpc service stop SERVICENAME -I IPADDRESS -U USERNAME 
 +net rpc service start SERVICENAME -I IPADDRESS -U USERNAME 
 +</​code>​
 ===== Raid Checking ===== ===== Raid Checking =====
   * get the raid disk <​code>​cat /​proc/​mdstat</​code>​   * get the raid disk <​code>​cat /​proc/​mdstat</​code>​
Line 16: Line 20:
 <​code>​cat access.* | awk '{ print $1 }' | sort | uniq -c | sort -n</​code>​ <​code>​cat access.* | awk '{ print $1 }' | sort | uniq -c | sort -n</​code>​
 ===== SSH Tunnel Control ===== ===== SSH Tunnel Control =====
-  * ssh -M -S my-ctrl-socket -fnNT -L 50000:​localhost:​3306 jm@sampledomain.com +<​code>​ 
-  ​* ​ssh -S my-ctrl-socket -O check jm@sampledomain.com +user@host:​~$ ​ssh -M -S my-ctrl-socket -fnNT -L 50000:​localhost:​3306 jm@sampledomain.com 
-  <​code>​Master running (pid=3517)</​code>​ +user@host:​~$ ​ssh -S my-ctrl-socket -O check jm@sampledomain.com 
-  ​* ​ssh -S my-ctrl-socket -O exit jm@sampledomain.com +Master running (pid=3517) 
-  <​code>​Exit request sent.</​code>​+user@host:​~$ ​ssh -S my-ctrl-socket -O exit jm@sampledomain.com 
 +Exit request sent. 
 +</​code>​ 
 +===== Reset Home Directory Permissions ===== 
 +<​code>​ 
 +  find /home/user -type d -print0 | xargs -0 chmod 0775 
 +  find /home/user -type f -print0 | xargs -0 chmod 0664 
 +</​code>​
 ===== Memory Usage ===== ===== Memory Usage =====
-  * ps_mem.py - https://​github.com/​pixelb/​ps_mem/​+https://​github.com/​pixelb/​ps_mem/​ 
 +<​code>​ 
 +ps_mem.py 
 +</​code>​
 ===== Convert Video Files ===== ===== Convert Video Files =====
   * MKV -> MPG <​code>​ffmpeg -i "​file.mkv"​ -c:a copy -c:v copy "​file.mp4"</​code>​   * MKV -> MPG <​code>​ffmpeg -i "​file.mkv"​ -c:a copy -c:v copy "​file.mp4"</​code>​
Line 54: Line 68:
 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. 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.
  
 +===== Catching ctrl-c =====
 +
 +From [[https://​rimuhosting.com/​knowledgebase/​linux/​misc/​trapping-ctrl-c-in-bash|here]] -- You can use the trap builtin to handle a user pressing ctrl-c during the execution of a Bash script. e.g. if you need to perform some cleanup functions.
 +
 +
 +
 +<​code>​
 +#!/bin/bash
 +
 +# trap ctrl-c and call ctrl_c()
 +trap ctrl_c INT
 +
 +function ctrl_c() {
 +        echo "** Trapped CTRL-C"​
 +}
 +
 +for i in `seq 1 5`; do
 +    sleep 1
 +    echo -n "​."​
 +done
 +</​code>​
  
 
 commands.1516391358.txt.gz · 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