process file descriptor count

I’ve recently had to deal with a process leaking file descriptors. The following command came in handy as a quick way to count how many file descriptors a process is using.

Let’s say that we want to count them for the process(es) called firefox:

ps -ae | grep firefox | perl -lane 'print $F[0]' | while read filename; do ls /proc/$filename/fd; done | wc -w


VM stuck on a task

I’ve recently lost control of a VM that was stuck at 95% of a task. I waited and tried to regain control of the VM, nothing helped. This is how I got around it:

SSH into the ESX on which the VM is instantiated
cat /proc/vmware/vm/*/names | grep <vm_name>
note the vmid
note the group vmid
/usr/lib/vmware/bin/vmkload_app -k 9 <group_vmid>

That’s it!

ssh tunnel to circumvent a firewall

My work place like many others has a pretty restrictive firewall that doesn’t let me ssh into my own machine. To get in the network, one has to use VPN which means that a furious battle will rage getting this to work in linux; but above all you won’t get to ssh from your phone.

So if you have a home server, run the following command on your work machine and it will create a tunnel from your work machine to your home server:

ssh -f -N -R 1337:localhost:22 root@home_server

Now login to your home server and when you

ssh localhost -p 1337

You will in fact be sshing to your work machine via magic fairies & such.

It adds a level of indirection which sucks major balls, so you can copy some keys and get all that automated but I don’t want to go into these details. Figure it out.

You can go away now.