Monthly Archives: March 2022

Automatically creating a user and forcing password change on first login: A Linux scripting example

Sometimes there might be a need to make a test user really fast. Reasons may vary and we might want to make this as easy as possible for ourselves. We are of course thinking about adding our test user to sudo/wheel group and we have a our default password at mind that we will set to our test user.

However, we might want to force user to change the password during first login and be certain that our poorly chosen default password will not stay universal on possibly critical systems. Later, we also might want to lock the user account and possibly even delete it when there is no need to test anymore. Here is how do all this with some good old scripting:

https://github.com/postman721/scripting-examples/blob/main/auto_creation.sh

Adding backports to Debian stable

Sometimes there might come a situation where Debian stable is just too old. This is usually related to hardware support of some component that the computer has that has no current support on a kernel that Debian stable ships with. Kernel is a typical example but others may exist as well. Backports might be of help when trying to get some more support to hardware. However, before proceeding it is good to notice that backports might cause issues down the line if used too carelessly.

A typical case of an issue might be that when the next Debian stable eventually arrives upgrade might be tricky if you have some packages that are more recent than those Debian is offering. This used to be more of a big deal back in the day. Currently, I believe that backports generally do not provide any significant risk that could not be handled during upgrades. Caution is still adivised,

To add backports to Debian stable you need to do the add the following entry (as sudo or root) to your /etc/apt/sources.list or equivalent file under /etc/apt/sources.list.d folder structure:

deb http://deb.debian.org/debian bullseye-backports main contrib non-free

After the above line is added do: sudo apt-get update

Installing from backports is done by first locating the package you want to install. A good source for this is https://backports.debian.org/

When the package of choice is found, then the installation command will be, for example:

sudo apt install linux-image-amd64/bullseye-backports

On the above command, linux-image-amd64 is a metapackage that will install a more later kernel from Debian backports. Finally, to start using the later kernel, I would need to reboot my computer.

Adding more sources to PostX Gnu/Linux

All of the below should be done as root / sudo su . Caution is advised when operating as root or sudo su. Accidental and careless usage might be dangerous to system stability. Proceed with your own responsibility.

On a latest release of PostX Gnu/Linux contrib and non-free sources entries were accidentally left out. This will be fixed on later upcoming releases. For now you can add the following entries to sources list files:

deb http://deb.debian.org/debian bullseye contrib non-free
deb-src http://deb.debian.org/debian bullseye contrib non-free

deb http://deb.debian.org/debian bullseye-updates contrib non-free
deb-src http://deb.debian.org/debian bullseye-updates contrib non-free

deb http://security.debian.org/debian-security/ bullseye-security contrib non-free
deb-src http://security.debian.org/debian-security/ bullseye-security contrib non-free

Adding entries can be done manually by adding them into /etc/apt/sources.list. Alternatively, they can be added to file of your choosing under /etc/apt/sources.list.d directory structure.

For example you can make a file called patch.sh with the sources list content, as seen above, and make it executable with chmod +x patch.sh .

Finally, you can execute the patch.sh as follows: cat patch.sh > /etc/apt/sources.list.d/extra.list .

This will create a new file called extra.list under /etc/apt/sources.list.d folder. To apply changes to system, you still need to execute apt-get update. After this you are all done and new sources should be ready for usage.