AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
 View Only
  • 1.  sudo and shell basics

    Posted Thu May 22, 2008 10:12 AM

    Originally posted by: SystemAdmin


    Hi

    what I want to do is to append something to a root file using sudo and echo.

    sudo echo "xyz">>/.profile

    and get
    The file access permissions do not allow the specified action.

    How to do it?

    Regards
    Amit Bist
    #AIX-Forum


  • 2.  Re: sudo and shell basics

    Posted Thu May 22, 2008 10:33 AM

    Originally posted by: tony.evans


    From the sudo manual,

    http://www.sudo.ws/sudo/man/sudo.html

    To make a usage listing of the directories in the /home partition. Note that this runs the commands in a sub-shell to make the cd and file redirection work.

    $ sudo sh -c "cd /home ; du -s * | sort -rn > USAGE"

    You need to use

    sudo "echo xyz >>/.profile"

    to get your command to work, otherwise the redirection happens in the current shell, not as part of the sudo command.
    #AIX-Forum