Unlock screen from command line
Go to TTY and run the command:
sleep 5; xdotool type <yourpassword>; xdotool key Return
and then go back to the login screen and click in the password box. Wait ~5 secs and your password will be typed and enter will have been pressed.
My pronouns are He / Him
kbenoit
Back in 2000, while studying CS in college, I was not happy with the Micro$oft attitude. So I took a year off and discovered Linux that gave me an interest to return studying CS. So I did search the University that was the most Linux oriented. In my first week, at Sherbrooke University, I was hired to maintain Linux in the Lab. Later I applied for an internship with Karim Yaghmour, the author of Building Embedded Linux Systems, that got me involved in Kernel Development. I used a few distros, my own (LFS) among others, but actually feel happy with using Ubuntu as my main OS, since about 2006.
Updated on September 18, 2022Comments
-
kbenoit over 1 year
I was using virtualbox on a laptop and closed the lid which locked the screen and sleep the computer. Now it came back from sleep, the screen is locked, but I can not type my password. The mouse work, I can set focus in the password box, but typing does nothing.
I guess the keyboard is held by virtualbox.
I tried plugin in a keyboard, no luck. I tried killing unity-panel-service --lockscreen-mode, it seems to have a watchdog that restart it.
I'll find some command line to sleep my vm, but is there anyway to unlock the screen from command line ?
-
kbenoit over 9 years"vboxmanage controlvm <VMName> savestate" -- saves the state of the vm then in my case I have no other work in progress so I just restarted lightdm.
-
Aquarius Power over 9 yearshave you tried to SIGSTOP vbox?
-
-
kbenoit over 9 yearsYou can normally set your DISPLAY variable to access you X session from a virtual terminal, but to be helpful, there should be a command to tell unity to unlock the screen.
-
sbergeron over 9 yearsbut without accessing a terminal from that specific x session i don't think it's possible
-
kbenoit over 9 yearsSounds good, but it refuse my password ???
-
kbenoit over 9 yearsOne should use "read pwd < /dev/stdin", type your password then use $pwd in place of <yourpassword> so that your password is not saved in history or use HISTIGNORE.
-
kbenoit over 9 yearsxdotool type abcdefghijklmnopqrstuvwxyz ouput qbcdefghijkl~nopqrstuvwxywcq ? But works fine on some other computer. That one was installed in french, the installer set a few things fr_FR instead of fr_CA. This seems to be the problem.
-
kbenoit over 9 yearsType ctrl-alt-F1, log in, type "export DISPLAY=:0". This terminal is now the same as a terminal inside you X session, you can start X programs and they will appear in the virtual terminal at ctrl-alt-F7. To ensure you are allowed to access the session, the file $HOME/.Xauthority contains the credentials needed to access a particular X instance.
-
JellicleCat over 7 yearsWhy does this work when entered on a shell but not when run from a script in
/lib/systemd/system-sleep
? -
Tim over 7 years@JellicleCat I guess because no x screen is attached to systmd?
-
JellicleCat over 7 years@Tim : thanks. With your guidance, I incorporated this answer to successfully use xdotool on the login screen from
system-sleep
: stackoverflow.com/a/10721288/507721 -
JellicleCat over 7 yearsAdditionally, in my script, I needed to run
xdotool
as my own user, not as root (which matters becausesystem-sleep
's scripts run as root.