Linux - DesktopThis forum is for the discussion of all Linux Software used in a desktop context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm running Kubuntu, so it is "Konsole", not "Terminal" on my box. I need a bash script that does the following:
Kills any current Konsole sessions,
Guessing it is the cmd: myvar < ps -A | grep konsole && kill $myvar
Re-opens Konsole with 3 session tabs,
Logs each tab session into sudo mode for root
I need to register this in the Login Registry so I always have these 3
Konsole sessions open at the start of any login on my computer.
It's such a pain to have to manually do this every time I login.
Ideally, for security, the command will be:
Code:
bash /...path.../sudologin.sh mypass
which will also allow it's call at anytime and be used by any linux user and also allow, with the right symlink or rc registry, it to be called without the path name. Non KDE users will use "terminal" not konsole.
sounds like a lot to figure out, your side panel says you've been using Linux for at least 3 yrs now, what have you figured out so far, other then the steps of operation?
using a Konsole, or you can install a different terminal to work in so it does not kill that one while you're working on figuring out how to kill a current Konsole terminal. work out the steps in a cli then add to a script test, fix, repeat until you get it. one step at a time.
somethink like this to kill kill kill the terminals
Code:
ps ux | grep xfce4-terminal | xargs kill
xfce4-terminal --tab -T one
xfce4-terminal --tab -T two
xfce4-terminal --tab -T three
got a look up how your terminal you're going to use is used to do these things.
On the Redhat and Suse flavors of Linux the cli cmd:
Code:
kdesu konsole
works but on the debian and Ubuntu flavors the cli cmd:
Code:
konsole -e "su -"
is the working cmd for opening a new konsole session.
Since I'm attempting the opening of multiple tabs, needing the ktabs.txt file, not sure where to put this command set, in the ktabs.txt file or before it?
#! /bin/bash
# Script to login to SUDO mode
# CMD: bash /Scripts/Extras/sudologin.sh
# Get the current dir to enable return to it
curdir=$pwd;
cd "/Scripts/Extras/";
# kill the current konsole sessions
pkill konsole;
# Restart konsole in sudo mode with tabs from the file
konsole -e "su -" --tabs-from-file ktabs.txt
# Return to the starting dir
cd $curdir;
The problem here is when executed from Konsole the kill terminates the commands, so unless it is somehow stored in memory the remaining "restart" does not execute. I'm
adding this to a custom application launcher to get around this, but if you know the way to store this command set for continued execution it would be nice.
Out of curiosity I'm wondering if the "nohup" background run cmd will work?
I ran my code, both from a launcher and from an "F2" window piping to error file and got no errors, but also the 3 knosole sessions did not apprear, so there is something wrong with the code.
OK found the issue with the 3rd tab in the ktabs.txt file but now wondering if the sudo cmd needs to be in that file at the end of each tab line, since none of the sessions are coming up "SUDO"?
Thanks! Moving the -e to the end of the line, it now executes only I'm just only getting 2 tabs and none are in the sudo mode.
Cheers!
TBNK
Turbocapitalist,
I see in some HOWTOs that it's -c for a cmd instead of -e to execute, but my system runs the -e. My question then is should the -e be in the ktabs.txt file. And should that replace the:
Code:
command=/usr/bin/sudo -i /bin/sh
you showed in your script as that "command=/usr/bin/sudo -i /bin/sh" is not working. Also should it be the actual cli cmd of "sudo su -u root -p mypass"? That would have the end of each tab line of:
Code:
-e sudo su -u root -p mypass
So I tried that and no change not coming up SUDO!
I'm seeing this is one of those: "Hold your mouth just right!" situations! He He!
Would it be that my script needs to call another script the uses a for loop to find each konsole tab and execute the "sudo su -u root -p mypass" cmd on each tab?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.