Beginner Guide to sudo Command in Linux example

  • sudo command not found
  • Debian sudo not found
  • Find out sudo version
  • Arch Linux sudo not found
  • how to list current privileges for a given user
  • invalidate sudo -kill the cache
  • sudo -v option validation credentials
  • sudo long listing of commands

sudo is an abbreviation for superuser do.

It is a Linux/Unix command used by system administrators to grant root privileges to a set of users for a specific command.

It is only used at the command level.

This blog, cover the `sudo usage examples and use cases.

Sudo command not found

Sometimes, the sudo command will not work and it gives a sudo command not found error in the console. To make this command work,

  • find out the Linux and install the sudo package

Debian sudo not found

First, log in with the su command.

su -

install sudo package

apt-get install sudo -y

It installs the sudo command in Debian Linux.

Arch Linux sudo not found

Install Sudo package using the Pacman tool.

pacman -S sudo

Find out sudo version

sudo -V
Sudo version 1.9.4
Sudoers policy plugin version 1.9.4
Sudoers file grammar version 42
Sudoers I/O plugin version 1.9.4

how to list current privileges for a given user

**To check your current sudo privileges, run this command: sudo -l.

sudo -l

sudo with the allowed command to run

In the given command, the current user can start the tomcat command sudo is followed by the tomcat service start command and asking prompt to give the password.

sudo service tomcat9 start
[sudo] password for current user:
Starting tomcat9: [ OK ]

In this example, the System administrator gives the current user permission to execute the tomcat start command.

invalidate sudo -kill the cache

If you run the tomcat restart command again, it will not prompt you for a password because the password is temporarily stored in the cache.

Use the ‘sudo -k’ command to clear the cached credentials.

sudo long listing of commands

sudo -ll

Its formats allowed command listing in a long listing format.

-v option validation credentials

if current user credentials are changed, sudo user credentials also need to revalidate it.

sudo -v