Find the answer to your Linux question:
Results 1 to 6 of 6
I downloaded a firefox linux package uncompress it and put it under my home dir when I 'cd' into firefox and run the following command with my user account "esolve" ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2012
    Posts
    85

    strange problem with sudo -u


    I downloaded a firefox linux package
    uncompress it and put it under my home dir
    when I 'cd' into firefox and run the following command with my user account "esolve"
    Code:
    ./firefox
    it works fine
    but when I switch to root account, and run
    Code:
    sudo -u esolve ./firefox
    I see the errors below, and firefox can't be opened, THEN I tried to modify the package owner: chown -R esolve:esolve firefox, the error persists and firefox still can't be opened
    Code:
    Error: Access was denied while trying to open files in your profile directory
    if I just run it as root account, there will be errors but firefox can still be opened

    I tried the same version of firefox package in another linux machine before and when I'm with root account
    "sudo -u esolve ./firefox " works fine
    what is wrong with this? it is strange
    BTW, the user account esolve was created by useradd
    maybe this is a problem? coz when I open the terminal, the default shell is /bin/sh
    I have to mannually change SHELL=/bin/bash, and even if I put a .bashrc with such a line under homedir,
    the .bashrc.doesn't seem to work


    coz I need to use "sudo -u esolve ./firefox " in a script, otherwiser I will just switch to esolve and run ./firefox
    so I hope to deal with this error
    Last edited by esolve; 11-14-2012 at 11:33 AM.

  2. #2
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,844
    sudo -u mean 'run as another user', take a look at the sudo man page.

    The syntax should be
    Code:
    sudo -u <username> <application>
    which is what you have in the other examples you've provided. If you don't want to provide a username, then drop the '-u' argument altogether.
    Linux user #126863 - see http://linuxcounter.net/

  3. #3
    Just Joined!
    Join Date
    May 2012
    Posts
    85
    sorry, my original post ignored the username, now I have modified it, I used sudo -u <username> <application>

  4. #4
    Linux Newbie
    Join Date
    Jun 2012
    Location
    SF Bay area
    Posts
    148
    If you're already "root" you don't need to use "sudo" to execute a program as another user. You can just use "su esolve -c firefox".

  5. #5
    Linux Engineer
    Join Date
    Apr 2012
    Location
    Virginia, USA
    Posts
    880
    Quote Originally Posted by esolve View Post
    BTW, the user account esolve was created by useradd
    maybe this is a problem? coz when I open the terminal, the default shell is /bin/sh
    I have to mannually change SHELL=/bin/bash, and even if I put a .bashrc with such a line under homedir,
    the .bashrc.doesn't seem to work


    coz I need to use "sudo -u esolve ./firefox " in a script, otherwiser I will just switch to esolve and run ./firefox
    so I hope to deal with this error
    What distro are you running? Default for Linux distros is typically /bin/bash
    To change this, you can edit /etc/passwd file using the command 'vipasswd' (as root).

    Then, just replace /bin/sh with /bin/bash on the appropriate line. This requires knowledge of vi/vim (depending on distro) which can be a little tricky to use if you've never used it before.

    To change default shell for user add, edit /etc/default/useradd (That's what it is in RHEL-based distros, not sure offhand what it might be in debian or others).

  6. #6
    Just Joined!
    Join Date
    Mar 2008
    Posts
    20
    Quote Originally Posted by cnamejj View Post
    If you're already "root" you don't need to use "sudo" to execute a program as another user. You can just use "su esolve -c firefox".
    cnamejj is right. I would only add a little option to make sure esolve is loaded with his own profile:
    Code:
    su - esolve -c firefox

Posting Permissions

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