0

I am trying to execute ls after opening a new Guake tab and logging into postgres.

guake -n guake -e 'sudo -i -u postgres && ls' 

The command successful opens a new tab then prompts me for my password and logins into postgres, but it does not execute ls once in postgres.

How can I achieve this?

    1 Answer 1

    1

    Did you check manual page for sudo? The third synopsis example shows

    sudo [...] [-u user name ] [VAR=value] -i | -s [command] 

    the command part is the thing you are looking for. It is the command that is executed after changing user to the required one.

    This fits exactly into your example like this:

    sudo -u postgres -i ls 

    joining everything together with your original task:

    guake -n guake -e 'sudo -u postgres -i ls' 

      You must log in to answer this question.

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.