Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 10 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:

   sg - execute command as different group ID

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

   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 '14 at 1:50

Your Answer


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.