LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   gnome-terminal will not execute commands after a su (switch user) command (https://www.linuxquestions.org/questions/linux-newbie-8/gnome-terminal-will-not-execute-commands-after-a-su-switch-user-command-4175612207/)

joshjoshjosh 08-18-2017 11:39 AM

gnome-terminal will not execute commands after a su (switch user) command
 
Hello!
I am executing: gnome-terminal --execute su - ..... --execute cd /home/test

After the gnome-panel executes the su to another profile it ignores any later execute commands. Is there anyway to execute commands after a switch user command?

Thanks!

rtmistler 08-18-2017 01:24 PM

Can you do what you wish using sudo as opposed to su?

joshjoshjosh 08-18-2017 01:41 PM

No.

Turbocapitalist 08-18-2017 01:48 PM

Check the manual page again:

Quote:

--execute CMD ARGS, -x CMD ARGS

Executes the command CMD with its arguments ARGS on startup. No arguments beyond this one will be processed by the terminal. This behaviour mimics the xterm -e behaviour.

Only one --execute option is allowed because everything after the first one is ignored by gnome-terminal.

So if you are using su instead of sudo then you'll need to pay attention to the -c option.

Code:

gnome-terminal --execute su -l -c '...; ...; cd /home/test;'
See

Code:

man gnome-terminal
man su


hazel 08-18-2017 02:18 PM

It's not a good idea to use either su or sudo in a big desktop environment like gnome. These desktops are held together by a slew of XDG environmental variables that can get corrupted if they are exposed to root ownership. Use gksudo instead.

Turbocapitalist 08-18-2017 02:20 PM

Quote:

Originally Posted by hazel (Post 5749721)
It's not a good idea to use either su or sudo in a big desktop environment like gnome. These desktops are held together by a slew of XDG environmental variables that can get corrupted if they are exposed to root ownership. Use gksudo instead.

Adding the -H option in sudo should do the same.


All times are GMT -5. The time now is 05:55 AM.