See also: Windows Tips

See also: Cisco Tips

See also: Misc Tips

General (any distro)Edit

Make sure you check out these tips

How to automatically restart a daemonEdit

  • Put this in crontab
* */4 * * * /bin/pidof mythbackend >/dev/null || /etc/rc.d/mythbackend start

How to rsync a whole linux boxEdit

rsync -avH --numeric-ids --devices --specials --stats <src> <dest>

How to make encrypted tarballsEdit

tar czvf - <files, dirs>|gpg -r --encrypt > archive.tar.gz.gpg

To decrypt:

gpg --decrypt archive.tar.gz.gpg |tar xzvf -

How to find out which process has a port openEdit

sudo netstat -tulp

How to forward ports with sshEdit

ssh -q -f -N -g -L <local-port>:<remote-host>:<remote-port> <ssh-server>

How to multiplex through an ssh sessionEdit

Connect master:

ssh -M -S ~/.ssh/ctl-%r-%h-%p

Connect slave:

ssh -S ~/.ssh/ctl-%r-%h-%p

To automate it, add an entry for this host in ~/.ssh/config:

ControlPath ~/.ssh/ctl-%r-%h-%p
ControlMaster auto

Host * can be used to match all hosts. If you want to be asked to create a master session, use:

ControlMaster autoask

How to configure Sendmail to route to an smtp server Edit

Edit /etc/

define(`SMART_HOST’, `‘)dnl

If you need to use a port other than 25, add:

define(`RELAY_MAILER_ARGS', `IPC $h 8080')dnl

Run m4:

m4 /etc/mail/ > /etc/mail/

Restart Sendmail:

/etc/init.d/sendmail restart

How to rip a dvd with mencoderEdit

nice -n 18 mencoder dvd://<title no> -alang en -vf scale -zoom -xy 640 \
-o <outfile.avi> -oac mp3lame -lameopts abr:br=192 \
-ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1200:threads=2

How to encode video for ipodEdit

Get podencoder:

for i in *; do podencoder "$i" -o ~/ipodvids/; done

How to get file/dir names right in gripEdit

%A - %d/%t - %A - %d - %n.%x

How to unzip a whole bunch of zips into their own dirs in 1 commandEdit

for i in *.zip; do mkdir `basename $i .zip`; unzip -d `basename $i .zip` $i; done

How to configure a bttv cardEdit

First of all, you need to tell the bttv what type of capture card you have. In gentoo, you need to create a file /etc/modules.d/bttv My card is a Lifeview Flyvideo 2000 which is card 54, so I add a line like so:

options bttv card=54

How to stream with VLCEdit

vlc v4l:/dev/video:channel=1:norm=pal –sout #transcode{vcodec=mp4v,acodec=vorbis,vb=1024,ab=192}:\

If you want to watch the stream as well, use this command:

vlc v4l:/dev/video:channel=1:norm=pal –sout ‘#duplicate{dst=display,dst=”transcode\

How to use sudo with no passwordEdit

This is a dumb idea. Don't do it!

  • run 'visudo', and add:

How to convert flac to mp3Edit

gst-launch-0.10 filesrc location=<infile.flac> ! decodebin ! lame bitrate=256 ! filesink  location=<outfile.mp3>

How to create SAMBA machine accountsEdit

useradd -d / -s /bin/false <hostname>$
passwd -l <hostname>$
smbpasswd -a -m <hostname>$

How to map windows groups to unix groups on a SAMBA PDCEdit

rm /var/cache/samba/group_mapping.tdb
net groupmap modify ntuser=”Domain Admins” unixgroup=wheel
net groupmap modify ntuser=”Domain User” unixgroup=users

How to get date & time in fluxboxEdit

session.screen0.strftimeFormat: %a %d %b, %k:%M

How to rename network interfacesEdit

Put in /etc/udev/rules.d/05-net.rules

SUBSYSTEM=="net", ATTRS{address}=="01:23:45:67:89:ab", NAME="lan0"
SUBSYSTEM=="net", ATTRS{address}=="cd:ef:01:23:45:67", NAME="wlan0"

Big important NOTE: The letters (a-f) in the MAC address must be lowercase! Otherwise it won't work.

How to use openvpnEdit

  • On the Server
user nobody
group nogroup
ca ca.crt
cert server.crt
key server.key
dh dh1024.pem
plugin /usr/lib/openvpn/ system-auth
dev tun
proto tcp
port 443
keepalive 10 30
  • On the client
dev tun
proto tcp
remote <remote server> 443
ca /etc/openvpn/ca.crt
  • On linux you can store the username/password:
auth-user-pass /etc/openvpn/secret
chmod 600 /etc/openvpn/secret
  • Pushing default routes etc (to redirect all traffic via VPN)
push "redirect-gateway"
push "dhcp-option DNS <dns-server-0>"
push "dhcp-option DNS <dns-server-1>"
push "route <network> <netmask>"

Ubuntu (also debian)Edit

How to get optional libraries for thingsEdit

apt-get build-dep <package>

Using package selectionsEdit

Dump installed packages to a fileEdit

sudo dpkg --get-selections > packages

Set selections from a fileEdit

sudo dpkg --set-selections < packages

Hold back a package updateEdit

echo "rdiff-backup hold"|dpkg --set-selections

How to start some of ubuntu's daemons in fluxboxEdit

gnome-volume-manager &
gnome-power-manager &
gnome-settings-daemon &
sleep 1

You need the sleep in order to get the GTK theme, etc, loaded before Fluxbox, GKrellm, etc.

How to build DEBsEdit

To do this properly (for distribution) you should set up a chroot. See the docs on Ubuntu's wiki.

This info is coming from:

sudo apt-get install dpkg-dev file gcc g++ libc6-dev make patch perl autoconf dh-make fakeroot autotools-dev automake14

I'll be working in ~/scratch. Put your source tarball here and untar it.

dh_make -e -f ../some-app-0.1.tar.gz

Now's when you edit all the files in debian/ When you're satified:

dpkg-buildpackage -rfakeroot

How to set up a chrootEdit

sudo apt-get install debootstrap dchroot
sudo mkdir /var/chroot

Edit /etc/dchroot.conf, and append:

<some-identifyer> /var/chroot
sudo debootstrap --variant=buildd --arch i386 dapper /var/chroot/
sudo cp /etc/resolv.conf /var/chroot/etc/resolv.conf
sudo cp /etc/apt/sources.list /var/chroot/etc/apt/sources.list
sudo chroot /var/chroot/
apt-get update
apt-get install wget debconf devscripts gnupg
locale-gen en_AU.UTF-8

Extra steps for non-root use:

sudo cp /etc/passwd /var/chroot/etc/
sudo sed 's/\([^:]*\):[^:]*:/\1:*:/' /etc/shadow | sudo tee /var/chroot/etc/shadow
sudo cp /etc/group /var/chroot/etc/
sudo cp /etc/hosts /var/chroot/etc/
sudo cp /etc/sudoers /var/chroot/etc/
sudo chroot /var/chroot/
dpkg-reconfigure passwd
passwd <your first ubuntu user in the admin group>
apt-get install sudo

Then set your <some-identifyer> in /var/chroot/etc/debian_chroot. And create your home directory (or bind-mount it).

To chroot:

dchroot -d
dchroot -d 'command'

How to create a repositoryEdit

Quick and dirty. This doesn't handle distributing sources or signing packages.

mkdir -p /var/www/apt/dists/dapper/main

put your .debs in there.

cd /var/www/apt/dists/dapper/main
dpkg-scanpackages . /dev/null | gzip -9c >  Packages.gz
cp Packages.gz dists/dapper/main/binary-i386/

Now create a release file:

vim /var/www/apt/Release
Archive: dapper
Component: main
Architecture: i386

To use, add this to /etc/apt/sources.list:

deb http://localhost/apt dapper main
apt-get update

Debian (debian specific)Edit

How to install xEdit

apt-get install x-window-system

How to install from floppyEdit

You need 3 floppies:

  • boot.img
  • root.img
  • net-drivers.img


How to install kernel headersEdit

yum install kernel-devel

How to build RPMSEdit

  • Sources go in /usr/src/redhat/SOURCES
  • Output goes in /usr/src/redhat/RPMS/i386/
yum install rpmbuild
rpmbuild -ba <package>-<version>.spec

How to use grouplistsEdit

yum grouplist
yum groupinstall "GNOME Desktop Environment"

How to install asteriskEdit

CentOS has the best asterisk packages!

  • Put this in /etc/yum.conf:
name=RHEL 5 - i386 ATrpms
  • Australian voices (do this each time you upgade):
tar zxvf OpenVoice-Free-1.3.tar.gz 
/bin/cp -v OpenVoice-Free/au/* /var/lib/asterisk/sounds/
/bin/cp -v OpenVoice-Free/digits/au/* /var/lib/asterisk/sounds/digits

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.