Managing User Password Expiration with chage

I want to talk a little about a Linux tool called chage which should be available on most Linux distributions with base installation. Yes chage this is not a typo. It is a tool to view and change the user password expiry information. It can be used to list the current password status of a user and also to set the password expiry information. I encountered it when one day after installing some service on a Linux server it just refused to work as expected. The root cause of it all was the dedicated user’s password had expired. You can get the details of the user password expiry information by running sudo chage -l youruser. The output will look something like this: ...

February 23, 2025 · Andrius

Removing Local and Remote Git Tags

As I was experimenting with git tags, I ended up with a bunch of them that I didn’t need and I wanted to remove them all. One things to keep in mind is that tags similarly to branches can be local or remote. If you create tags but don’t push them then they’re just local and you can remove them using git tag -d tagname. You do need to specify the exact tag name to do that which you can get by listing all available tags with git tag. But removing them one by one can be tedious so you can combine the two mentioned commands into the following one-liner. ...

February 22, 2025 · Andrius

Using Git Tags and GitHub Workflow

Using git tags is quite easy and can be useful in setting up a simple CI/CD like pipeline i.e. streamlining the process of packaging or deploying your code. First thing you need to do is to create a tag in your git repo, you do this by running git tag v0.1.2 where v0.1.2 is your tag name, usually a version number or some other more human friendly identifier than a commit hash. It doesn’t have to start with v, but it’s a common to do so. Any tag creation that you do takes place on your local machine until you push it to the remote repo with git push --tags. ...

February 19, 2025 · Andrius

Redirecting Output of Multiple Commands

Sometimes when writing a script you want to redirect the output of multiple commands to a file. This is useful when debugging or when you want to generate a file that is the result of multiple commands. The naive approach is to redirect the output of each command to the file: echo "Hello" > file.txt echo "World" >> file.txt There are several issues with this approach. You have to make sure that the first redirect is > and the following ones are >> otherwise you will overwrite the file when you meant to append to it. As you write and tune your script this is a very likely mistake to make. Also you have keep repeating the same file name which is also error prone though this can be mitigated by introducing a variable and using that instead. Another thing is that it’s not very efficient because the file is opened and closed multiple times. It’s also not atomic, meaning that if the file is accessed by another process the results are unpredictable. ...

February 19, 2025 · Andrius

Getting Table Sizes in MySQL

Sometimes, like when evaluating an open source project, you might want to understand how the database entries grow based on your typical usage. This will allow you to find the hot tables i.e. the ones that grow the fastest and will help you plan ahead to make sure it scales. As this is something that would usually take place in a development environment or on a local machine you should have the root access to the database. The examples bellow assume your password is mypwd and schema name is schema1. ...

February 19, 2025 · Andrius

Creating Aliases for SSH Connections

Here’s a tip if you have some servers that you need to connect to often, especially if they have a long name and need a username that doesn’t match with the one on your local system, and even more so if you need to use an identity file, that is not the default one. The command would look something like this: ssh some_user@server1-qualifier.region.company.com -i ~/.ssh/server1_id_rsa` It’s possible to simplify this by creating an alias with all the required params in ~/.ssh/config file. Here’s how it would look for this scenario: ...

December 10, 2023 · Andrius

Copying OpenSSH Public Key

For the longest time to achieve passwordless login on a server I was doing the following: manually connected to the server created the .ssh directory if it didn’t exist created the authorized_keys file inside that directory and pasted the contents of previously copied public key crucial step was to set the correct permissions: 700 for the directory and 600 for the file But as with many things, there’s a script for that! It’s named ssh-copy-id and it’s part of the openssh package. Copying the public key to a server myserver is as easy as doing this: ...

December 9, 2023 · Andrius