Linux hacks

Command Line Completion

The Bash default command line completion isn't as good as Windows. But you can configure it to be the same. Just edit ~/.inputrc and add the following:

set completion-ignore-case on

set mark-directories on

set mark-symlinked-directories on

set show-all-if-ambiguous on

set visible-stats on

$if mode=vi

  "\C-0-": digit-argument

  TAB: menu-complete

  "\e[Z": "\C-0-\t"

$else

  TAB: menu-complete

  "\e[Z": "\M—1\t"

$endif

Auto login

If you're creating a simple Virtual Machine that's only got a console and you don't have any security concerns (e.g. a test network isolated from the internet), then you can enable auto-login.

Stop terminal auto-off

By default the terminal window will blank out if nothing is done, which is not very useful if you're monitoring stuff. To disable this, use the following command.

setterm -blank 0 -powersave off -powerdown 0


Generate CSV file of current directory

 find  -printf '"%P";"%Tc";"%s";\n' > ~/files.csv


Get the end of a file

less +F error.log

To page up / page down, you need to press Ctrl-c. 

To re-enter forward forever mode, press F.

Make a time-stamped backup of a file

cp /folder/file.ext{,-`date +%Y-%m-%d-%H%M%S`}