Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
user@linux:~$ sudo echo "ndiswrapper" >> /etc/modules bash: /etc/modules: Permission denied user@linux:~$ cat /etc/modules # /etc/modules: kernel modules to load at boot time. # # This file contains the names of ...
  1. #1
    Linux User Agent-X's Avatar
    Join Date
    May 2005
    Location
    Dimension X
    Posts
    261

    Why am I not allowed to do this?

    user@linux:~$ sudo echo "ndiswrapper" >> /etc/modules
    bash: /etc/modules: Permission denied
    user@linux:~$ cat /etc/modules
    # /etc/modules: kernel modules to load at boot time.
    #
    # This file contains the names of kernel modules that should be loaded
    # at boot time, one per line. Lines beginning with "#" are ignored.

    fuse
    lp
    sbp2
    I can't write to the last line of /etc/modules

  2. #2
    Linux Guru
    Join Date
    Nov 2004
    Posts
    6,110
    Try this
    Code:
    sudo bash
    echo "ndiswrapper" >> /etc/modules
    Any different?

  3. #3
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422
    run
    Code:
    su root -c "echo "ndiswrapper" >> /etc/modules"
    Or just turn into root before you do that.
    Since well I noticed that if you use sudo you dont have access to all the files.
    New Users, please read this..
    Google first, then ask..

  4. #4
    Linux User Agent-X's Avatar
    Join Date
    May 2005
    Location
    Dimension X
    Posts
    261
    I'm trying to make a script...
    I know I can do this as root, but I don't know any way of becoming root via a script.

  5. #5
    Linux Guru
    Join Date
    Nov 2004
    Posts
    6,110
    Becoming root as part of a script is difficult intentionally to stop you doing it unintended or trying to hide the root password somewhere such as in the script or in a file somewhere. The point of a script is to automate something. If it is something that root should be doing then you should run it as root, possibly under root's cron.

  6. #6
    Linux User Agent-X's Avatar
    Join Date
    May 2005
    Location
    Dimension X
    Posts
    261
    I am root. I own the computer. Things like this make me feel as though shell scripting is inadequate.

    It's about saving time and mass production.

    Why is it that out of so many commands I can do as sudo, I can't do this one?

    The account is an administrator, thus having access to root.

  7. #7
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422
    Since this is access to a system file I guess.
    New Users, please read this..
    Google first, then ask..

  8. #8
    Linux User Agent-X's Avatar
    Join Date
    May 2005
    Location
    Dimension X
    Posts
    261
    So, change the permissions and then change them back?

    Awesome.

    user@linux:~$ echo "ndiswrapper" >> /etc/modules
    bash: /etc/modules: Permission denied
    user@linux:~$ sudo chmod 777 /etc/modules
    user@linux:~$ echo "ndiswrapper" >> /etc/modules
    user@linux:~$ echo "meow" >> /etc/modules
    user@linux:~$ sudo chmod 444 /etc/modules
    user@linux:~$ sudo echo "ndiswrapper" >> /etc/modules
    bash: /etc/modules: Permission denied
    user@linux:~$ cat /etc/modules
    # /etc/modules: kernel modules to load at boot time.
    #
    # This file contains the names of kernel modules that should be loaded
    # at boot time, one per line. Lines beginning with "#" are ignored.

    fuse
    lp
    sbp2
    ndiswrapper
    ndiswrapper
    meow
    user@linux:~$

  9. #9
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422
    What I normaly do Instead of chmodding. Is chowning it to the current user with a script.

    so:
    sudo chown $USER /dir/to/file
    sudo chown root /dir/to/file
    New Users, please read this..
    Google first, then ask..

  10. #10
    Linux Guru
    Join Date
    Nov 2004
    Posts
    6,110
    There are two points to remember
    • Root is not a person, it is a privilege level. You may be the administrator but do you really want everything running at that level?
    • If the script needs to do something as root, let it run as root
    • root login is disabled in Ubuntu but the account is still very much present. You can still have jobs in cron for root

Page 1 of 2 1 2 LastLast

Posting Permissions

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