LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-18-2017, 11:39 AM   #1
joshjoshjosh
LQ Newbie
 
Registered: Aug 2017
Posts: 6

Rep: Reputation: Disabled
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!
 
Old 08-18-2017, 01:24 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,320
Blog Entries: 13

Rep: Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372
Can you do what you wish using sudo as opposed to su?
 
Old 08-18-2017, 01:41 PM   #3
joshjoshjosh
LQ Newbie
 
Registered: Aug 2017
Posts: 6

Original Poster
Rep: Reputation: Disabled
No.
 
Old 08-18-2017, 01:48 PM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,617
Blog Entries: 3

Rep: Reputation: 2871Reputation: 2871Reputation: 2871Reputation: 2871Reputation: 2871Reputation: 2871Reputation: 2871Reputation: 2871Reputation: 2871Reputation: 2871Reputation: 2871
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
 
Old 08-18-2017, 02:18 PM   #5
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 5,502
Blog Entries: 16

Rep: Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263Reputation: 3263
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.
 
Old 08-18-2017, 02:20 PM   #6
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,617
Blog Entries: 3

Rep: Reputation: 2871Reputation: 2871Reputation: 2871Reputation: 2871Reputation: 2871Reputation: 2871Reputation: 2871Reputation: 2871Reputation: 2871Reputation: 2871Reputation: 2871
Quote:
Originally Posted by hazel View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute commands in new created terminal. selvavinayak88 Linux - Newbie 2 05-23-2016 07:22 AM
How to make a normal user execute commands of the super user's .?.. siranjeevi Linux - Server 1 07-03-2010 03:51 AM
[SOLVED] How to get gnome terminal execute different commands from diff. tabs? kusti85 Linux - General 2 01-06-2010 05:16 PM
Execute a command in all tabs in gnome-terminal ganesh_k Linux - Newbie 3 11-01-2008 11:11 AM
Execute terminal commands from .desktop files tuculover Linux - Newbie 6 10-22-2004 05:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration