You are here

Tips on using BASH features

Tips on using BASH features

While you use Terminal or run your Linux on text mode, you can use this special key to help you work easier. Here it is: 

 

Ctrl+A Move cursor to the beginning of the command line.

Ctrl+C End a running program and return the prompt,

Ctrl+D Log out of the current shell session, equal to typing exit or logout.

Ctrl+E Move cursor to the end of the command line.

Ctrl+H Generate backspace character.

Ctrl+L Clear this terminal.

Ctrl+R Search command history, see Section 3.3.3.4.

Ctrl+Z Suspend a program, see Chapter 4.

ArrowLeft and ArrowRight Move the cursor one place to the left or right on the command line.

ArrowUp and ArrowDown Browse history. Go to the line that you want to repeat, edit details if necessary,

Shift+PageUp and Shift+PageDown Browse terminal buffer (to see text that has “scrolled off” the screen).

Tab Command or filename completion; when multiple choices are possible, the system possible, ask you if you want to see them all.

Tab Tab Shows file or command completion possibilities. if you want to change into the directory with a very long name, you don’t have to type down the whole name, just type on the command line cd xxx (xxx=the first 3 characters of directory name), then you press Tab and the shell completes the name for you, if no other files are starting with the same three characters. Of course, if there are no other items starting with “x”, then you might just as well type cd x and then Tab.  If more than one file starts with the same characters, the shell will signal this to you, upon which you can hit Tab twice with short interval, and the shell presents the choices you have:  your_prompt> cd ststarthere stuff stuffit In the above example, if you type “a” after the first two characters and hit Tab again, no other possibilities are left, and the shell completes the directory name, without you having to type the string “rthere”:

your_prompt> cd starthere

you’ll still have to hit Enter to accept this choice. In the same example, if you type “u”, and then hit Tab, the shell will add the “ff” for you, but then it protests again, because multiple choices are possible. If you type Tab Tab again, you’ll see the choices; if you type one or more characters that make the choice unambiguous to the system, and Tab again, or Enter when you’ve reach the end of the file name that you want to choose, the shell completes the file name and changes you into that directory - if indeed it is a directory name. This works for all file names that are arguments to commands. The same goes for command name completion. Typing ls and then hitting the Tab key twice, lists all the commands in your PATH that start with these two characters: 

your_prompt>

ls ls

lsdev

lspci

lsraid

lswlsattr

lsmod

lspgpot

lss16toppmlsb_release

lsof

lspnp

lsusb

source: mangtatang.dagdigdug.com