Wednesday, December 3, 2008

To lock the screen as root user

Often i have encountered problem for locking screen , when logged in as root user in OS like RHEL4, RHEL3 etc

Later i found a method to lock the screen as follows
Create one normal user and set some password for the user

open a file (say lock)
open the file using some editors
add content as follows
USER=normal_user_created
xhost +
su -c xscreensaver - $USER &
su -c "xscreensaver-command -lock" - $USER
xhost -



After that give executable permission for the file using
chmod +x lock


move the file to some directory such as /bin or /sbin, so that the command will be in PATH variable

For RHEL5,CentOS5 i had to modify the script little bit to make it work
Changed content as follows

USER=damodar
xhost +
su -c gnome-screensaver - $USER
su -c "gnome-screensaver-command -l" - $USER

No comments:

Post a Comment