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.

CHAPTER 8 ■ USING THE COMMAND LINE BETTERHowever, note that vi mode doesn’t have quite so many useful key bindings defined. You can defineyour own, though; take a look at the section in the readline init file in the bash manual, or type bind -pto get a list of key bindings in a form that you can dump straight into your ~/.initrc). To return to emacsmode again, use this:set -o emacsYou can set vi mode to be on permanently by adding these lines to your ~/.initrc file:set editing-mode viset keymap viThe bash man page has many more of the default key bindings documented. You can also type bind-P to get a list of possible functions and their key bindings (if any).• Ctrl-A and Ctrl-E: These move to the beginning and the end of the command line,respectively. You’re probably already familiar with these.• Ctrl-U: This deletes from the cursor backward to the beginning of the line. This isuseful when you’ve accidentally exited the incremental search with a commandline you don’t want or if you just get your fingers in a tangle and need to startagain. It also works when you’re entering passwords, so it’s handy when you getstuck halfway and aren’t sure how many times to hit Backspace. If you want to putthe line you’ve just cut back again, use Ctrl-Y, which restores whatever is currentlyin the buffer.> cd /usr/share/some/nonsense Ctrl-U>• Ctrl-K: This is the reverse of Ctrl-U; this deletes from the cursor forward to the endof the line.• Ctrl-R and Ctrl-S: This performs an incremental search backward or forward,respectively, in your command-line history. So, if you hit Ctrl-R and start typing aword (for instance, find), it’ll start looking for the last command that used theword find, and it’ll show the results as you type. Keep hitting Ctrl-R to scrollbackward through the list of commands that fit the search pattern. If you hit Ctrl-Rand then type apache, this is the sort of output you’ll get:> [Ctrl-R]apache(reverse-i-search)`apache': /etc/init.d/apache2 force-reload• Ctrl-J and Ctrl-G: These abandon an incremental search either with the line foundor with the original line, respectively. So, these commands will put you back toyour regular command line, from where you can edit the command you have (thesearched-for command line, with Ctrl-J, or the command line you started with,with Ctrl-G) as required.(reverse-i-search)`apache': /etc/init.d/apache2 force-reloadCtrl-J> /etc/init.d/apache2 force-reload172Download at WoweBook.Com

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

Saved successfully!

Ooh no, something went wrong!