Limiting scp bandwidth usage
Use the -l parameter of scp to limit the speed of a file transfer (both upload or download). An empirically tested, good value for a 54Mbit wireless connection is 18000:
1 scp -l 18000 remotehost:file.img .
SSH public key encryption - How to generate the key and how to copy it to the remote machine
1 ssh-keygen -t dsa 2 ssh-copy-id -i ~/.ssh/id_dsa.pub user@server
OS X doesn’t come equipped with ssh-copy-id but you can download the script from here.
Remove ID3 tags from MP3 files recursively.
Remove id3 tags from MP3 files recursively.
1 #!/bin/bash 2 # By Marko Haapala 3 # requirements: 4 # id3ed - apt-get install id3ed 5 IFS=$'\n' 6 for mp3_file in $(find ./ -type f -iname '*.mp3'); do 7 id3ed -r "${mp3_file}" 8 done
Converting WMA files to MP3 on Linux
Use this to convert WMA files to MP3 in Linux.
1 #!/bin/bash 2 # By Marko Haapala 3 # converts wma to mp3 recursively. does not delete any static files, so 4 # cleanup and renaming is needed afterwards. 5 # 6 # requirements: 7 # lame - http://lame.sourceforge.net/download.php 8 # mplayer - apt-get install mplayer or http://www.mplayerhq.hu/design7/dload.html 9 10 11 current_directory=$(pwd) 12 wma_files=$(find "${current_directory}" -type f -iname "*.wma") 13 # Need to change IFS or files with filenames containing spaces will not 14 # be handled correctly by for loop 15 IFS=$'\n' 16 for wma_file in ${wma_files}; do 17 mplayer -vo null -vc dummy -af resample=44100 \ 18 -ao pcm -ao pcm:waveheader "${wma_file}" && lame -m s \ 19 audiodump.wav -o "${wma_file}".mp3 20 rm audiodump.wav 21 done
Transfer partition from one server to another
The following is an example of how to transfer a partition from one server to another.
In the example, I first create a file containing the partition, and then transfer the partition to the other server.
1 dd if=/dev/xen-1/aktagon.com-disk of=/tmp/file 2 scp /tmp/file username@host:/file
I then SSH to the other server and create the partition from the file.
1 ssh host 2 lvcreate -L 4G /dev/VG00/aktagon.com-disk 3 cat aktagon.com-disk.bz2 > /dev/aktagon-1/aktagon.com-disk
Remember to create a backup before running these commands.