Welcome to the new Linux Foundation Forum!

Lab 25.2 the echo method requires you to be root; sudo won’t work.

OlegNikolaevOlegNikolaev Posts: 2
edited March 17 in LFS201 Class Forum

Hey guys,

There is a note in 25.2 "In the below we are going to use two methods, one involvingsysctl, the other directly echoing values to/proc/sys/kernel/pid_max. Note that theechomethod requires you to be root;sudowon’t work. We’ll leave it to you to figureout why, if you don’t already know!"

The method mentioned is:
$ echo 24000 > /proc/sys/kernel/pid_max # This must be done as root

I can't figure out why. Can someone help?


  • coopcoop Posts: 339

    if you don't do it as root (through su say) you have to do:

    sudo sh -c "echo ......pid_max"

    it is because you cannot do something like sudo echo "something" > /root/something" because you don't have permission to write something in that directory. echo has to start a new shell to redirect the output to a privileged directory; thus you must start a new shell before you do the echo which is what "sh -c" does

  • I get it. in fact, the shell does the redirect, not the 'echo' command even under sudo, and the shell is running under the regular user. Thanks.

Sign In or Register to comment.