Posts Tagged you probably don’t want to read this
How to backup a directory using tar in one line.
This is all terribly simple… but I’m rather inclined to forget it. The reason I’m putting this here is that I’ve written something like this at least twice.
file=$(basename `pwd`); backupName=$file-$(date +%Y-%m-%d.tgz); tar -C .. -czf $backupName $file --exclude=$file/$backupName
This creates a gunzipped tar file of the current directory, in the current directory and includes the current date in the name. This is quite useful for your home directory.
Add comment April 5, 2008
A local firewall for ubuntu
A very simple local firewall for Ubuntu machines using iptables.
I use the following set up:
In /etc/network/if-pre-up.d, I have an executable shell script called firewall which uses iptables-restore to load firewall settings stored in /etc/network/firewall. This script is as follows:
#!/bin/bash #/etc/network/if-pre-up.d/firewall - A script to restore a saved firewall on startup. cat /etc/network/firewall | iptables-restore
The firewall settings file /etc/network/firewall was created using the command:
iptables-save > /etc/network/firewall
after I set up a working firewall using iptables. (See man iptables). This file currently looks like this.
#/etc/network/firewall *filter :INPUT ACCEPT [1745:1484069] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [1763:303728]ROPCHAIN - [0:0] :LOGCONNECT - [0:0] -A INPUT -s 127.0.0.1 -p tcp -j ACCEPT -A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j LOGCONNECT -A FORWARD -j DROPCHAIN -A LOGCONNECT -j LOG --log-prefix "IPTABLES: BLOCK TCP CONNECT" -A LOGCONNECT -j DROP COMMIT
This stops any forwarding and any attempts to form incoming tcp connections. Any attempts to open a connection are logged via kernel logging.
I couldn’t find an easy way to filter just these messages into a file (short off piping all appropriate messages to a process in /etc/syslogd.conf that only keeps iptables messages… though I’m sure there is a clever way of doing this).
Also, I probably should be paying attention to rpc udp packets… or something like that.
Shout at me if there is some better way of doing this.
Add comment April 1, 2008
Ant troubleshooting
If you get an error like this:
No supported regular expression matcher found: java.lang.ClassNotFoundException: org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp)
when using ant then it may well be because you don’t have the ant-optional package installed (if you are using Ubuntu or similar.) You can install this with apt-get by typing:
apt-get install ant-optional
as root.
4 comments March 23, 2008
Services near Tower Hamlets
This is a map of amenities in near Tower Hill. It’s here so that it is easy to find.
Map
Add comment March 15, 2008
Emacs – select entire buffer macro
This is some emacs lisp code that makes -c a select the entire buffer. This is all terribly simple to do (if you spend a while looking at the documentation) – but I’d quite like to be able to cut and paste this without think. This has to pasted into your .emacs file to work.
(fset 'select-buffer [?\C-a ?\M-]) (global-set-key "^Ca" (quote select-buffer))
Of course, if you, unlike me, read documentation before deciding to impose your views upon people you might just use the mark-whole-buffer macro instead, which seems to be bound to C-x h by default.
1 comment March 15, 2008
How to stop the bell ringing in bash
To stop bash from trying to ring the bell add
set bell-style none
to the /etc/inputrc file. You can also be added to a local ~/.inputrc file – but this won’t work if
you log in as root.
Also, note that this won’t stop other applications from trying to ring the
bell – for this it might be best to switch off the bell at BIOS level.
See man bash.
Other applications whose bells you might like to stop:
less: Use the -q option. This can be acheived permanently by adding alias less=”less -q” to your .bashrc file.
man: man uses the $PAGER environment variable to display man pages, or the default pager (normally less) otherwise. Therefore add export PAGER=”less -q” to your .bashrc file.
vim: By default vim rings the bell. To stop this type set vb t_vb= at the colon-line, or add it to your .vimrc file.
emacs: Set the variable ring-bell-function to a function that doesn’t do anything. (setq ring-bell-function (lambda () nil)
1 comment March 9, 2008
