Sunday, November 11, 2007

Linux is fun for me

Do you've a SysRQ button on your keyboard? No. You must've the PrintScreen button, next to Scroll Lock? Yes. Then you can try out kernel keyboard shortcuts.

The fastest (and most unsafe) way to reboot your computer is
to press these these combinations, one after one.
Alt+SysRQ+s - Sync data to disks for all mounted disks immediately.
Alt+SysRQ+u - Remount all filesystems as readonly.
Alt+SysRQ+b - Reboot immediately.

There're a lot of kernel functions availible, depending upon your kernel version.
You can find them in kernelsource/Documentation/sysrq.txt file.

You can enable all of kernel functions by,
echo 1 >/proc/sys/kernel/sysrq

Pressing Alt+SysRQ+h should tell you about various sysRQ functions availible (in dmesg output). For example, on my system (Feisty Fawn), they are
SysRq : HELP : loglevel0-8 reBoot Crashdump tErm Full kIll saK showMem Nice powerOff showPc unRaw Sync showTasks Unmount shoW-blocked-tasks

The saK (secure access key) can be used to allow secure login. The output of kernel functions, if any, goes to /var/log/messages (or dmesg).


Waseem Ahmad said...

WTF I tried the first one and my system rebooted. I'm not gonna try more of these. hey guys read the labels before trying any of these......
And Kazim I'm not your Guniepig for these kind of experiments...
Now would you please explain all of these....
By the way it was really funny..Does it work only on windows or also on windhus?

Waseem Ahmad said...


Kazim Zaidi said...

Works only on Linux. They are Linux Kernel functions.

Alt+SysRQ+S - Sync all mounted filesystems. Data in buffer is immediately written to disks

Alt+SysRQ+U - Unmount and remount all filesystems readonly

Alt+SysRQ+B - reboot immediately.

Don't try the last one alone. It may result in filesystem corruption!

This sequence of keys (S U and B) is the fastest (and most unsafe, too) way to reboot your computer.

You see, Linux is fun for me (not for the readers of my blog, maybe)

Waseem Ahmad said...

I think i tried the last one alone..It just reboot..Thank god no File system corruption :-).

Aaveg Mittal said...

ohh!! plzzzzzz dont try thiss...i tried this peice of sh*t and unfortunately tried the last one system rebooted and was ............guys my system was about to crash....
newayz everything is under control now( xcept kazim, and v really hv to think about it )

Abbas said...

does not work

Shamail said...

Ab bolo...
Linux is 4 u......

Din worked on mine
Here is log and sys properties after doing this...

shamail@barbie:~/DownloadedMusic :-) dmesg | tail -3
PPP BSD Compression module registered
PPP Deflate Compression module registered
rfcomm_tty_ioctl: TIOCGSERIAL is not supported

shamail@barbie:~/DownloadedMusic :-) uname -a
Linux barbie 2.6.18-4-686 #1 SMP Mon Mar 26 17:17:36 UTC 2007 i686 GNU/Linux

shamail@barbie:~/DownloadedMusic :-) id
uid=1000(shamail) gid=1000(shamail) groups=20(dialout),24(cdrom),25(floppy),29(audio),44(video),46(plugdev),106(netdev),109(powerdev),1000(shamail)

shamail@barbie:~/DownloadedMusic :-) sudo echo 1 >/proc/sys/kernel/sysrq
bash: /proc/sys/kernel/sysrq: Permission denied
shamail@barbie:~/DownloadedMusic :-)

Linux is 4 u.....
Bolo bolo....

Kazim Zaidi said...

These Alt+SysRQ+... are kernel functions. To know more about them read the kernel documentation sysrq.txt.

Permission denied is surprising! Someone may explain that...

Your distribution (I guess Debian) must've disabled or masked these functions. These are used by kernel developers when coding. There are functions that will print the CPU register contents, task list, core dumping, killing everything except init and so on...

Explore to find out how to enable them for yourself!

Waseem Ahmad said...

Hey i tried following it's really cool..
Alt+SysRq+p #to see the contents of CPU register following is the output of the dmesg...

SysRq : Show Regs
Pid: 0, comm: swapper
EIP: 0060:[=c01012b6>] CPU: 0
EIP is at mwait_idle_with_hints+0x46/0x60
EFLAGS: 00000246 Tainted: P (2.6.20-16-generic #2)
EAX: 00000000 EBX: 00000000 ECX: 00000000 EDX: 00000000
ESI: 00000000 EDI: c03d4008 EBP: 00004664 DS: 007b ES: 007b GS: 00d8
CR0: 8005003b CR2: a00a2000 CR3: 1ad15000 CR4: 000006d0
[=c0101409>] cpu_idle+0x49/0xd0
[15702.505160] [=c03d97f5>] start_kernel+0x365/0x420
[=c03d9230>] unknown_bootoption+0x0/0x260