LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-02-2008, 03:48 AM   #1
newtovanilla
Member
 
Registered: Apr 2008
Posts: 267

Rep: Reputation: 30
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?
 
Old 05-02-2008, 04:35 AM   #2
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
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
would change to runlevel number 3 and so on. In many distributions runlevel number 5 is the one that boots into graphical login manager, but it can be configured otherwise; to make sure what is a "non-graphical" runlevel, either see the inittab file or try each runlevel from 2 to 5.

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

Last edited by b0uncer; 05-02-2008 at 04:42 AM.
 
Old 05-02-2008, 04:45 AM   #3
newtovanilla
Member
 
Registered: Apr 2008
Posts: 267

Original Poster
Rep: Reputation: 30
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"?

Last edited by newtovanilla; 05-02-2008 at 04:48 AM. Reason: add last question
 
Old 05-02-2008, 04:52 AM   #4
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
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).
 
Old 05-02-2008, 05:03 AM   #5
newtovanilla
Member
 
Registered: Apr 2008
Posts: 267

Original Poster
Rep: Reputation: 30
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.
 
Old 05-02-2008, 05:19 AM   #6
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
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
This runs screen (which is transparent - you won't notice any difference) and on top of it 'top'. Now that it runs on screen, you can lock your screen with ^A x, or in other words, hold CTRL while pressing 'a' key, release CTRL, then press 'x' key. You should be prompted for your password to unlock the screen. If you want, you can de-attach the screen session with ^A d, and get back to the console - the 'top' is still there, but it's detached so it's running but not in sight. This looks the same as if it would run in the background, except that you can even log off and it won't stop. To get it back, run
Code:
screen -r
and it should re-attach and be there; hit 'q' to exit top. To log out, command
Code:
exit
To get help in command line you can use 'apropos' or 'man' (or on some systems 'info', which is about the same, but uses linked pages and not just single page like manpages):
Code:
man -k keyword
shows, if any, manual pages that include keyword (this allows you to search for manual pages that could help if you know a keyword that is related). Similarly running
Code:
apropos keyword
shows you some manual page numbers, for example
Code:
man -k lock screen
prints a lot of text, including this line:
Quote:
screen (1) - screen manager with VT100/ANSI terminal emulation
The first column ('screen') is the man page name. The number on the second column (1) is the 'section' of man pages where this page is - there are several sections (try to find information about them with man!), and a page can exist in several sections with the same name, so you can use that number to tell which page exactly you want to see, if there are multiple. The third column is a description of the page. To see that page, command
Code:
man screen
or if there are several pages and you wish to get the one that is in the 1st section,
Code:
man 1 screen
The 'info' command works similarly to 'man', try it out if it exists.
 
Old 05-17-2008, 08:05 PM   #7
newtovanilla
Member
 
Registered: Apr 2008
Posts: 267

Original Poster
Rep: Reputation: 30
Wink screen lock worked on test

Quote:
you can lock your screen with ^A x, or in other words, hold CTRL while pressing 'a' key, release CTRL, then press 'x' key.
Thank you for the solution to my post! You can mark this post as complete, I think?

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!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
screen lock for virtual console cad Linux - General 2 02-18-2007 11:13 AM
disable automatic screen blanking in console mode drkstr Slackware 3 10-10-2006 10:25 PM
Screen flickering in console mode LasseBob Linux - Newbie 1 02-16-2005 10:36 AM
Screen doesn't scroll upwards when in console mode under vesafb fsateler Debian 6 12-10-2004 07:49 PM
HP Pavilion notebook: Full screen in console mode Minoru Linux - Hardware 2 08-14-2003 06:53 AM


All times are GMT -5. The time now is 05:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration