Friday, November 20, 2009
Search
  
Most Popular
Guides
General Computing
WEB Reviews
Sapphire HD 5750 1 GB GDDR5
Synology DS209 Advance NAS Enclosures
Toshiba Satellite T135 Win 7 CULV Notebook
ASRock M3A785GXH/128M Motherboard
LiteON iHAS424 Dual-Layer DVD Writer
Sapphire PurePSU 950W
AMD Athlon II X3 435 Triple Core Processor
Cooler Master Lab Test Bench V1.0
Breaking News
Twitter To Charge For Upcoming Services
YouTube More Acessible With Automatic Captions Feature
Panasonic Presents Advanced Disc for Archive
ASUS Supercharges The Eee Line Of PCs With NVIDIA ION
MediaTek and Qualcomm Enter Into Patent Arrangement
Intel Validates Hynix 40nm Class 2Gb DDR3 Products
Elpida Completes Development of 1-Gigabit GDDR5
PlayStation Network Video Delivery Service Now Available for Europe
Home > Guides > General Computing

Wednesday, February 07, 2007
Linux tips and tricks

1. Page 1

Key combinations to impress your friends

You probably know key combinations like Ctrl-C or Ctrl-Z. You'd be surprised to learn that there are quite a few more useful key combinations that you probably haven't heard of. Here are a few to keep in mind when working at the console (note: most of these should also work under Konsole or other GUI console applications):

  1. Ctrl-C (usually) sends the kill signal, which terminates a process abruptly.

  2. Ctrl-Z sends the stop signal, which stops process execution immediately, without terminating. Use “fg” or “bg” after that to restart the process of send it to the background. Ctrl-Y is an interesting variant, which stops process execution only when the process tries to read user input from the console.

  3. Ctrl-S is the scroll lock: when you have too much output scrolling quickly, you can use Ctrl-S to stop process output. You can then use Shift-PageUp/PageDown to scroll up and down and read it. Ctrl-Q resumes. Technically speaking, Ctrl-S and Ctrl-Q send the XON/XOFF terminal commands, that may be ignored in some cases. The Bash shell translates Ctrl-S to “search”, so it depends on where you are working.

  4. Ctrl-L clears the screen and positions the prompt at the top left corner. Use this if your screen has become garbled.

  5. Ctrl-A and Ctrl-E take you to the beginning and the end of the line, respectively. Home and End also work, but not always.

  6. Alt-F and Alt-B take you to the next or previous word, very useful if you're typing a long sequence of commands or a command with many arguments.

  7. Tab is probably the most useful key when using the shell. Tab will do filename completion, but also hostname completion, variable name completion and other useful things.

The X-Windows environment

There are a few key combinations that work under the X-windows server, regardless of whether you are under KDE or Gnome (or any other environment, for that matter):

  1. Ctrl-Alt-F1/F2... : switch to the corresponding character virtual console. This is meaningful only if you are running under the appropriate init level, otherwise you won't find a login prompt. You will need Alt-F7 to get back to X-windows (this depends on the kernel settings for the number of virtual consoles, could also be Alt-F9 or Alt-F11, for example).

  2. Ctrl-Alt-Backspace : Kill the X-server

  3. Ctrl-Alt- + or - : Cycle between resolutions, according to the xf86config file. You need to have multiple resolutions defined in your config file for this to work.

The Magic SysRq key

You need to enable the magic SysRq key during compilation of the kernel. Some distributions enable it by default. Otherwise you can simply compile the kernel yourself (easier than it seems, trust me) after enabling it under “Kernel Hacking”.

Once you have the SysRq key enabled, the following keystrokes will work (more can be found in the kernel documentation) :

  1. Alt-SysRq-S: emergency sync, tries to write all unsaved buffers

  2. Alt-SysRq-U: emergency remount read only for all file systems

  3. Alt-SysRq-E: send the terminate (15) signal to all processes except init

  4. Alt-SysRq-I: send the kill (9) signal to all processes except init

  5. Alt-SysRq-B: emergency IMMEDIATE reboot (unsafe, like pressing the reset button!)

  6. Alt-SysRq-K: emergency kill of all programs under the virtual console

When the system crashes, emergency sync, remount and reboot are a convenient way to ensure a relatively safe system reboot. The following sequence best emulates a normal software reboot : Alt-SysRq-S, 5 sec pause, Alt-SysRq-E, 5 sec pause, Alt-SysRq-S, 5 sec pause, Alt-SysRq-I, Alt-SysRq-S, 5 sec pause, Alt-SysRq-U, Alt-SysRq-B (the pauses and multiple syncs are a bit excessive, but better safe than sorry). If a console crashes really bad, emergency kill may remedy the situation and get you back to a login prompt.

Note that these commands are immediate and potentially unsafe, so only use as a last resort before doing a real hardware reset or something equally drastic. Also, bear in mind that the magic sysrq key can be used as a denial-of-service attack by malicious hackers/crackers, so don't enable it in servers that are particularly vulnerable and exposed to such threats.

Quitting Vim/Vi

I remember playing with various linux commands and applications back in the days when I was beginning to use linux. One of the most annoying ways to get stuck was inside the Vi/Vim editor, that captures the Ctrl-C and Ctrl-Z keystrokes. Although I'm sure there are several readers who think that Vi is the best thing since sliced bread, most people should just know how to exit, in case they accidentally get trapped inside it. Simply type “:q!”, without the quotation marks, of course.

Conclusion

So many things, so little time. Although the examples given above may at first seem to be daunting, I think that every linux user should at least try to use them. After a while, these make life seem so much easier that it will be definitely worth it. That being said, if you only had to know ONE key, Tab would be it. Trust me on this...

PKT




Get RSS feed Easy Print E-Mail this Message


Recommended Links
 
Home | News | All News | Reviews | Articles | Guides | Download | Expert Area | Forum | Site Info
Site best viewed at 1024x768+ - CDRINFO.COM 1998-2009 - All rights reserved -
Privacy policy - Contact Us .