There are several keyboard shortcuts in Linux. Learning them can make your life a lot easier! This tuXfile discusses mainly command line shortcuts but some X Window System shortcuts are also included.
Virtual terminal
Ctrl + Alt + F1Switch to the first virtual terminal. In Linux, you can have several virtual terminals at the same time. The default is 6.
Ctrl + Alt + FnSwitch to the nth virtual terminal. Because the number of virtual terminals is 6 by default, n = 1...6.
ttyTyping the
tty command tells you what virtual terminal you're currently working in.Ctrl + Alt + F7Switch to the GUI. If you have the X Window System running, it runs in the seventh virtual terminal by default in most Linux distros. If X isn't running, this terminal is empty.
Command line - input
Home or Ctrl + aMove the cursor to the beginning of the current line.
End or Ctrl + eMove the cursor to the end of the current line.
Alt + bMove the cursor to the beginning of the current or previous word. Note that while this works in virtual terminals, it may not work in all graphical terminal emulators, because many graphical applications already use this as a menu shortcut by default.
Alt + fMove the cursor to the end of the next word. Again, like with all shortcuts that use Alt as the modifier, this may not work in all graphical terminal emulators.
TabAutocomplete commands and file names. Type the first letter(s) of a command, directory or file name, press
Tab
and the rest is completed automatically! If there are more commands
starting with the same letters, the shell completes as much as it can
and beeps. If you then press Tab again, it shows you all the alternatives.This shortcut is really helpful and saves a lot of typing! It even works at the lilo prompt and in some X applications.
Ctrl + uErase the current line.
Ctrl + kDelete the line from the position of the cursor to the end of the line.
Ctrl + wDelete the word before the cursor.
Command line - output
Shift + PageUpScroll terminal output up.
Shift + PageDownScroll terminal output down.
clearThe
clear command clears all previously executed commands and their output from the current terminal.Ctrl + lDoes exactly the same as typing the
clear command.resetIf you mess up your terminal, use the
reset command. For
example, if you try to cat a binary file, the terminal starts showing
weird characters. Note that you may not be able to see the command when
you're typing it.Command line - history
historyWhen you type the
history command, you'll see a list of the commands you executed previously.ArrowUp or Ctrl + pScroll up in the history and edit the previously executed commands. To execute them, press
Enter like you normally do.ArrowDown or Ctrl + nScroll down in the history and edit the next commands.
Ctrl + rFind the last command that contained the letters you're typing. For example, if you want to find out the last action you did to a file called "
file42.txt", you'll press Ctrl + r and start typing the file name. Or, if you want to find out the last parameters you gave to the "cp" command, you'll press Ctrl + r and type in "cp".Command line - misc
Ctrl + cKill the current process.
Ctrl + zSend the current process to background. This is useful if you have a program running, and you need the terminal for awhile but don't want to exit the program completely. Then just send it to background with
Ctrl+z, do whatever you want, and type the command fg to get the process back.Ctrl + dLog out from the current terminal. If you use this in a terminal emulator under X, this usually shuts down the terminal emulator after logging you out.
Ctrl + Alt + DelReboot the system. You can change this behavior by editing
/etc/inittab if you want the system to shut down instead of rebooting.
No comments:
Post a Comment