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 6770805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:21:24+00:00 2026-05-26T15:21:24+00:00

I am writing a simple script which restarts a hadoop slave. In the script,

  • 0

I am writing a simple script which restarts a hadoop slave. In the script, I have to do some initial changes as a root user. After that I have to change to user “hadoop” and perform set of commands. I was using os.system to run commands but I doubt whether it works well. For example:

uid=pwd.getpwnam('hadoop')[2]
os.setuid(uid)
os.system('whoami')
os.chdir('/home/hadoop/hadoop/')
os.system('bin/hadoop-daemon.sh stop tasktracker')

Again I have to perform some commands as root after this and again become user “hadoop” and execute :

os.system('bin/hadoop-daemon.sh stop tasktracker')

I have three questions here ,

  1. Is os.system is the best command that I can use to issue linux commands ?

  2. I am able to change from root user to user hadoop by the commands above but I am not able to change to root user (I can understand there will be security issues if they permit this, I want to know is there any possibility to do that , atleast by passing password) ?

  3. Does os.setuid() work ? whoami prints user hadoop but the process “tasktracker” is not stopped using those command, but if i perform the same commands manually it works fine (I use “su hadoop” instead of setuid while trying it out manually).

Thanks for all your help.

  • Sethu
  • 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-26T15:21:24+00:00Added an answer on May 26, 2026 at 3:21 pm

    you could use:

    os.system('sudo -u hadoop bin/hadoop-daemon.sh stop tasktracker')
    

    or if you dont have sudo, but have su

    os.system('su hadoop -c "bin/hadoop-daemon.sh stop tasktracker"')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a simple shell script which changes the mac address of the
I am writing a simple script that displays a dialog box when a user
I am writing a simple shell script which requires a root privilege. Using the
I'm writing a simple script, that just connects to telnet port, listens everything on
I am writing a simple GreaseMonkey script that has a jQuery plugin called hoverIntent
I have written this short script (which I've stripped away some minor detail for
I'm having problems with this getopt() code in a script that I'm writing which
I've been writing a simple PHP script which is supposed to generate a RSS
I'm writing a script in Python that will allow the user to input a
I'm very new to Ruby. I've recently finished writing a simple script, which uses

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.