If you have a compute server (EC2, ECS) based on Amazon Linux Image or have installed it locally on Docker Desktop and when you try to run a command with sudo you may get sudo: command not found error as sudo package is not installed by default,
How to install sudo package on Amazon Linux
You can make use of the yum - the command-line package-management utility for Linux,

bash-4.2# yum install sudo
...
Install 1 Package (+7 Dependent packages)
Total download size: 5.5 M
Installed size: 19 M
Is this ok [y/d/N]: y
Downloading packages:
(1/8): audit-libs-2.8.1-3.amzn2.1.aarch64.rpm | 99 kB 00:00:00
(2/8): cracklib-2.9.0-11.amzn2.0.2.aarch64.rpm | 81 kB 00:00:00
(3/8): gzip-1.5-10.amzn2.0.1.aarch64.rpm | 128 kB 00:00:00
(4/8): libcap-ng-0.7.5-4.amzn2.0.4.aarch64.rpm | 25 kB 00:00:00
(5/8): libpwquality-1.2.3-5.amzn2.aarch64.rpm | 85 kB 00:00:00
(6/8): pam-1.1.8-23.amzn2.0.1.aarch64.rpm | 729 kB 00:00:00
(7/8): sudo-1.8.23-10.amzn2.1.aarch64.rpm | 831 kB 00:00:00
(8/8): cracklib-dicts-2.9.0-11.amzn2.0.2.aarch64.rpm | 3.6 MB 00:00:02
...
Installed:
sudo.aarch64 0:1.8.23-10.amzn2.1
Complete!
bash-4.2#
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!