Site Tools


misc

Differences

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

Link to this comparison view

Next revision
Previous revision
misc [2011/03/04 00:55] – external edit 127.0.0.1misc [2013/02/21 09:52] (current) paulsmith
Line 1: Line 1:
 +====== misc ======
 +
 +===== umount nfs mount that server disappeared =====
 +<code>
 +mount local the ip off the server that disappeared:
 +
 +ifconfig eth0:fakenfs 192.168.0.18 netmask 255.255.255.255
 +umount -f -l /my/mount/dir
 +ifconfig eth0:fakenfs down
 +</code>
 +
 +===== list listened ports =====
 +<code>
 +netstat -ltnup
 +</code>
 +
 +===== script to copy files =====
 +This script copies files from one location to another building the same directory structure.
 +<code>
 +#!/bin/bash
 +
 +TARGETDIR=/usr/local/vmware/custom/host1
 +
 +copyfiletotarget() {
 +        dir=${1%/*}
 +        #echo $TARGETDIR$dir
 +        mkdir -p $TARGETDIR$dir
 +        cp -pR $1 $TARGETDIR$1
 +}
 +
 +copyfiletotarget /etc/make.conf
 +copyfiletotarget /etc/ha.d/haresources
 +copyfiletotarget /etc/ha.d/authkeys
 +copyfiletotarget /etc/ha.d/ha.cf
 +copyfiletotarget /etc/ha.d/ha_logd.cf
 +copyfiletotarget /var/www/localhost/htdocs/index.htm
 +copyfiletotarget /var/www/localhost/htdocs/index.txt
 +copyfiletotarget /etc/conf.d/hostname
 +copyfiletotarget /etc/hosts
 +copyfiletotarget /etc/iscsi
 +copyfiletotarget /etc/conf.d/net
 +copyfiletotarget /etc/conf.d/ntp-client
 +copyfiletotarget /etc/nut/
 +copyfiletotarget /etc/samba/smb.conf
 +copyfiletotarget /usr/local/sbin
 +copyfiletotarget /etc/vmware/netmap.conf
 +copyfiletotarget /etc/vmware/config
 +copyfiletotarget /etc/vmware/license.vs.1.0-00
 +copyfiletotarget /etc/vmware/license.cfg
 +copyfiletotarget /etc/vmware/hostd/vmInventory.xml
 +copyfiletotarget /etc/vmware/hostd/datastores.xml
 +
 +</code>
 +
 +===== simple rename =====
 +<code>
 +for f in ?.jpg; do mv "$f" "000$f"; done
 +for f in ??.jpg; do mv "$f" "00$f"; done
 +for f in ???.jpg; do mv "$f" "0$f"; done
 +</code>
 +
 +===== simple zip a set of files =====
 +<code>
 +for f in net-acct-*; do gzip "$f"; done
 +</code>
 +
 +===== unzip files create a directory to put them in =====
 +<code>
 +for f in *.zip; do a=`/bin/basename $f .zip`; mkdir $a; cd $a; unzip ../$f; cd ../; done
 +</code>
 +
 +===== touch all files and subdirectories =====
 +<code>
 +find . -exec touch {} \;
 +</code>
 +
 +===== cp files from find/grep results to a directory =====
 +<code>
 +find ~/somedir/ | grep .mkv | xargs -i cp -v {} /usr/local/media/movies/
 +</code>
 +
 +===== cv (strip comments from a file) =====
 +<code>
 +grep -vE '^\s*(#|$)' $1  | grep -v -e '^$'
 +</code>
 +