Awesome Commands for Linux

I used to have a Wiki that I would keep track of all of the “Cool Commands” that I found or created.  But now that Wiki is down and I haven’t had the time to put it back up.  So, I need to keep track of commands so I don’t forget them.   Alright, starting off, have you ever wanted to change a few lines of text in a bunch of files?  I have.  I found a one line Perl script that will take care of it for you, and leave you a backup file for your trouble.

  • perl -pi -i.bak -e ‘s/searchval/replaceval/’ *.html

This command can use regular expressions for the search value and the replace value.

This next command will sync your information and can be used to only keep updated copies of files.   There are lots of options too, this only scratches the surface.

  • rsync -uav --progress /srcdir/ /dstdir/

This command will will look at the srcdir and then determine if the dstdir file is newer, if it is, it won’t copy.  Very useful if you need to merge multiple copies of files, but don’t want duplicates.

This next command will find files for you based on all sorts of criteria:

  • find . -mtime -10

This command will look for files that are -10 days old.

You can combine rsync and find to search for files and then sync those files.

  • find . -mtime -10 -print0 | rsync -av --progress --files-from=- -from0

This command will first compile a list of files that meet the find criteria and then will port them to rsync.  Very helpful.

Ok, that is all the cool commands for today, I will probably find some more tomorrow.

Found more… This command will make a file of any size for you:

  • dd if=/dev/zero of=file.out bs=1MB count=100

This command will create a 100 meg dummy file. Works great.

Mike

  1. No comments yet.

  1. No trackbacks yet.