HOME BLOG

Archive for the ‘Linux’ Category

How to view the output of a running background process in Linux

Posted on: November 10th, 2026 by Olu No Comments

Hi Folks,

In this post we talk about how to view the output of a background process while it is running in Linux. Why is this important? It could come in handy if you need to troubleshoot problems with a program that was started in the background by another program, especially when you’re dealing with third-party software where you can’t easily set up logging as you wish. The way to do this is to use the proc system.

First, find the process id. You can do this by running the following command

ps aux | grep "your program name"

This command will list all processes that match the name of the program you supply. You will also see the id of each process. Once you find the id of the process your program is running under, then use the tail command and proc system to access its output. Run a command like

tail -f /proc/<process id>/fd/1

Note that 1 represents stdout while 2 represents stderr. The tail command displays the last part of a file. The -f flag tells tail not to stop when the end of the file is reached, but to wait for more data to be appended to the input. This gives a streaming effect.

In case tail doesn’t work, you can use the cat command to view all contents of the file by running a command like

cat /proc/<process id>/fd/1

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

Resources

The /proc Filesystem. The Linux Kernel. https://www.kernel.org/doc/html/latest/filesystems/proc.html#proc-pid-fd-list-of-symlinks-to-open-files

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.