Put: : <'COMMENTBLOCK_ORWHATEVERYOUWANTTOCALLME
'
before the block and put:
COMMENTBLOCK_ORWHATEVERYOUWANTTOCALLME
after the block
Count # of files in a directory (recursively):
ll -R | grep -v "\(total \)" | grep -v "\.\?[/]$" | grep -v "^$" | wc -l
List files recursively by date:
find . -printf "%T@ %Tc %p\n" | sort -n printf arguments from man find: %Tk: File's last modification time in the format specified by k. @: seconds since Jan. 1, 1970, 00:00 GMT, with fractional part. c: locale's date and time (Sat Nov 04 12:02:33 EST 1989). %p: File's name.
Add symbolic link to file (~/www/elgg1.5/php.ini in example) to current directory and subdirectories:
for ELE in `find . -type d -print| awk 'NR > 1 {print}'`; do ln -s ~/www/elgg1.5/php.ini ${ELE}/php.ini ; done
change permissions of files recursively so group permissions match owner permissions:
chmod -R g=u name-of-folder
change permissions of directories or files only:
find -type d -exec chmod 775 {} \; find -type f -exec chmod 664 {} \;
copy files recursively, keeping permissions:
cd /source tar cf - * | ( cd /target; tar xfp -)
get index number of application audio:
assuming index is $INDEX:
pactl load-module module-null-sink sink_name=steam
pactl move-sink-input $INDEX steam
parec -d steam.monitor | sox -t raw -r 44k -sLb 16 -c 2 - /tmp/testme.wav
pactl list short sources
and copy the one that has the word monitor
in italsa_output.pci-0000_00_1f.3.analog-stereo.monitor
ffmpeg -f pulse -i alsa_output.pci-0000_00_1f.3.analog-stereo.monitor -ac 2 recording.m4a
transcode a video file so it is playable through Windows Media Player (Windows) and Quicktime (MacOS):
ffmpeg -i INPUT_FILE -b 1500 -ab 384k -cropleft 20 -cropright 20 OUTPUT.mpg
The easy way is to use gtk-RecordMyDesktop,but functionality with gtk-RecordMyDesktopusing jackappears to be broken. So another way if you need jackis ffmpegwith x11grab:
ffmpeg -f jack -ac 2 -ab 128k -i ffmpeg -acodec pcm_s16le -f x11grab -r 30 -s 320x240 -i :0.0+0,76 -vcodec libx264 -vpre lossless_ultrafast -threads 0 /tmp/test.mkv
Notes:
mousepos.py (linux only)
add PDF printer to ubuntu intrepid or jaunty (source):
bmeps seems to be the only way to make a transparent PDF from a PNG file. Directions for building here.
convert a grayscale PDF to B&W with Imagemagick:
convert -threshold 75% input.pdf output.pdf
determine resolution of images inside a pdf: pdfimages -list EXAMPLE.pdf
-J
i.e. ssh -J user@jumphost user@host
scp -J user@jumphost file user@host
DHCP Server and Firestarter (on 12.04)
Assign card a specific name:
Example: udevinfo -a -p /sys/class/sound/controlC1 udevinfo -p /sys/class/tty/ttyUSB2 -a ATTRS{modalias}=="usb:v067Bp2303d0300dc00dsc00dp00icFFisc00ip00", NAME="logochip", MODE="0666"
Backup (tar) directory and subdirectories:
tar -cvzf mytarfile.tgz mydir/
Backup database:
mysqldump --skip-lock-tables -h <hostname> -u <username> -p<password> <databaseName> > <filename>.sql
FONTS:
SWAPPINESS:
Convert File Ascii –> Hex: hexdump -e '16/1 “0x%02x, ” “\n”' <filename>
sudo lsof -i:8078
/etc/sudoers
file i.e. copy to somewhere safe/etc/sudoers
with visudo
not sudo
. It's a wrapper for your already configured editor (not necessarily vi)visudo
add to the end of your /etc/sudoers
file USERNAME ALL=(ALL:ALL) NOPASSWD: FULL_PATH_TO_SCRIPT
substituting in USERNAME and FULL_PATH_TO_SCRIPT as necessarysudo FULL_PATH_TO_THE_SCRIPT
echo Some message > /dev/kmsg
gawk '{ print strftime(), $0; fflush() }'
awk
is supposed to do this but at least when then piping to grep
only gawk
worked.apt-get purge `apt-get -s purge <PKG> | grep '^ ' | tr -d '*'`
du -cha --max-depth=1 /var | grep -E "M|G"
netstat -anpe | grep "1234" | grep "LISTEN"