HOME BLOG

Archive for the ‘Linux’ Category

How to list all available verisons of a package on Redhat Linux

Posted on: June 18th, 2023 by Olu No Comments

Hi folks,

In this post I give a small tip on how to list all available versions of a package on Redhat Linux.

Command

yum --showduplicates list available <package-name>

E.g.

yum --showduplicates list available kernel-devel

That’s all for now. Till next time, happy software development.

How to be able to switch to another user without entering password

Posted on: September 17th, 2022 by Olu No Comments

Hi folks,

In this post I explain how to switch to another user in Linux without needing to enter a password.

You can do this with the PAM authentication module.

Edit /etc/pam.d/su

vim /etc/pam.d/su

 

Then enter the following lines

auth       [success=ignore default=1] pam_succeed_if.so user = the-username
auth       sufficient   pam_succeed_if.so use_uid user ingroup the-groupname

Save and exit the file.

This will allow you to switch to the-user if you belong to the-group without needing to enter the password for the user using a command like

 su - the-user

 

That’s all for now. Till next time, happy software engineering.

 

References

How to Switch (su) to Another User Account without Password. https://www.tecmint.com/switch-user-account-without-password/

How to use sudo command without password

Posted on: September 17th, 2022 by Olu No Comments

Hi folks,

in this post I discuss how you can use sudo command without password on a Linux system.

Back up your sudoers file

cp /etc/sudoers /etc/sudoers.old

Then, run visudo command

visudo

 

Then enter an entry like

your-user-name ALL=(ALL) NOPASSWD: ALL

 

Then, if visuo uses nano, press Ctrl X to save. Then press enter to finish the save.

Please note: it’s not good security pracrice to let a non-root user run sudo without passwords, so you may want to limit it to some specific commands.

That’s all for now. Till next time, happy software development.

 

References

How to Use sudo Commands Without Password in Linux. https://www.makeuseof.com/using-sudo-without-password/

How to find files in a folder while excluding those in certain subfolders

Posted on: March 11th, 2021 by Olu No Comments

Hi folks,

Recently in the course of work I had to find lots of files in a certain folder while excluding files in certain subfolders. I had to do a bit of research on how to do this in Linux-like environments. So I thought I’ll share.

So, let’s assume that in the current directory there are subdirectories s1, s2, s3, etc., each containing .txt files. Now assume you want to recursively find all .txt files in the current directory, but exclude all those in s2 and s3 subdirectories.

Here’s a command you can use to accomplish this using the find command.

 

find . -name '*.txt' -not \( -path './sub2/*' -o -path './sub3/*' \)

 

Note that the -o means OR logic. The \( and \) allows us wrap multiple conditions together to form a compound condition and the -not means NOT logic. Also of interest is the -path flag which allows you to match a pattern in the path of a file.

That’s all for now. Till next time, happy software development.