~/.bashrc Tips & Trick

$USER = Your User Name

Thanks to "plb" on the debian forum for providing the tip/trick!

Open your .bashrc file located in your /home/$USER/ directory. It is a hidden file as some like to call it in the Gnu/Linux world. Assuming you have opened your file find a spot to paste in the following text:


function extract()
{
if [ -f "$1" ] ; then
case "$1" in
*.tar.bz2) tar xjf "$1" ;;
*.tar.gz) tar xzf "$1" ;;
*.tar.Z) tar xzf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) unrar x "$1" ;;
*.gz) gunzip "$1" ;;
*.jar) unzip "$1" ;;
*.tar) tar xf "$1" ;;
*.tbz2) tar xjf "$1" ;;
*.tgz) tar xzf "$1" ;;
*.zip) unzip "$1" ;;
*.Z) uncompress "$1" ;;
*) echo "'$1' cannot be extracted." ;;
esac
else
echo "'$1' is not a file."
fi
}


Now go to your editor/notepad menu and save. The next time you have an archived file that need to be opened open a terminal/console and type: (example): extract myfile.zip

USB gamepad

If you can not get your USB gamepad to work in linux, type the following into
a terminal:

modprobe joydev
modprobe usbhid

Then try your USB gamepad.

Secure /tmp directory

Make /tmp a RAM based file system. RAM is much faster than a disk, and any
data stored there is truly temporary and is lost at shutdown.

Drop to single-user mode so the X font server is shut down:
init 1

Clean out the existing /tmp:
rm -r /tmp/.[a-zA-Z]*

Add this line to /etc/fstab:
none /tmp tmpfs defaults 0 0

Mount it and verify that it worked:
mount -a
df

Now, by default Linux tmpfs will use up to half the RAM. Depending on your
security goals, this might mean that a user could cause problems by using too
much RAM for files in /tmp. Limit it with something like this in /etc/fstab,
which limits it to 100 MB: none /tmp tmpfs rw,size=100000000 0 0

Limit it even more 60 MB:
none /tmp tmpfs rw,size=128000 0 0

Do the above, but prevent an attacker from doing many things by making /tmp
less useful to them. Make the /etc/fstab entry say:
none /tmp tmpfs rw,noexec,nosuid,nodev,size=100000000 0 0

Limit it even more 60 MB:
none /tmp tmpfs rw,noexec,nosuid,nodev,size=128000 0 0
---
http://www.cromwell-intl.com/security/linux-hardening.html
---

Another method is to create a loopback filesystem that will be mounted as /tmp
and can use the same restrictive mount options. To create a 500mb loopback
filesystem, execute:

dd if=/dev/zero of=/.tmpfs bs=1024 count=500000

mke2fs -j /.tmpfs

cp -av /tmp /tmp.old

mount -o loop,noexec,nosuid,nodev,rw /.tmpfs /tmp

chmod 1777 /tmp

mv -f /tmp.old/* /tmp/

rmdir /tmp.old

Once this is complete, edit /etc/fstab to have the loopback filesystem mounted
automatically at boot:

/.tmpfs /tmp ext3 loop,nosuid,noexec,nodev,rw 0 0
---
http://blogs.techrepublic.com.com/opensource/?p=171

lower latency TCP

This tweak allows the Linux kernel to lower latency on TCP connections.
This is useful for online games and interactive web sites that stream live data
and benefit from low latency to and from the server. This tweak will vary
between computers as not much can be done to lower latency from the
software side.

Go to:
/etc/rc.d/rc.local

Then add the following to a new line:
echo 0 > /proc/sys/net/ipv4/tcp_low_latency

Restart for the change to take effect.

Restore grub bootloader

First thing is you need to run the command grub, you must be sudo/root to do
this. For grub (hd0,1) means hda (primary controller master), second partition or
(hda2)

Second, tell grub where are the grub files:

If you know where they are, type something like:
root (hd0,1)

Or if you don't have a clue run the following command:
find /boot/grub/stage1

Third, to install grub in the master boot record (mbr) of the first hard drive run
the following command: setup (hd0)

Finished: type quit and your are finished.

---

http://www.sorgonet.com/linux/grubrestore/