November 14th, 2003, 07:36 AM
*nix terminal shortcut keys
Okay so you have just logged into a *nix shell with your handy SSH or telnet client. So you decide to see what all is in your directory. You type ls -at. That's a typo, you had better delete that. So you casually press your <backspace> key and your command turns into ls-at^ ]? What? So you try again and you get the same thing: ls -at^ ]^ ]. Well then you decide to clear it and try again so you hit <enter> and what do you get: ls -at^]^. So now you are confused as to what is going on. Depending on how your telnet session settings are set up, some of you keys may be messed up so it would be handy to know some simple *nix keyboard shortcuts:
tab = Auto complete the file you are typing
~ = returns you to your home directory
ctrl + A or Home = Move the cursor to the beggining of the line
ctrl + B = Move back one character (does not delete)
ctrl + C = Kill the current process
ctrl + D = Delete one character forward or logout of the current session if no text is available
ctrl + E or End = Move the cursor to the end of the line
ctrl + F = Move forward one character
ctrl + G = Cancels a Command that you have started typing
ctrl + H = Backspace
ctrl + I = Goto other panel
ctrl + J = Enter
ctrl + K = Delete one line forward from the point your cursor is at
ctrl + L = Clear the terminal window
ctrl + M = Enter
ctrl + N = Scroll thourgh the next commands
ctrl + O = Repeat a command sequence
ctrl + P = Scroll through the previously executed commands
ctrl + Q = Clear the scoll lock set with ctrl + S
ctrl + R = Reverse search. Lets you search back through your bash history.
ctrl + S = Set the Scroll lock. The screen will not update
ctrl + T = Transpose charaters around cursor: ex. foo (with the cursor on the middle o) becomes
ctrl + U = Clear the current line (can also be used as cut if you follow it with ctrl + Y)
ctrl + V = Next screenfull of text. And if you press it once, the next keyboard command will
display its shortcut
ctrl + W= Clear the current word
ctrl + X = Used to exit apps
ctrl + Y = Retrieves the most recently deleted text
ctrl + Z = Send the current process to the background
ctrl + + = Switch the GUI to a higher resolution
ctrl + - = Switch the GUI to a lower resolution
ctrl + alt + delete = Reboot system
ctrl + alt + backspace = Kill the X-server
ctrl + alt + Fn = (where N equals 1-6) Lets you switch through virtual terminals
ctrl + alt + F7 = Switches you to the X Sever if it is running
ESC + n = (where n is a number) repeat that command this many times
middle mouse button = paste highlighted text
[up or down arrows] = cycle through your bash history
shift + page up = Scroll back up through the terminal output
shift + page down = Scroll back down through the terminal output
That's all I am going to add now; mayber more later. But yeah, everyone add on!
November 14th, 2003, 07:47 AM
If some of these don't work as anticipated do
% stty -a
which will show you what your current control sequence keys are setup as.
A common problem is to have an incorrect erase mapping, so the BACKSPACE
or DEL keys don't work as intended. To fix this for your current login session, do.
% stty erase [hit your backspace key]
Also check out the man pages for your shell (csh, tcsh, bash, etc.) and stty.
Q: How do I know what shell I am using?
A: echo $SHELL
Get OpenSolaris http://www.opensolaris.org/
November 14th, 2003, 08:14 AM
spurious_inode makes a very good point here.... Those may work on the majority of systems, but they are by no means the standard. For example take a SCO Openserver Release 5 system..... If your account is created with the Bourne shell you have different defaults. For example your backspace key sequence is ^? instead of ^H. Another example would be your break sequence... We bash users know it as ^C however by default it is set to ^\ (however called usually control-pipe) on SCO bourne shell implementations. Also as spurious_inode mentioned many of these can be changed with the stty command. As well things like the ~ don't always work. This is a bash shortcut which is not included in the bourne shell. Another is your Ctrl+Alt+Delete. This is actually a configurable option in /etc/inittab. look for the line ca::ctrlaltdel:<some command>. You can change <some command> to literally anything you want, or leave the line as ca::ctrlaltdel: to disable ctrl+alt+delete. This is because linux is trapping the command, but for those that don't understand i'll leave that for another time, or a linux user.
IT Blog: .:Computer Defense:.
(Pronounced Pinched): Acronym - Point 'n Click Hacked. As in: "That website was pinched" or "The skiddie pinched my computer because I forgot to patch".
November 14th, 2003, 08:53 AM
Very nice tutorial...I'm not a fan of shortcut keys, but I'll have to try these out on the console
Creating further mindless stupidity....through mindless automation.