Today I’ve accidentally locked myself with Linux screensaver.

How this happened?

I use English letters for my password, but when I’ve stepped back from my Linux workstation my keyboard group was with group different than English.

As result when I come back and tried to unlock myself I couldn’t enter the correct password.


1. First and simplest solution will be to kill X with Crtl+Alt+Backspace

2. Reboot the PC – Alt+Ctrl+Del

3. Try to fix it

Because I’ve had open and unsaved documents first 2 options will result loss of my work I’ve decided to go with third one.

How I did it:

A requirement is to have another PC and ssh access to main one.

1. Login via ssh to locked PC.

2. Start vnc server under your account


Note you will need vnc server installed. How to do it is out of the scope – consult your documentation.

3. Open firewall ports required for VNC or simply shutdown firewall

/etc/init.d/iptables stop

4. On other PC start VNC client and connect to locked one

5. Start keyboard configuration


6. Remove all other layouts except English

7. Now you can return to locked PC and unlock it.

NOTE: This procedure was tested on LAN and CentOS 5.

Today I removed the user in my Linux workstation.

Probably you will say that this is simple task just remove user home directory and his password, but appears that this is not.

First thing is that there is no single command that will do this task for you.

Let’s start:

1. Lock user – this is done with following command:

passwd -l <user_name>

This command will achieve it by changing the password to a value that cannot be matched by any possible encrypted value.

This command is usefull also for temporary disabling user account.

2. Search for and kill any user processes that still run

ps aux | grep -i ^<user_name>

kill -9 <PID number>

where <PID number> is the number in the column just after the user name.

3. Find all files that belong to this user

find / -user <user_name>|less

4. Decision time – decide do you want to keep those files or erase them. My suggestion is to backup them just in case.

5. List and remove any crontab jobs

List user cron jobs:

crontab -u <user_name -l

And if you see any entries remove them:

crontab -u <user_name> -r

6. Remove user from sudoers (if you use sudo)


7. Check any other applications as remote access, MySQL, Web App.
More extended howto

← Previous Page