Results 1 to 7 of 7

Thread: sudo echo tun >> /etc/modules

  1. #1
    Join Date
    Jun 2008
    Beans
    301
    Distro
    Ubuntu 11.04 Natty Narwhal

    sudo echo tun >> /etc/modules

    hey all,

    im trying to write a script to install hamachi, but first i need to add tun to the loaded modules, and when i put sudo at the start of the echo command.. it gets access denied because the echo is run as sudo but the pipe to file isnt.. i was wondering if i could get it to run as root when pipeing

    i was thinking i could go

    chown <user>
    and then chown root after editing but it seems rarther clumsy...

  2. #2
    Join Date
    Jun 2007
    Beans
    1,745

    Re: sudo echo tun >> /etc/modules

    use
    Code:
    sudo su
    echo tun >> /etc/modules
    exit
    to temp gain root privilages, that way your line doesn't need boosting to root, or try:
    Code:
    echo tun >> sudo /etc/modules

  3. #3
    Join Date
    Apr 2007
    Location
    Philadelphia, Pa
    Beans
    99
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: sudo echo tun >> /etc/modules

    It's not the most elegant solution ever, but the quickest one I could think of at this time of night:

    Code:
    echo "tun" | sudo tee -a /etc/modules
    Like I said, not the most graceful solution ever, but much much better than chowning it to the user and then back to root.
    The cake is a lie!!!

  4. #4
    Join Date
    Jun 2008
    Beans
    301
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: sudo echo tun >> /etc/modules

    yeh i would rarther not be logging in as root, as the root account then needs to be enabled for the script to work, i tried the second one ( was my original guess ) and it actualy makes a file sudo and puts tun /etc/modules in it...

  5. #5
    Join Date
    Jun 2008
    Beans
    301
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: sudo echo tun >> /etc/modules

    thanks very much, yeh that works perfectly for what i need, ill keep tee in mind... slowly learning all the commands...

    thanks again

  6. #6
    Join Date
    Apr 2007
    Location
    Philadelphia, Pa
    Beans
    99
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: sudo echo tun >> /etc/modules

    You're very welcome. I just learned tee myself recently, but its a very useful utility to keep in mind.
    The cake is a lie!!!

  7. #7
    Join Date
    Apr 2006
    Location
    Montana
    Beans
    Hidden!
    Distro
    Kubuntu Development Release

    Re: sudo echo tun >> /etc/modules

    tee is very cool.

    You can (FYI):

    Code:
    sudo sh -c "echo tun >> /etc/modules"
    There are two mistakes one can make along the road to truth...not going all the way, and not starting.
    --Prince Gautama Siddharta

    #ubuntuforums web interface

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
  •