Wednesday, September 20, 2017
Most Popular
General Computing
WEB Reviews
Seagate Enterprise Capacity 3.5 V.3 4TB SAS 6Gb/s HDD Review
OCZ Vector 256GB SSD Review @ Custom PC Review
Gigabyte F2A85XM-D3H
NZXT Phantom 630
Auvio Bluetooth Portable Speaker Review
Corsair H90 CPU Cooler Review
BIOSTAR Hi-Fi Z77X (Intel Z77) Motherboard Review
Noctua NH-L9i Cooler Review on Technic3D
Breaking News
Pimax Launches First 8K VR Headset
New Amazon Fire HD 10: 1080p Full HD Display, Faster Performance, for $150
CyberLink Introduces 360 Video Editing Tools with PowerDirector 16 and Director Suite 6
Pioneer Introduces New CDJ-2000NXS2-W and DJM-900NXS2-W
AUO Presents 85-inch 8K4K Bezel-less TV Display
South Korean Government Wants to Stop Technology "Leaks" to China
Fujitsu Develops Wearable, Hands-Free Speech Translation Device
Dell Sees Solid Growth in Worldwide PC Monitor Market
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.


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...


Get RSS feed Easy Print E-Mail this Message

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