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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:42:58+00:00 2026-06-15T12:42:58+00:00

When I run commands from the console everything is OK: sudo -u oracle fgrep

  • 0

When I run commands from the console everything is OK:

sudo -u oracle fgrep ...

When I run the same command from Java code using ProcessBuilder, sudo doesn’t work, and I need to set chmod to 775 or else I don’t have permission to read logs.

Why doesn’t this work? Is there an option to read logs without chmod 775?

Here is how I am using ProcessBuilder:

ProcessBuilder pb = new ProcessBuilder("bash", "-c", command);
Process shell = pb.start();

InputStream is = shell.getInputStream();
  • 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-15T12:43:00+00:00Added an answer on June 15, 2026 at 12:43 pm

    Since you say chmod 775 for log file it works, it’s obvious your process doesn’t have permission.

    You can run your java with sudo:

    sudo java ClassFileName
    

    Or just add sudo as the first string in the array that you pass to bash process:

    command[0]="sudo -u oracle ";
    
    //command[1]=commandname;
    
    //command[2...n]=Other params;
    

    Assuming user oracle is in sudoers list and won’t ask for password, this will run just like how it runs in commandline when you use sudo.

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

Sidebar

Related Questions

I am using execv() to run commands from /bin/ such as 'ls', 'pwd', 'echo'
I'm trying to run various commands using psexec.exe from Windows Sysinternals . What I
Im trying to SSH from Java to a server and run multiple commands. the
In oracle database, command host can be used to run bash command from database
I baked an application using console and from URL everything seems ok. But when
I want to be able to input java commands/code to execute during run-time (during
I have the following problem: I have to run commands on remote servers from
I run this command : select * from LIST where JCODE = 8 and
Possible Duplicate: Can I run from command line program created by Eclipse? I am
I want to run the following command from a C program to read the

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.