« Newer Snippets
Older Snippets »
14 total  XML / RSS feed 

Extract all .tar files in a dir

// Extract all tar files in a dir
for i in *.tar; do echo working on $i; tar xvzf $i ; done

Delete all the .jpg files in all directories below the current

// Delete all the .jpg files in all directories below the current
find /PATH/TO/STARTING/DIRECTORY  -type f -name "*.jpg" -delete

Check Disk Usage on Linux

// Check Disk Usage on Linux
du -sh /PATH/TO/DIRECTORY

Make SymLink In Linux

Makes a symbolic link in linux

ln -s /home/dir_to /home/dir_from

//dir_to is the existing directory you want dir_from to point to symbolically

How to extract all the files from an RPM package

rpm2cpio filename | cpio -i --make-directories

how to use shfsmount as a normal user in Debian/Ubuntu

sudo chmod u+s /usr/bin/shfsmount /usr/bin/shfsumount

Bash script to export ssh public key to a remote server

This isn't a brilliant script, but it sure can be a time saver. When I add a public key by hand I end up doing a lot more commands.

#!/bin/bash

## USAGE: add_to_server.sh remote_server

## This script will add your ssh dsa public key to remote_server's authorized_keys list, 
## assuming that everything is in it's default location

set -v                                 # verbose output
username="USERNAME"              # CHANGE ME!!!!
remote_server=$1              # assigns the first commandline argument to $remote_server


## Pipe the public key to ssh, then remotely touch the file to make sure it will be there, and concat to the end of it.
## Might work without the touch?
cat ~/.ssh/id_dsa.pub | ssh ${username}@${remote_server} "touch ~/.ssh/authorized_keys && cat - >> ~/.ssh/authorized_keys"

exit 0

Stop bell/beep in bash

setterm -blength 0


Sets the bell length to zero for all applications

How to set a static IP in Ubuntu from the shell

Edit
/etc/network/interfaces 
and adjust it to your needs (in this example setup I will use the IP address 192.168.0.100):

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# This is a list of hotpluggable network interfaces.
# They will be activated automatically by the hotplug subsystem.
mapping hotplug
        script grep
        map eth0

# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.0.100
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255
        gateway 192.168.0.1

get rid of mac's ._ meta files on unix command line

When a mac accesses storage not formatted in it's own HFS format, it stores it's additional metadata about the file in another file named the same but starting with "._" It can be annoying and when you're accessing a remote volume that's source control managed with subversion, they show up your status information. This bash shell script will get remove of all ._metadata files residing below the current working directory.

#!/bin/sh
for i in `find . -regex '.*\._.*'`; do rm $i; echo "removing $i"; done


If you save that as "/home/$USER/bin/cleanup" and do a "chmod 777 /home/$USER/bin/cleanup" it will be available next time you open a terminal by just typing "cleanup".

How to Rip a DVD in Ubuntu Linux

First, install Handbrake:


sudo apt-get install nasm build-essential devscripts fakeroot
mkdir ~/tmp
cd tmp
wget http://apt.cerkinfo.be/pool/main/x264/x264_0.0.20050906-1.diff.gz
wget http://apt.cerkinfo.be/pool/main/x264/x264_0.0.20050906-1.dsc
wget http://apt.cerkinfo.be/pool/main/x264/x264_0.0.20050906.orig.tar.gz
dpkg-source -x x264_0.0.20050906-1.dsc
cd x264-0.0.20050906/
dpkg-buildpackage -rfakeroot
cd ..
sudo dpkg -i *.deb
sudo apt-get install debhelper libgtk2.0-dev jam nasm liba52-dev libavcodec-dev libdvdcss2-dev libdvdread3-dev libfaac-dev libmpeg2-4-dev liblame-dev libmp4v2-dev libogg-dev libsamplerate-dev libvorbis-dev libwxgtk2.6-dev libx264-dev libxvidcore-dev
wget http://handbrake.m0k.org/mirrors/m0k/HandBrake-0.6.2-src.tar.gz
tar -xzvf HandBrake-0.6.2-src.tar.gz
cd HandBrake-0.6.2
jam
sudo cp HBTest /usr/local/bin/handbrake

Next, follow the instructions from the Ubuntu Forums to compile and install MPlayer 2.0 from CVS.


Now we can actually rip the DVD:


cd ~/tmp
handbrake -e xvid -E ac3 -2 -S 1400 -i /dev/cdrom -o MOVIENAME.avi


Finally, split the DVD into two files:


mencoder -ovc copy -oac copy -endpos 700MB -o MOVIENAME.CD1.avi MOVIENAME.avi


The output will finish with something like:

Video stream: 1297.378 kbit/s  (162172 B/s)  size: 638610165 bytes  3937.851 secs  94414 frames

Note the number of seconds (in this case: 3937).


mencoder -ovc copy -oac copy -ss NUMER_OF_SECONDS -o MOVIENAME.CD2.avi MOVIENAME.avi


That's it!

Configure Ctrl-Alt-Del to open Gnome System Monitor

gconftool-2 -t str --set /apps/metacity/global_keybindings/run_command_9 "Delete"

gconftool-2 -t str --set /apps/metacity/keybinding_commands/command_9 "gnome-system-monitor"

Reverse DNS from command line

Quick and easy way to look up a domain name given an IP address.

dig -x 17.254.3.183


Fix permissions on a directory

chown -R youruser:youruser /thedirectory
find /thedirectory -type f -exec chmod 0644 {} \;
find /thedirectory -type d -exec chmod 0755 {} \;
« Newer Snippets
Older Snippets »
14 total  XML / RSS feed