1

I was trying to change the msg_max queue size on my ubuntu 14.04 system. Here is the console output:

$ sudo echo 500 > /proc/sys/fs/mqueue/msg_max
-bash: /proc/sys/fs/mqueue/msg_max: Permission denied

$
$ cat /proc/sys/fs/mqueue/msg_max
1000

$ sudo echo 500 > /proc/sys/fs/mqueue/msg_max
-bash: /proc/sys/fs/mqueue/msg_max: Permission denied

$ sudo sh -c "echo 500 > /proc/sys/fs/mqueue/msg_max"
[sudo] password for XXX:

$ cat /proc/sys/fs/mqueue/msg_max
500

My question is why the first approach using echo directly is not working while the other one using sh -c works?

neo
  • 969
  • 1
  • 11
  • 23
  • 1
    From the target duplicate: _The problem is that the shell does output redirection, not sudo or echo, so this is being done as your regular user_. – fedorqui Dec 02 '16 at 12:42
  • thanks got the answer here http://stackoverflow.com/questions/84882/sudo-echo-something-etc-.privilegedfile-doesnt-work-is-there-an-alterna – neo Dec 02 '16 at 12:44

0 Answers0