Hello, Im studying for the CKA test and a little confused about the `sudo` comma . . .

Joe:
Hello, Im studying for the CKA test and a little confused about the sudo command as Im normally a windows user and have not seen it on any of the practice quizes, but have seen a few comments about it in the channels.

I understand sudo gives elevated privileges,

What I dont understand is:
Do you need to write sudo in front of each command or does it “stick” meaning all commands afterwards get sudo privileges?
Also, what is sudo -i ? and how does it differ from just plain sudo and when would I user one over the other?
Thanks in advance.

Dr Ganesh Neelakanta Iyer:
In exam, based on the question requirements, you will be asked to use sudo -i as needed. Some times you will see permission denied when a particular operation is performed and that is when you can use sudo before them to get the right permission.

Arulanandam Sakthivel:
Hi,

Like you said… sudo gives you root privileges…

So you can use it when you get a permission denied error…

sudo -i allows you run the command from root login…

Thanks
Arul

Dr Ganesh Neelakanta Iyer:
sudo lets you run commands in your own user account with root privileges. su lets you switch user so that you’re actually logged in as root. sudo -s runs a shell with root privileges. sudo -i also acquires the root user’s environment.

Joe:
So does the sudo permission “stick” to all commands afterwards or do I need to apply sudo for each command thereafter that I need elevated permissions?

Also, for purposes of this test couldn’t I just prepend sudo -i to each command to ensure I have sufficient permissions?

Dr Ganesh Neelakanta Iyer:
Better to use it when needed.

Dr Ganesh Neelakanta Iyer:
That is what I did

Joe:
OK - thank you @Dr Ganesh Neelakanta Iyer and @Arulanandam Sakthivel