Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have to start an application with my own user rights, but the group must be different. So, instead of:

$ ps -eo "user,group,args" | grep qbittorrent
morfik   morfik      /usr/bin/qbittorrent

it should be for example:

$ ps -eo "user,group,args" | grep qbittorrent
morfik   p2p      /usr/bin/qbittorrent

It also has to be done without asking about password. Is there a way to achieve this?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

Use sg.

For example, the following command will invoke sleep for group group-name

sg group-name -c 'sleep 100'

From the man page:

NAME
   sg - execute command as different group ID

SYNOPSIS
   sg [-] [group [-c ] command]

DESCRIPTION
   The sg command works similar to newgrp but accepts a command. The
   command will be executed with the /bin/sh shell...
share|improve this answer
    
Pretty simple, and it works. :) –  Mikhail Morfikov Feb 3 at 1:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.