Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7897721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:14:24+00:00 2026-06-03T08:14:24+00:00

I want to use sudo to mount two separate network drives on an ad-hoc

  • 0

I want to use sudo to mount two separate network drives on an ad-hoc basis as my NAS device is not always on line, so I am not convinced that adding anything to /etc/fstab is necessary.

The following code is able to achieve this, however I do not intend to run the script from a terminal, thus the sudo password prompt is my issue:

#!/bin/sh

sudo mount -t cifs //10.1.1.9/Volume_1 /media/DNS323-A -ousername=user,password=pass,iocharset=utf8
sudo mount -t cifs //10.1.1.9/Volume_2 /media/DNS323-B -ousername=user,password=pass,iocharset=utf8

I need to select “run in terminal” to be able to successfully run that script from a file browser window. Thus I would prefer to use gksudo, which will open a prompt window for me to enter the sudo password.

However, if I instead use the following code I have to type the sudo password twice!

gksudo "mount -t cifs //10.1.1.9/Volume_1 /media/DNS323-A -ousername=user,password=pass,iocharset=utf8"
gksudo "mount -t cifs //10.1.1.9/Volume_2 /media/DNS323-B -ousername=user,password=pass,iocharset=utf8"

At this point I tried to be smart and use the gksudo option to “run as sudo” as follows,
however only the first drive is mounted like the first script above would fail silently if not run from a terminal:

gksudo -S "mount -t cifs //10.1.1.9/Volume_1 /media/DNS323-A -ousername=user,password=pass,iocharset=utf8"
sudo "mount -t cifs //10.1.1.9/Volume_2 /media/DNS323-B -ousername=user,password=pass,iocharset=utf8"

What I’d really like to be able to do is the following, but I’m not sure if it’s possible:

gksudo this{
command1
command2
command3
}

Is it just me or does gksudo have a short memory?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T08:14:25+00:00Added an answer on June 3, 2026 at 8:14 am

    this is a script, so the best way would be not to have the sudo/gksudo commands in the script, but call the script using sudo.

    I don’t think gksudo has any memory itself, that’s all sudos doing which is being used in the background.

    another possiblitiy would be to use:

    gksudo "sh -c 'command1; command2; ...'"
    

    but that’s not very elegant.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to install mysql in my Ubuntu 11.10. I use sudo apt-get install
I want to use the LinkedIn gem But not the one that I get
I want use groovy findAll with my param to filtering closure filterClosure = {
i want use some data from a website with web service. i have a
I want use JQuery mobile for the front-end of my mobile application, but I
I want use jQuery in my project. I know the javascript_include_tag calls the jQuery
I have a transaction log file in CSV format that I want use to
I have a easy select tag: <select> <option></option> <option></option> </select> Then I want use
I want to use ADO.NET Prepare command will increase performance if query is repeatevely
I want to use netlink to communicate between an application and kernel space. My

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.