Jun 09

1 To get hard disk information.
hdparm -I /dev/sda

2 Search and replace option in vi.
:%s/old/new/g

3 To make an icon.
convert -size 900×120 xc:black -font Times-Roman -pointsize 100 -fill green -annotate +20+80 ‘Linux is the Best’ -fill green -annotate +25+90 ‘Linux is the Best’ -trim +repage logo1.png

4 To replace one word with another with the backup of the original one.
sed -ibackup s/orange/grapes/g sedd

5 To search for a particular word and delete it.
find / -name aaa* -delete

6 To delete the last 30 days files. For files before 30 days +30.
find /root/wallpapers/ -mtime -30 | xargs /bin/rm -f

7 Command to dump partitions, directory etc..
dump -0aj -f /back/mydump /dev/sda2

8 Command to restore the dumped partition.
restore -rf mydump /back

9 To convert all jpeg files in the current directory to avi.
mencoder “mf://*.jpg” -mf fps=1 -o outputs.avi -ovc lavc -lavcopts vcodec=mpeg4

10 To convert avi to mpeg-2
mencoder /root/ItalianJob.avi -mf fps=1 -o /opt/ItalianJob.mpg -ovc lavc -oac pcm -lavcopts vcodec=mpeg2video

11 To convert mpg to avi.
mencoder /editor/Seval.mpg -ovc xvid -oac mp3lame -xvidencopts bitrate=800 -o /opt/Seval.avi

12 To delete lines 23-47 using vim or vi.
:23,47 d

13 Command to display the installed fonts.
fc-list

14 To check the CD/DVD drive/eject.
fuser /media/cdrom [eject]/[eject -p]

15 To kill the process.
fuser -k /media/cdrom

16 Find all files that have the .exe extension in the current directory.
find . -name \*.exe

17 Lists all of the files in the queue, as well as the user, the job number, the size and the root directories from which the print jobs originate.
lpq

18 To free memory when memory is in short.
memhog 500m

19 Cron to shutdown machine.
55 23 * * * /sbin/shutdown -h now

20 To password protect a zip file.
zip -e -r /root/Desktop/new /root/Desktop/old

21 To delete all hidden files from current directory.
rm -rf .*

22 Extracting files to a specific directory
unzip Commonly\ Used\ Malayalam\ Fonts.zip -d /usr/share/X11/fonts/TTF/ -(Sorry! I’m a Malayali)

23 To format CD-RW
cdrecord blank=fast dev=1,0,0

24 To stop all process except your shell.
kill 0

25 To disable usb in linux, eg. fedora 8.
mv /lib/modules/2.6.23.1-42.fc8/kernel/drivers/usb/storage/usb-storage.ko /opt/

written by admin


One Response to “25 Useful Linux Commands”

  1. 1. Binny V A Says:

    Nice collection. Here is my command collection. Btw, the first comment in this post is spam.

Leave a Reply