Lock Raspberry Pi From Command Line

Lock Raspberry Pi from Command line

A lot of people use Raspberry Pi as their desktop to replace their computers. The usage of Raspberry Pi as a desktop is also increasing in the life of people. Some people work at a place where if they leave their system then there is a high probability that other people can use their system. It might make the safety of the data in the danger that would be the breach of the security of the data. In this blog, one can learn the process of lock Raspberry Pi from the command line in an easy way. 

Numerous people are aware of the lock screen to make their system lock at their command. It provides safety to the data of the user that can make profits for the user. If the user is accessing the Raspberry Pi headerless or in command line mode and they are not logged in, then anyone who has access to it will need to log in to the system. One needs to lock their system as they do with their PC to protect their data from other people.

Steps to lock Raspberry Pi from the command line

If one needs to leave their system of Raspberry Pi then they need to apply a lock system to make it safe. The lock screen is installed by default but it does not represent on the menu. There are following steps one should do to for the security of the data

1. Open a terminal window, and type in*:

             sudo nano /etc/xdg/lxpanel/LXDE-pi/panels/panel

Lock your raspberry Pi

2. Scroll down (using the cursor keys) to the section that starts:

              Plugin { 


raspberry Pi Lock trick

3. Move to the end if this section, and type in (or copy/paste) the following:

   item { 



   action=/usr/bin/dm-tool lock 


Lock Raspberry Pi using Command

4. The user need to then save the file by typing Ctrl+x (the Ctrl key, with x), then ‘y’ to the prompt to save, and the Enter key and reboot the system. The user will now see a new item at the bottom of the menu.

5. Now the system is ready for the locking process. If one needs to lock their Raspberry Pi then they just need to click on the lock. It will provide safety to the data of the system.

6. One can write their password on the screen window to open the system. One should not share this password with anyone for the protection of the data. 

Note: On older versions of Raspbian, you may find the configuration file in ~/.config/lxpanel/LXDE-pi/panels/panel instead.


1 thought on “Lock Raspberry Pi From Command Line


Please share voice lock and unlock raspberry pi article

October 1, 2020 at 08:31am

Leave a comment

Your email address will not be published. Required fields are marked *

Please note, comments must be approved before they are published