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

  • Home
  • SEARCH
  • 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 4028094
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:10:41+00:00 2026-05-20T11:10:41+00:00

I need to execute a command which is needed to run as root. I

  • 0

I need to execute a command which is needed to run as root.

I read some post about using hard-coded passwords in scripts could be insecure, but actually I don’t care because I’m providing root password to users anyway. It’s an stripped system and there’s only 2 users: client and root, so avoid warning me about security issues, Go ahead and give a quick and dirty solution.

For this bash script I need to
get as superuser using su,
then “my command”,
and then logout.

I don’t want the terminal prompt to type the password myself, instead read the password that I’m providing somewhere in script and run the command. It’s a priority to not prompt any input by user.

Alternatively, maybe I could install sudo, but is there any chance to run a command without any prompt of password (editing sudoers or something)?
What about of using expect?

Update: I forgot to say that is also a portable SO, used for USB sticks (maybe later for CDLive too), as you know, in some distros of this kind is provided a root password if users needed. The command mentioned before is a package extensions for some application install, and only root have privilegies to execute such command (I have to say it’s not a apt-get install or rpm command, so don’t worry about this).

  • 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-05-20T11:10:41+00:00Added an answer on May 20, 2026 at 11:10 am

    If you want a command to be runnable with no password, set that specific command as runnable with no password in your /etc/sudoers file (limiting the arguments to only the specific ones you wish to allow, if your use case allows that limitation).

    This is as simple as setting the NOPASSWD: flag for the relevant sudoers entry.

    If you really, really don’t care about security, it could be as simple as this:

    %admin ALL=(ALL) NOPASSWD: ALL
    

    (after putting sudo-capable users in the admin UNIX group)

    …or, if you did care, you could do something specific:

    someuser ALL = NOPASSWD: /usr/local/sbin/my_admin_command
    

    Note that if these commands will be run with no user present, they also may not have a TTY assigned; in such a case, you must be sure that your sudoers file doesn’t contain the (oft-present-by-default) line:

    Defaults requiretty
    

    …or that the effect of this default is being specifically discarded by the line granting permissions.

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

Sidebar

Related Questions

I need to execute the given commands as root and sudo user using Java.
I need to execute this Sql command (which works fine in management studio): select
I need to execute a command 100-200 times, and so far my research indicates
I need to execute some commands in batch mode (e.g., via Rscript). They work
I need execute some code before Windows shutdown process each time. So, I want
I need to execute the less command, with paging, from my Java console application.
I am playing about with the IQueryProvider.Execute command and am passing in an expression
I need to execute a SELECT ... from Sybase's command line tool, FSQL ,
I'm developping my first Android App. I need to execute a command in a
I need to execute from Java a batch script, which does following 1) Once

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.