Results 1 to 4 of 4

Thread: Sudo still gives me permission denied

  1. #1
    Join Date
    Jul 2010
    Location
    51.508056, -0.128056
    Beans
    205
    Distro
    Ubuntu 12.04 Precise Pangolin

    Sudo still gives me permission denied

    Hello there, I am trying to create a file with some text in it inside rules.d

    Code:
    sudo echo SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666", OWNER="mendhak" > /etc/udev/rules.d/51-android.rules
    So I want to write that string to the 51-android.rules file. Whether or not I use sudo, the output is always


    bash: /etc/udev/rules.d/51-android.rules: Permission denied
    If I gksu gedit a file there, it works just fine and I can create it.


    However, I'd like to be able to do this via a bash script. What am I missing?

  2. #2
    Join Date
    Jun 2007
    Location
    Poughkeepsie, NY
    Beans
    5,814
    Distro
    Ubuntu

    Re: Sudo still gives me permission denied

    try using sudo -i before issuing the command, it will place you into a root like setting so you no longer have write sudo with every command. it will last for a few minutes or until you close the terminal.
    Code:
    sudo -i
    
    echo SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666", OWNER="mendhak" > /etc/udev/rules.d/51-android.rules
    Last night I lay in bed looking up at the stars in the sky and I thought to myself, where the heck is the ceiling.

  3. #3
    Join Date
    Jun 2006
    Location
    UK
    Beans
    Hidden!
    Distro
    Ubuntu 14.10 Utopic Unicorn

    Re: Sudo still gives me permission denied

    The problem is using a bash redirect with sudo.

    Code:
    sudo echo string > /path/to/file
    ... will fail with the error you see. What you can do is:

    Code:
    echo string | sudo tee /path/to/file
    I'll leave you to adapt that with your collection of strings.

    Or - you can obtain a root terminal with sudo -i as LowSky suggests.

    Please do not PM me about your forum account unless you have been asked to. The correct place to contact an admin about your account is here.

  4. #4
    Join Date
    Jul 2010
    Location
    51.508056, -0.128056
    Beans
    205
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Sudo still gives me permission denied

    Very nice, I didn't know about sudo -i. I will add that to my script.

    Both of your solutions worked, thanks very much!

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
  •