On last.fm: Create Your Own Online Radio Stations

Use keyboard shortcuts at the command line

Tags: Linux, Vincent Danen, keyboard shortcut, keyboard, Ctrl, Linux Tips Newsletter

  • Save
  • Print
  • 14

Takeaway: The bash shell gives you flexibility at the command line for editing. Have a look at these examples.

Delivered each Tuesday, TechRepublic's free Linux NetNote provides tips, articles, and other resources to help you hone your Linux skills. Automatically sign up today!

The bash shell offers a lot of power for interacting with the command line. By default, the shell uses an Emacs-like mode to edit lines, which you can change to a vi-like mode. The mode you choose largely depends on which editor you're most comfortable with.

For example, when using the default Emacs-like mode, you can use a number of [Ctrl] or [Esc] key combinations to navigate and manipulate text when you're working on a lengthy command. Here's a list of some of your options:

  • Press [Ctrl]B to move backward one character.
  • Press [Ctrl]F to move forward one character.
  • Press [Esc]B to move one word backward.
  • Press [Esc]F to move one word forward.
  • Press [Ctrl]A to move to the first character in the line.
  • Press [Ctrl]E to move to the end of the line.
  • Press [Ctrl]U to delete the current line.
  • Press [Ctrl]K to delete from the cursor's current position to the end of the line.

You can also use a command to search through your history. Press [Ctrl]R to perform a reverse search through your history for a given command. When you've located the command, press [Enter] to reexecute it, or edit the command to change it.

If you frequently work from the command line, using these shortcuts can save you a lot of time.

  • Save
  • Print
  • 14

What do you think?

Article Categories

Security
Security Solutions, IT Locksmith
Networking and Communications
E-mail Administration NetNote, Cisco Routers and Switches
CIO and IT Management
Project Management, CIO Issues, Strategies that Scale
Desktops, Laptops & OS
Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
Data Management
Oracle, SQL Server
Servers
Windows NT, Linux NetNote, Windows Server 2003
Career Development
Geek Trivia
Software/Web Development
Web Development Zone, Visual Basic, .NET
advertisement
Click Here