Archive for the ‘tips’ Category

mounting a partclone image

Wednesday, May 22nd, 2013

Convert imagefile to a row dd file

sudo partclone.ntfs -r -W -s sda2.partclone.img -o sda2.img
mount -o loop sda2.img /mount/point

Disable adobe update manager startup

Saturday, May 18th, 2013
rm ~/Library/LaunchAgents/com.adobe.AAM.Updater-1.0.plist

SSH fingerprint

Wednesday, May 15th, 2013

To view the fingerprint of a SSH-key:

ssh-keygen -l -f id_dsa.pub

Sort merged apache log-file by date

Saturday, May 11th, 2013
1
2
3
4
5
6
7
#!/bin/bash
if [[ $2 == "" || $1 == "" ]] || [ ! -f $1 ]; then
    echo "Usage: $0 input-file output-file"
    exit
fi
echo "Sorting $1"
sort -t ' ' -k 4.9,4.12n -k 4.5,4.7M -k 4.2,4.3n -k 4.14,4.15n -k 4.17,4.18n -k 4.20,4.21n $1 > $2

Reference: http://stackoverflow.com/questions/5672733/how-can-i-sort-an-apache-log-file-by-date

Change screen shot directory Mac OSX

Monday, May 6th, 2013
defaults write com.apple.screencapture location ~/Pictures/
killall SystemUIServer

Reference: http://osxdaily.com/2011/01/26/change-the-screenshot-save-file-location-in-mac-os-x/

xargs list of files with whitespace

Sunday, May 5th, 2013
xargs -d '\n' -a delimited_by_newline.txt command

Flush DNS Cache OSX Mountain Lion

Friday, May 3rd, 2013
sudo killall -HUP mDNSResponder

Reference: http://osxdaily.com/2008/03/21/how-to-flush-your-dns-cache-in-mac-os-x/

Bash multithread

Thursday, August 30th, 2012
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
 
# finn fil ubuntu i /usr i, lag fil 1 om vellykket, i bakgrunn
find /usr -iname ubuntu && touch 1 &
 
# lag fil 2 i bakgrunn
touch 2 &
 
# Vis innhold i katalog
ls
 
# vent til de to underoperasjonene er ferdige
wait
 
# Hvis innhold i katalog når begge kommandoer er ferdige
ls
# Legg merke til at ved første ls er kun fil 2 tilstede, men ved andre
# er fil 1 også tilstede (wait ferdig, find && touch-kommando ferdig)
 
# slett filer vi laget
rm 1 2

Testing USB-stick with qemu/kvm

Wednesday, August 29th, 2012
1
2
3
lsusb
kvm -no-acpi -boot c -m 1024 \
  -usb -device usb-host,hostbus=2,hostaddr=4

Remove annoying update pop-ups from Ubuntu Oneiric(12.04)

Saturday, August 25th, 2012

Open /etc/xdg/autostart/update-notifier.desktop, find NoDisplay and edit it to false.

154
155
156
157
158
159
160
161
162
163
...
Icon=update-notifier
Exec=update-notifier
Terminal=false
Type=Application
Categories=
NotShowIn=KDE;
NoDisplay=false
X-GNOME-Autostart-Delay=60
X-Ubuntu-Gettext-Domain=update-notifier

Update-notifier will then show up in the application gnome-session-properties, where it can be disabled. When disabled, a modified version of update-notifier.desktop is written to ~/.config/autostart/.