13.07.2015 Views

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

C H A P T E R 8■ ■ ■Making Better Use ofthe Command LineYou no doubt spend a lot of time on the command line. This chapter contains some tips and tricks tomake your life easier when you’re typing, including both built-in bash shortcuts and how to write yourown autocompletion functions. Working on the command line often also means that you’re using files invarious ways, including the quick-reference guides to find and xargs (both incredibly useful butoccasionally complex to use). The last two recipes will help you operate on files more quickly.8-1. Using bash Keyboard ShortcutsA huge number of keyboard shortcuts are available for bash that can make your command-line life mucheasier and quicker.■ Note In fact, these are GNU readline shortcuts, which means that they’re usable not just in bash but also inany other applications compiled with readline. This includes, for example, the mysql command line.You’ve almost certainly already picked up one or two, but it’s worth putting the effort in to get moreof them under your fingers. The easiest way to learn them is to pick up one or two at a time and make apoint of using them until you’re fully familiar with them; then move on to the next couple.The default setting in most setups is emacs-like editing mode. You can also set bash/readline to usevi editing mode:set -o viThis will put you into a mode that behaves like vi(m) insert mode. To get into command mode, hitEsc (or press Ctrl-[), and then issue your commands as you would on the vi(m) command line. Forexample, use 3b to move three words backward. Hit i again to go back into insert mode and start typing.171Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!