For system, network and cloud administrators
For example, I wanted the current logged user in my Ubuntu desktop, to be added to the sudoers
file. That was important for me because I wanted to run podman
. In order to do that, I’ve used several methods.
The tee -a command (or tee –append) can be used to append (write at the end of the file) the current logged in user to the sudoers file:
echo $USER | sudo tee -a /etc/sudoers
You can append text to a file in Linux using the cat command in combination with with EOF (End Of File):
cat >> /etc/sudoers << EOF
busyneo ALL=(ALL:ALL) ALL
EOF
You can notice that in the above example, I’m basically marking the start and the beginning of my text that I need inserted into the sudoers file by using EOF.