Friday, June 26, 2009

5 Useful Linux / Unix Commands

1). Show installed but unused linux headers, image, or modules:

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'

If you would also like to purge them too:

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge


2). Rip audio from a video file:

mplayer -ao pcm -vo null -vc dummy -dumpaudio -dumpfile


You can also extract the sound from a flv and make an mp3 with:

ffmpeg -i input.flv -f mp3 -vn -acodec copy ouput.mp3


3). Stream YouTube URL directly to mplayer:

mplayer -fs $(echo "http://youtube.com/get_video.php?$(curl -s $youtube_url | sed -n "/watch_fullscreen/s;.*\(video_id.\+\)&title.*;\1;p")")

(Replace $youtube_url with any youtube URL)


4). Purge configuration files of removed packages on debian based systems:

sudo aptitude purge `dpkg --get-selections | grep deinstall | awk '{print $1}'`


5). Convert images to a multi-page pdf:

convert -adjoin -page A4 *.jpeg multipage.pdf

No comments:

Post a Comment