Table of Contents

Comments:

Put: : <'COMMENTBLOCK_ORWHATEVERYOUWANTTOCALLME'

before the block and put:

COMMENTBLOCK_ORWHATEVERYOUWANTTOCALLME

after the block

DISPLAY SETTINGS:

FILE MANAGEMENT

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 -)

Rip Audio from application using Pulseaudio (no Jack):

get index number of application audio:

assuming index is $INDEX:

Alternative: With ffmpeg

VIDEO

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

Record Desktop as Video:

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:

Position of Mouse Cursor:

mousepos.py (linux only)

PRINTING

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.

PDF

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

INTERNET

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>

Unattended upgrades, security only, for 16.04

check if port is in use

sudo lsof -i:8078

Superuser

Execute sudo cmd without needing to type password

Staying Safe
  1. backup /etc/sudoers file i.e. copy to somewhere safe
  2. leave at least one terminal window open as root
  3. edit /etc/sudoers with visudo not sudo. It's a wrapper for your already configured editor (not necessarily vi)
The Magic

Misc