Tips & Tricks, Tutorials, Hacking, Troubleshooting,

Taking basic screenshots in Ubuntu is easy. To capture the entire desktop, press the Print Scrn key on your keyboard. To capture the currently active window, press Alt + Print Scrn. However, if you are using Ubuntu 10.10, you might find that Alt + Print Scrn does not work when taking screenshots.

This is because the Alt + Print Scrn key combination is already assigned to the Magic SysRq key, which is a key combination used by the Linux kernel. It allows you to perform various low level commands, regardless of the state of the system. See the following Wikipedia page for more information:

http://en.wikipedia.org/wiki/Magic_SysRq_key

There is a way to disable the Magic SysRq key so you can use the Alt + Print Scrn key combination to take a screenshot of the currently active window. Open a Terminal window by selecting Accessories | Terminal from the Applications menu.

Opening a Terminal window

Type the following command at the command prompt and press Enter.

sudo sysctl -w kernel.sysrq=0

Sysctl is an interface for examining and dynamically changing parameters in Linux operating systems. The –w option allows you to change the sysctl settings. See the following page on Wikipedia for more information about the sysctl command.

http://en.wikipedia.org/wiki/Sysctl

NOTE: You can also type “man sysctl” (without the quotes) at the command prompt to get information about the options available for the sysctl command.

Enter your password when prompted.

Turning off the Magic SysRq key

The setting changed by the command you entered is echoed in the Terminal window.

Sysrq is turned off

Now, when you press Alt + Print Scrn, a screenshot is taken of the currently active window and the Save Screenshot dialog box displays. This dialog box allows you to assign a name to the screenshot file and to select a folder in which to save the file. Click Save to save the file.

Alt + Print Scrn now working for screenshots

If, after a reboot, you find you are unable to use Alt + Print Scrn to take a screenshot of the currently active window, again, you can permanently turn off the Magic SysRq key. To do this, we will open the sysctl.conf file in gedit and add a line to turn off the Magic SysRq key. Type the following line at the command prompt and press Enter.

gksudo gedit /etc/sysctl.conf

NOTE: The gksudo command is used to open graphical applications with administrative privileges. You may not have to enter your password again, depending on whether the grace period for the sudo/gksudo commands is active. You can turn this off, requiring your password to be entered every time you enter a sudo or a gksudo command. See our post, Eliminate the Grace Period for the sudo/gksu Commands, for more information.

Opening the sysctl configuration file in gedit

Scroll to the end of the file and add the following line to the file.

kernel.sysrq = 0

Click Save to save the file.

Adding the line to turn off the Magic SysRq key

To close gedit, select Quit from the File menu.

Closing gedit

To enable the Magic SysRq key again, type the following line at the command prompt and press Enter.

sudo sysctl -w kernel.sysrq=1

This changes the value of the sysrq setting to 1, turning it on.

Turning on Magic SysRq key again

If you want to turn on the Magic SysRq key again permanently, open the /etc/sysctl.conf file again as discussed earlier in this post and change the kernel.sysrq = 0 line to kernel.sysrq = 1.

If you want to know more about this issue with the Magic SysRq key, see the following web page:

https://bugs.launchpad.net/ubuntu/+source/metacity/+bug/642792

No comments:

Post a Comment