Options:
- -u →
sudo -u rahul ls /home/rahul
Here, the command runs as rahul instead of root.
- -i →
sudo -i
It gives you a shell with complete root authority, just like the root user.
- -k →
sudo -k
It clears the sudo time, so next time it will ask for your password again.
- -l →
sudo -l
It displays the exact list of commands that you are allowed to run using sudo.
- !! →
sudo !!
It executes the most recent command again, but with root privileges.
Examples
Install software:
sudo apt-get install git
Change file owner:
sudo chown shobha: developers file.txt
Here, shobha becomes the owner, and the developers become the group.
Note
Whenever you run this command in the terminal, be very careful. Even a single wrong command can damage the whole system.