Monday, November 06, 2017

How to set a PIN password or a short password in Ubuntu Linux

If you are looking for a way to a PIN password or a short password in Ubuntu Linux, similar to Windows 10, you've come to the right place.
The way described here changes only the desktop login (lightdm service), but can be applied to other services as well if you wish.
Also, this allows you to have your original strong password for "sudo", while maintaining a fairly easy way to login to Ubuntu desktop.
Commands can be issued in the terminal program.


First of all, make sure you have installed the libpam-pwdfile package:
sudo apt-get install libpam-pwdfile

Creating the user/password file

You will be prompted to enter a new PIN password.
Your password will be encrypted and saved to a file named ""

pinpass=$(mkpasswd -5)
echo "$pinpass" | sudo tee /etc/

You will see the encrypted pin password echoed in the terminal. This password will be written to the /etc/ file.

Alternatively, you may use:
openssl passwd -1 yourpinpasswordhere

Setting up the desktop login service

The next step is to prepare the desktop login service to accept the PIN password before other password procedures. I've mentioned already the name of the desktop login service, lightdm .

Take a look at the file:

cat /etc/pam.d/lightdm

If you don't have this file, then your desktop (login) service is a different one, and you should find your desktop manager before going further. As explained before, this guide is for Ubuntu 16.04 but can be used for other login services as well.

It could be useful if you also create a backup:

sudo cp /etc/pam.d/lightdm /etc/pam.d/lightdm.backup

Now, you may edit the file using nano or gedit or any other  text editor:
sudo gedit /etc/pam.d/lightdm

At the top of the file mine had:

auth    requisite
auth    sufficient user ingroup nopasswdlogin
@include common-auth

I have modified it like so:

auth requisite
auth sufficient user ingroup nopasswdlogin
auth required pwdfile=/etc/
auth required
@include common-auth

Save the file and close your text editor.

Log out and log back in.

You should be able to use the PIN password you set. By following this guide, the PIN password is only used for the desktop login service, not for the password of sudo commands.

This is a modified guide based on a pam pwdfile guide for vsftpd at:

Monday, August 24, 2015

How to issue a time resynchronization in Windows - cmd/batch

 Hello again, I'm back. I found some spare time to add some updated tricks concerning technology, and general tips for Windows or GNU/Linux. :)

I've been having some problems with the time synchronization in Windows 7, which required more often synchronization. So after some googling around, I came up with this little batch commands:
echo Current date/time: %date%_%time%
%windir%\system32\sc.exe start w32time task_started
%windir%\system32\w32tm.exe /resync
echo Fixed date/time: %date%_%time%

Save it as a .bat file and run it as an administrator (right-click on file > Run as administrator).
It's nothing much, pretty dirty scripting I confess, but it does get the job done, at least in my case. I hope it will help someone else too.

See ya!

Thursday, October 11, 2012

Icon 'gtk-close' not present in theme

I recently started to use screenlets again, especially FreeMeteo for weather forecast. But on ubuntu 12.04 every time I login I get a crash message: crashed with GError in load_buttons(): Icon 'gtk-close' not present in theme

If you have a similar crash message, you can simply install the gnome-icon-theme-full package which contains the gtk-close.png file.


Kernel mainline ppa downloader (aka kmpd / kmp-downloader)


kmp-downloader is a simple program that allows you to install fresh new kernel versions from the ubuntu kernel mainline ppa.

As it is, the mainline is not an actual "ppa" (personal package archive) and doesn't allow people to use apt-get to upgrade.


You may need python beautifoul soup (python-bs4) or execute:
sudo apt-get install python-bs4

How to use it

You may download it using this quick link:

Save the archive and extract the files. Double click on (execute in terminal). If you're not sure about an option, press Enter and it will select the default answer.

You may also execute this command (one-liner):

cd /tmp; rm -rf medigeek-kmp*; wget --no-check-certificate -O kmpd.tar.gz; tar xzf kmpd.tar.gz; cd medigeek-*; python

You will be asked a series of questions, where you either reply by "Y" or "N" (yes or no) or simply press enter and let the program figure out the default reply (mentioned in square [] brackets). It will then install the appropriate debian packages.

Note: it will not fix the problems with other packages. I suggest running linux ppa packages without dkms package (without closed source packages like nvidia driver or virtualbox driver), in order to have a smooth, errorless installation.


To uninstall the kernel packages, remember to boot to a different kernel image first. Then you can use your favourite package manager to uninstall the packages.

If you prefer the command line, if you installed version 3.5.3, you can uninstall it using this command:

sudo apt-get purge linux-image-3.5.3.* linux-image-extra-3.5.3.* linux-headers-3.5.3.*

Thursday, July 26, 2012

python: download url to file with progress bar

This is an alternative answer for a question on stackoverflow:

I modified the answer a bit, using .format instead of % string formatting and sys.stdout.write(), and posted it on gist github:

# Improve
# (using .format() instead of % string formatting)

import sys
import urllib2

file_name = url.split('/')[-1]
u = urllib2.urlopen(url)
f = open(file_name, 'wb')
meta =
file_size = int(meta.getheaders("Content-Length")[0])
print("Downloading: {0} Bytes: {1}".format(url, file_size))

file_size_dl = 0
block_sz = 8192
while True:
    buffer =
    if not buffer:

    file_size_dl += len(buffer)
    p = float(file_size_dl) / file_size
    status = r"{0}  [{1:.2%}]".format(file_size_dl, p)
    status = status + chr(8)*(len(status)+1)


I'm using this solution for the kernel mainline ppa downloader: