Run Command as Other Users on Linux

Windows Articles

How to use modprobe command?

The modprobe command is a Linux administration system created for management, visualization, inclusion and exclusion. From loadable modules to kernel. Also, the Module is...

Install Virtualmin on CentOS 8

Hello, friends. In this post, you will learn how to install Virtualmin on CentOS 8. In addition to that, we will leave it ready...

Different ways to open File Explorer in Windows 10

Hello! Certainly the archive scan is an essential element when it comes to controlling the contents. It is even so important, that there are...

How to setup WireGuard VPN with ubuntu 20.04

Here, we will learn today how to configure WireGuard VPN with Ubuntu 20.04. Wireguard® is an amazingly straightforward yet quick and present-day VPN that...

How to Unlock the Bootloader on Xiaomi devices

Greetings dear readers, this time we bring you an easy guide on how to unlock the Bootloader on Xiaomi devices. The Bootloader in a...

In Linux, there are a number of situations where running a certain command as another user is necessary. It’s especially true in the professional/enterprise environment where there are a number of users. This method is also useful if one user doesn’t have any particular shells.

Running command

For performing the action, you have to follow the following structure –

su -s <shell_path> <user_name> -c <command>

For example, I have Apache installed and there’s a PHP file at the location “/var/www/html”. In order to run the file as user “viktor”, the following command will be necessary –

su -s /bin/sh viktor -c "/usr/bin/php /var/www/html/php_demo.php"

Enjoy!

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

How to use modprobe command?

The modprobe command is a Linux administration system created for management, visualization, inclusion and exclusion. From loadable modules to kernel. Also, the Module is...

Install Virtualmin on CentOS 8

Hello, friends. In this post, you will learn how to install Virtualmin on CentOS 8. In addition to that, we will leave it ready...

Different ways to open File Explorer in Windows 10

Hello! Certainly the archive scan is an essential element when it comes to controlling the contents. It is even so important, that there are...

How to setup WireGuard VPN with ubuntu 20.04

Here, we will learn today how to configure WireGuard VPN with Ubuntu 20.04. Wireguard® is an amazingly straightforward yet quick and present-day VPN that...

How to Unlock the Bootloader on Xiaomi devices

Greetings dear readers, this time we bring you an easy guide on how to unlock the Bootloader on Xiaomi devices. The Bootloader in a...
x