Results 1 to 5 of 5

Thread: Linus script help

  1. #1
    Premium Lager

    Join Date
    Jan 2008
    Age
    60
    Posts
    4,882
    Thanks
    1,635
    Thanked 2,711 Times in 1,230 Posts
    Rep Power
    1174
    Reputation
    40746

    Default Linus script help

    Hello, I have a very simple script I run to open my GUI file manager as root "elevated privileges" but as it stands now I have run it in a terminal then manually enter roots password.

    it is just

    Code:
    sudo nemo
    I run this script from a desktop shortcut on linux mint and then the "run in terminal/display/cancel/run" window pops up. I select "run in terminal" and then a terminal window pops up and asks for the su password. I enter that and then the nemo filemanager opens with root privileges.


    what would be needed to add to the script to pass the root password automatically so as all I need to do is run the script and select run in terminal.

    using "run" does not work, nothing happens.


    thanks
    __________________________________________________ __
    Statistically, if you wait long enough, everything will happen!



Look Here ->
  • #2
    Shut your dog up!!
    Jma's Avatar
    Join Date
    Feb 2013
    Location
    Somewhere in the darkness...
    Posts
    509
    Thanks
    442
    Thanked 431 Times in 216 Posts
    Rep Power
    322
    Reputation
    8540

    Default

    Hello,

    From here -

    Code:
    There is a very neat trick in every Linux which will allow you to do so. It is called the SetUI bit.
    
    Keep in mind that you will need to have the permissions locked down tight in this file for this to be secure.
    
    Make the file owned by root and group root:
    
    sudo chown root.root <my script>
    Now set the SetUID bit, make it executable for all and writable only by root:
    
    sudo chmod 4755 <my script>
    Keep in mind if this script will allow any input or editing of files, this will also be done as root.
    
    The SetUID bit makes a script or binary always run as the owner of the file/binary, an example of such a binary is 'passwd'.
    
    There is a solution using sudoers here is an example you could use:
    
    Cmnd_Alias        CMDS = /path/to/your/script
    
    <username>  ALL=NOPASSWD: CMDS
    Now just place sudo in front of your script and it should run without asking for a password.
    I've never tried that but I have edited the sudoers file to stop the need for a password having to be entered in Terminal when required.

    Did that by:
    In the sudoers file change the line:
    Code:
    %sudo ALL=(ALL) ALL
    to
    Code:
     %sudo ALL=(ALL) NOPASSWD: ALL
    Logout then back in again.

    Good luck.

  • The Following 2 Users Say Thank You to Jma For This Useful Post:

    mickstv (19-11-17),tristen (17-11-17)

  • #3
    Premium Lager

    Join Date
    Jan 2008
    Age
    60
    Posts
    4,882
    Thanks
    1,635
    Thanked 2,711 Times in 1,230 Posts
    Rep Power
    1174
    Reputation
    40746

    Default

    Ok thanks I will look at it and see how I go. many thanks
    __________________________________________________ __
    Statistically, if you wait long enough, everything will happen!

  • #4
    Senior Member
    mickstv's Avatar
    Join Date
    Jan 2010
    Age
    51
    Posts
    4,173
    Thanks
    2,225
    Thanked 2,404 Times in 1,392 Posts
    Rep Power
    681
    Reputation
    18426

    Default

    I use Manjaro, but what I suggest should work with your distro.

    First make sure gksu is installed.

    Run once in terminal gksu nemo it should ask for your root password then an option comes up to save to keyring.

    Once done the command gksu nemo should always open nemo as root (superuser) without the need for the password.

    You can create a launcher icon on the desktop and include the gksu nemo command.


    EDIT. It might only work on the mate desktop. I just tried on peppermint 6 and it didn't work.
    Last edited by mickstv; 19-11-17 at 05:31 PM.

  • The Following 2 Users Say Thank You to mickstv For This Useful Post:

    porkop (20-11-17),tristen (19-11-17)

  • #5
    Senior Member

    Join Date
    Apr 2011
    Location
    Gold Coast
    Posts
    1,504
    Thanks
    1,879
    Thanked 1,590 Times in 726 Posts
    Rep Power
    767
    Reputation
    27988

    Default

    Some changes to Jma's approach. You can put the following in sudoers:

    Code:
    yourusername ALL=(root) NOPASSWD: /usr/bin/yourprogram
    Replace yourusername with your actual username and /usr/bin/yourprogram with the full path to the program you want to run.

    This will allow your user to execute only yourprogram as root without a password.

    This line must be below any other line in the sudoers file that affects your user, even as part of a group. I don't have Mint setup to try it. But on Manjaro the sudoers file has an include line right at the end which includes files in /etc/sudoers.d. One of these files was giving members of the group wheel access to all with a password. As my user was a member of wheel and this was included at the end it overrode the nopasswd directive earlier in the file.

    Good luck.

  • The Following User Says Thank You to DB44 For This Useful Post:

    Jma (01-12-17)

  • Bookmarks

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •