Linux console mode, how to lock screen?
When I run KDE 3.5, I can lock the session, lock the session and switch to another user, or logout.
1) How can I do that if I am not in KDE and boot in to just a console command prompt? 2) How can I tell the boot process for Linux to boot into just console mode? It gives me an option to select a different graphical session, but it automatically goes into the graphical mode. Is there way to tell Linux to go into just command mode? 3) If I am in terminal command mode only, how can I lock the screen? |
Linux uses runlevels which determine what services (like graphical server X) are run automatically. There are seven in total (0 to 6) of which runlevels 0, 1 and 6 are "special" or "reserved": for reboot, single user mode and shutdown. The rest (2-5) are "normal" multiuser runlevels, at least usually - they can be configured as you wish, but usually the default configuration is to have one "graphical" runlevel - one that automatically starts X and runs a graphical login manager when you boot into it - and the rest console login runlevels. If you have /etc/inittab file in your system, the runlevels are configured there (default runlevel, what to run on each runlevel, ...)
To change runlevels on-the-fly you can use init (or telinit) command: Code:
init 3 To change the default runlevel - the one that you get into when you boot - alter /etc/inittab file. There's a line that specifies the default runlevel number (initdefault), so just change that number, save and quit. I think it'd be safer to just log off, but maybe if you have altered your environment or something like that, you'd really want to lock the screen while in console. Luckily it seems a program called screen can do that (my typical use of that program is to detach and re-attach programs on a remote machine to keep them running while I'm logged off). In http://www.rackaid.com/resources/lin...nux-screen.cfm it says the command for screen to lockscreen is ^X x, so try it out (^ means press CTRL). |
Thank you for your comment.
This is what you mean by run levels in the /etc/inittab file: # 0 - halt (Do NOT set initdefault to this) # 1 - Single user mode # 2 - Multiuser, without NFS (The same as 3, if you do not have networking) # 3 - Full multiuser mode # 4 - unused # 5 - X11 # 6 - reboot (Do NOT set initdefault to this) This one seems to have a different name for 0, it calls it "halt". Will that runlevel reboot? The file looks like some kind of computer code. What programming language is it? "I don't quite get why you'd want to "lock screen" in command line, because you can just log off." I was trying to figure out more about Linux. It is new to me. In KDE, I can lock the screen. Is it impossible to lock the screen if I log in during the console only mode? You gave a command to try, but I did not get that command. Is it two "x"? I would press "ctrl" key while I press "shift" while I press "x" and then another "x"? |
Halt means system halt, or "turning the system off". It's not "poweroff", because it really doesn't power off unless there's some power management system that can do it (acpi); on older computers or computers where that sort of power management doesn't work, "halt" runs the system down into a state where the next step would be to turn power off, but because the system can't do it, the user must turn off the power by pressing the power button, for example. So it won't reboot, but run the system down, and if it can, power it off after that (that's what usually happens).
The file is not of any "language" as in programming languages or such; it's just a configuration file, and somebody decided that would be it's syntax - it's written in such a manner that a program that reads it knows in what form the various options are and can "read and understand" it. For example the lines starting with # are comment lines, and are ignored (this is usual). I checked how screen's lockscreen works, and it seems the information on the page I referred to wasn't accurate (didn't seem like that to me, or at least my version of screen works differently) - while running screen you can lock the screen by pressing ^A x, or in other words, hold CTRL button while pressing 'a' key, then release CTRL and press 'x' key. So yes, you can lock screen when in console (for example if you booted into command line mode and do not have a graphical desktop running). |
Thank you for your comment.
I will try that when I boot up in a console only mode. I typed in "help" at the console and it did not tell me anything about how I could lock the screen, if I could at all. There is so much about Linux that it is so difficult to find out about. If it were not for a forum like this, I think that a newbie like me would just give up Linux and get mom and dad to M$crosoft ME. |
Yeah, it can be a little difficult in the beginning - but once you get more accustomed to Linux (which could be harder if you're a long-term user of some non-Unix operating system), it gets easier all the time.
You can get into console not only by changing runlevel but by entering another virtual terminal, one that does not have X (the graphical server) running. Most Linux systems will have as much as 12 virtual terminals (places where you can log in even if you're aleready logged in at another virtual terminal) on the same machine, and they're accessible with key combinations from ALT+F1 to ALT+F12, or if you're in a graphical desktop/login manager (using X), CTRL+ALT+F1 onwards (or put another way: if you're on console, it's sufficient to use ALT and one of the Fn buttons, where n is a number from 1 to 12, but if you're not on plain console, you need to use CTRL too). So for example CTRL+ALT+F1 will get you to a console terminal (usually) if you're on your graphical desktop - KDE, for example - right now. There you can log in and try screen and do whatever you like, and when you want to get back to your grahpical terminal, hit ALT+F7 (usually it's 7 that the X is run on, but if it's not there - you get a console login again - try the other terminals 6...12). Or CTRL+ALT+F7, the CTRL key doesn't matter on console. You can try screen's lockscreen ability like this: log in on a console, then run some program with screen, like top for example (which shows process information) and then start playing around. Code:
screen top Code:
screen -r Code:
exit Code:
man -k keyword Code:
apropos keyword Code:
man -k lock screen Quote:
Code:
man screen Code:
man 1 screen |
screen lock worked on test
Quote:
Note that when I tested it as you said, with the "screen top" command, that it asked for a "key", and then asked "again". This was a password that I could enter in, different or the same my choice, that would unlock the screen. There is not a control key combination that will unlock the console screen lock without the password, is there? That would defeat the screen lock! |
All times are GMT -5. The time now is 11:01 PM. |