LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   tee command in sudoer file (https://www.linuxquestions.org/questions/linux-software-2/tee-command-in-sudoer-file-893768/)

pandunr 07-26-2011 12:39 AM

tee command in sudoer file
 
I have previlige to use tee command with sudo. When I try to execute the tee command with sudo, system is asking root password. How can use tee with sudo without root password. Here is the command

sudo tee file

When I execute the command system prompts for root password. I'm expecting system should prompt for individual id password.

MensaWater 07-26-2011 09:35 AM

sudo does NOT ask for the root password (unless you are already root when you invoke it) - It asks for the password of the user that is invoking the sudo command.

What exactly are you trying to do with tee? "tee file" is meaningless. The point of the tee command is to allow you to send output to a second location.

For example if you wanted to see the output of "ls -l" on the screen and also have it stored in a file you would type:
"ls -l |tee /tmp/ls.txt"

Since tee only acts on stdout you might want to also insure stderr went to the file in which case you'd do standard redirection:
"ls -l 2>&1 |tee /tmp/ls.txt"

tee itself does not require root access so I'm not sure why it would be in your sudoers setup. Instead you'd want the command you're running in sudoers. For example if you needed to save the output of /etc/shadow file you might run:
"sudo cat /etc/shadow |tee /tmp/shadow.out" The command would run as root then pipe stdin to tee which would run as your original user and create the file /tmp/shadow.out as your original user.

You could also run something like:
"sudo cat /etc/shadow |sudo tee /tmp/shadow.out" to make it run tee as root and create the output file owned by root.

Maybe if you give us an idea of what you're trying to do with tee it would help.


All times are GMT -5. The time now is 03:34 PM.