Results 1 to 10 of 10

Thread: Trouble with "mkdir" permissions in root directory

  1. #1
    Join Date
    Jun 2009
    Beans
    5

    Question Trouble with "mkdir" permissions in root directory

    Dear Ubuntu community,

    I am rewording a posting I initiated 20 hrs ago to a more tangible form.

    I am having problems running a bash script named "testfile" that attempts to create and write to a new directory ("steve_test") in the root directory (/). I did this in order to reproduce a problem I am having running an executable (IPW 2.1) that attempts to do the same thing. Script "testfile" has root suid priveleges (I even tried "chmod 7777 testfile" to no success), and I have privileges to execute "testfile", so I don't understand what the problem is. The funny thing is, when I "sudo su" to root, it works just fine. Isn't setting suid root privileges to "testfile" supposed to do the same thing? Maybe I'm totally confused... The shell output is below. I would so much appreciate any help so that I can get my software running.

    BTW: I am running Ubuntu 9.04 and Windows XP on dual boot.

    --Steve

    shell output:

    steven@stevens-computer:~/test$ bash testfile

    mkdir: cannot create directory `/steve_test': Permission denied
    testfile: line 5: /steve_test/mytext.txt: No such file or directory

    steven@stevens-computer:~/test$

  2. #2
    Join Date
    Jan 2008
    Location
    Philippines
    Beans
    17
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Trouble with "mkdir" permissions in root directory

    i'm not an expert but have you tried "sudo testfile" i think that will give your script root permissions

  3. #3
    Join Date
    Jun 2009
    Beans
    5

    Re: Trouble with "mkdir" permissions in root directory

    vidgen13,

    Yes, I mentioned in my original post that I could execute the script after switching to root. But it doesn't seem like I should have to do this if I set the suid byte and the script is owned by root (?). Also, and more importantly, the software I am running executes a script that tries to do the same thing. The running process needs "mkdir" permissions in root, I don't know how to my "sudo ..." might carry through all of the running processes.

    Steve

  4. #4
    Join Date
    Jul 2008
    Location
    Birmingham, England
    Beans
    2,400

    Re: Trouble with "mkdir" permissions in root directory

    Have you tried giving your user permission to run the script without a password in /etc/sudoers?

    Try adding the following line to /etc/sudoers

    Code:
    user steven=NOPASSWD: /usr/bin/testfile
    where /usr/bin/testfile is where the script is located

  5. #5
    Join Date
    Mar 2006
    Location
    Williams Lake
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Trouble with "mkdir" permissions in root directory

    You shouldn't be creating other directories in / as it may break the lsb (Linux Standards Base), The correct place for user created directories is /usr/local. If you make your script executable, and run it from /usr/local/bin and set it to create a directory in /usr/local, then use sudo to run it, you may have better luck.

  6. #6
    Join Date
    Jun 2009
    Beans
    5

    Re: Trouble with "mkdir" permissions in root directory

    SuperSonic4,

    The permissions of /etc/sudoers was r--r-----. I added write permissions to sudoers and now sudo is all balled up. At this point I cannot use "sudo" at all. When I do, I get the message "sudo: /etc/sudoers is mode 0640, should be 0440". I get the same message when I try to set the permissions of sudoers back the way it was (0440). Do you know how to undo the permission change I made to the file? Thanks.


    cariboo907,

    I do not want to write to the root directory. I am trying to figure out how to get permissions to do so in order to see ways of possibly getting my software running. It is apparently trying to write temporary files to the root directory. Do you think doing this may de-stabilize (mess up, etc etc) my system? Also, I tried following SuperSonic4's suggestion and now I cannot use sudo. This was caused by me adding write privileges to /etc/sudoers in order to edit the file. Now I keep getting the message "/etc/sudoers is mode 0640, should be 0440" when I try use sudo or modify permissions of sudoers. In retrospect I should not have tried this. Thanks.

  7. #7
    Join Date
    Nov 2005
    Location
    Uppsala, Sweden
    Beans
    2,180
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Trouble with "mkdir" permissions in root directory

    Quote Originally Posted by steve_akh076 View Post
    SuperSonic4,

    The permissions of /etc/sudoers was r--r-----. I added write permissions to sudoers and now sudo is all balled up. At this point I cannot use "sudo" at all. When I do, I get the message "sudo: /etc/sudoers is mode 0640, should be 0440". I get the same message when I try to set the permissions of sudoers back the way it was (0440). Do you know how to undo the permission change I made to the file? Thanks.
    Try to reboot into recovery mode and:
    Code:
    chmod 0440 /etc/sudoers
    then reboot.
    And never ever change permissions on important system files to edit them. The permissions are set the way they need to be, and if you change them things will stop working.
    To edit /etc/sudoers without messing it up:
    Code:
    sudo visudo
    Last edited by jocko; June 28th, 2009 at 09:14 PM.

  8. #8
    Join Date
    Apr 2009
    Location
    University of Minnesota
    Beans
    39
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Trouble with "mkdir" permissions in root directory

    Another way to edit the sudoers file, in case you aren't used to vi is:

    EDITOR=<nano/gedit> sudo visudo

    Have you tried simply chmod +s ?
    Phil

    [@Augsburg]

  9. #9
    Join Date
    Jun 2009
    Beans
    5

    Re: Trouble with "mkdir" permissions in root directory

    jocko and Augsburg,

    Thank you so much for helping me reset my file permissions. Yeah, that was not the way to go... No, I have not tried "chmod +s". Do you mean "chmod +s sudoers"? I shan't try that in retrospect.

    Steve

  10. #10
    wojox is offline I Ubuntu, Therefore, I Am
    Join Date
    Apr 2009
    Beans
    8,628

    Re: Trouble with "mkdir" permissions in root directory

    Code:
    (I even tried "chmod 7777 testfile" to no success)
    try

    Code:
    chmod 777

Tags for this Thread

Bookmarks

Posting Permissions

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