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 ...
- 11-09-2007 #1
Why am I not allowed to do this?
I can't write to the last line of /etc/modulesuser@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
- 11-09-2007 #2Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
Try this
Any different?Code:sudo bash echo "ndiswrapper" >> /etc/modules
- 11-09-2007 #3
- 11-09-2007 #4
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.
- 11-09-2007 #5Linux 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.
- 11-09-2007 #6
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.
- 11-09-2007 #7
- 11-09-2007 #8
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:~$
- 11-09-2007 #9
- 11-09-2007 #10Linux 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


Reply With Quote