[Bash] Don’t add message to .bashrc

It’s often very useful to add customized message (with info or specific commands) on a VM. The easiest way to do that is to use the /etc/motd file. But what to do if you want to add a message just for one user ?

The first thing that everybody try is to add the message to the .bashrc.
That’s a bad habit:

zapan:~$ ssh me@zapan 'uptime'
You shouldn't see this message !
 17:16:45 up 4 days,  7:29,  4 users,  load average: 1.81, 1.25, 0.83

As you can see the content is displayed in case of a non-interactive non-login shell invoked via ssh. Instead add your message to the .bash_profile or .profile file.

Further Reading and sources

[OpenVZ] Useful one-liner

List containers sorted by CPU usage:

# vzlist -o ctid,name,laverage

List containers sorted by TCP sender buffer usage:

# vzlist -H -o ctid,name,tcpsndbuf | sort -r -n -k3

List containers sorted by TCP receive buffer usage:

# vzlist -H -o ctid,name,tcprcvbuf | sort -r -n -k3

List containers sorted by overall resources consumption:

for i in `vzlist -H -o veid`;do echo $i; vzcalc $i; echo "========"; done;

Add a new network interface to a container:

# vzctl set <id> --netif_add eth0 --save

[Postgres] Increase shmmax

PostgreSQL is great, but the manner its work is sometime… a little unsettling. For example, Postgres like spawning a lots of little processes that communicate by IPC, which means using chunk of shared memory. Sometime you can hit the shmmax limit.

To obtain the current value :

cat /proc/sys/kernel/shmmax

You can ovverride the default value into the /etc/sysctl.conf file.
Add a line like this for example:

kernel.shmmax = 43554432

And don’t forget to make a sysctl -p and restart postgres to take into account the new value.