Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
25
rated 0 times [  25] [ 0]  / answers: 1 / hits: 23313  / 3 Years ago, thu, july 1, 2021, 9:17:36

Can you tell me what the difference is between cat and sudo cat?



All I know so far is that cat is used for displaying contents of file and concatenation.


More From » sudo

 Answers
7

For a little humour I would say that cat is an animal and sudo cat is a feline with superpowers. :D



sudo is a command that you use to obtain root privileges. root is a special user that manages the machine, and for this he/she has superpowers. For example, if there is a file that only root can see its contents, and you are logged in as a normal user, you can use



$ sudo cat name_of_the_file


to read it. Also if there is a program that only root can run, like the reboot command:



$ reboot
warning: must be root!
$ sudo reboot
rebooting...........


THE CATCH IS: you must be specially (and manually) assigned by root to have permission to use sudo. The permission is given in a file called /etc/sudoers. In Ubuntu, the first user, the one created during install, is automatically a sudoer. But the subsequent users are not. You have to add them manually to the group sudo whose members are allowed to use the command sudo.



By the way, /etc/sudoers is a file that only root can see. So if you do



$ cat /etc/sudoers


you will not be able to see its contents. But if you do:



$ sudo cat /etc/sudoers


you are good.



Hope this helps.


[#26667] Friday, July 2, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ttarum

Total Points: 417
Total Questions: 101
Total Answers: 115

Location: Maldives
Member since Wed, Nov 4, 2020
4 Years ago
ttarum questions
Sat, Aug 20, 22, 12:42, 2 Years ago
Wed, Sep 28, 22, 18:07, 2 Years ago
Mon, Feb 7, 22, 20:23, 2 Years ago
;