I‘m typing the following command:
But, getting the error:
How do I fix this problem under Debian / Ubuntu / RHEL / CentOS Linux?
This error means the sudo command is not installed. The sudo command allows a permitted user to execute a command as the superuser or another user, as specified in the sudoers file.
Step #1: Become a root user
Use su – command as follows:
$ su -
When prompted you need to type the root user’s password.
Step #2: Install sudo tool under Linux
If you are using Debian or Ubuntu Linux, enter:
# apt-get install sudo
Sample outputs:
Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: sudo 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 610 kB of archives. After this operation, 983 kB of additional disk space will be used. Get:1 http://security.debian.org/ squeeze/updates/main sudo amd64 1.7.4p4-2.squeeze.3 [610 kB] Fetched 610 kB in 4s (132 kB/s) Selecting previously deselected package sudo. (Reading database ... 30838 files and directories currently installed.) Unpacking sudo (from .../sudo_1.7.4p4-2.squeeze.3_amd64.deb) ... Processing triggers for man-db ... Setting up sudo (1.7.4p4-2.squeeze.3) ... No /etc/sudoers found... creating one for you.
If you are using RHEL / CentOS / Fedora / Scientific Linux, enter:
# yum install sudo
Sample outputs:
Loaded plugins: product-id, protectbase, rhnplugin, subscription-manager Updating certificate-based repositories. Unable to read consumer identity 0 packages excluded due to repository protections Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package sudo.x86_64 0:1.7.4p5-12.el6_3 will be installed --> Finished Dependency Resolution Dependencies Resolved ==================================================================================================== Package Arch Version Repository Size ==================================================================================================== Installing: sudo x86_64 1.7.4p5-12.el6_3 rhel-x86_64-server-6 423 k Transaction Summary ==================================================================================================== Install 1 Package(s) Total download size: 423 k Installed size: 0 Is this ok [y/N]: y Downloading Packages: sudo-1.7.4p5-12.el6_3.x86_64.rpm | 423 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : sudo-1.7.4p5-12.el6_3.x86_64 1/1 Installed products updated. Verifying : sudo-1.7.4p5-12.el6_3.x86_64 1/1 Installed: sudo.x86_64 0:1.7.4p5-12.el6_3 Complete!
Step #3: Add admin user to /etc/sudoers
You need to add yourself to /etc/sudoers file, enter:
# visudo
Grant vivek user full permission via sudo:
vivek ALL=(ALL) ALL
Save and close the file.
How do I use sudo?
To become a root user and start root shell, enter:
$ sudo -i
OR
$ sudo -s
To run a command called ‘/sbin/service httpd restart’, enter:
$ sudo /sbin/service httpd restart
To reload squid proxy server, enter:
$ sudo /usr/sbin/squid3 -k reconfigure
Sample outputs:
We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. [sudo] password for vivek:
🐧 3 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Thanks for this! I’m learning Linux (using Fedora) and I managed to remove sudo when I removed vim-minimal.
i have “passwrd: command not found” in ideneb 1.3 , when i type “passwrd root” to config setup….do u have an idea.
thank u!
Try passwd command.