Prepend the text “foo” to the start of every line in file.
With sed:
1 |
sed -i.bak 's/^/foo/' file |
With perl:
1 |
perl -e 'while (<>) {print "foo"}' < infile > outfile |
Taken from:
Linux and open-source solutions.
Prepend the text “foo” to the start of every line in file.
With sed:
1 |
sed -i.bak 's/^/foo/' file |
With perl:
1 |
perl -e 'while (<>) {print "foo"}' < infile > outfile |
Taken from:
Sometimes with a new user on Ubuntu I find that filename auto-completion is missing in the shell. I found two issues that cause this:
1. Ubuntu sets new users to /bin/sh which is a very limited shell. So first step is to change the user to /bin/bash:
1 |
chsh -s /bin/bash rpenguin |
2. The /etc/bash.bashrc has filename completion disabled by default. Edit this file and un-comment the appropriate lines. Here’s what it looked like on one server:
1 2 3 4 5 6 7 8 |
# enable bash completion in interactive shells #if ! shopt -oq posix; then # if [ -f /usr/share/bash-completion/bash_completion ]; then # . /usr/share/bash-completion/bash_completion # elif [ -f /etc/bash_completion ]; then # . /etc/bash_completion # fi #fi |
So I changed to:
1 2 3 4 5 6 7 8 |
# enable bash completion in interactive shells if ! shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then . /etc/bash_completion fi fi |
Upon login the new user should now have filename completion features.
Also note that by default “vi” is handicapped. Here’s how to upgrade to a full feature set:
Some times I’ll run into an Ubuntu install where “vi” does not work as expected. For example the backspace and arrow keys will in insert mode will add characters. Turns out Ubuntu installs vim-tiny by default which is a stripped down (and historically compatible) version of vi. The solution is just to install the full version:
1 |
sudo apt-get install vim |
This post post gives a very effective way to cause TCP connections to be more rapidly recycled:
http://ihazem.wordpress.com/2012/02/07/reducing-time_wait-socket-connections-recyclereuse/
AIDE or Advanced Intrusion Detection Environment is a great tool for host based system integrity monitoring. AIDE will maintain a database of checksums on the content and attributes of critical system files. If these files change then a notification email will be sent.
Here’s the homepage for the AIDE project: http://aide.sourceforge.net/
Installing AIDE is easy since it’s available via yum:
1 |
yum install aide |
Edit the configuration file at /etc/aide.conf and make the following changes:
To setup just do:
1 2 |
/usr/sbin/aide --init cp /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz |
Also add a daily cronjob that runs a check operation:
1 |
0 5 * * * /usr/sbin/aide --check |
This job will send notification email to “root”. Make sure “root” is aliased to an appropriate address so the notifications will actually be received.
The procedure when you receive a notification should be to:
Here’s the update procedure:
1 2 |
/usr/sbin/aide --update mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz |
If you don’t update the database then you’ll keep getting the same notifications over and over.