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,
![Fix sudo command not found Amazon Linux Fix sudo command not found Amazon Linux](https://code2care.org/linux/fix-amazon-linux-bash-sudo-command-not-found/images/Fix sudo command not found Amazon Linux.jpg)
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#
Facing issues? Have Questions? Post them here! I am happy to answer!
Author Info:
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
More Posts related to AWS,
- Get the total size and number of objects of a AWS S3 bucket and folders
- How to Create AWS SNS Topic using AWS CLI
- Fix: Amazon Linux bash: sudo: command not found
- [Solution] AWS Java SDK S3 AmazonS3Exception InvalidAccessKeyId
- Create an AWS User using CLI2 Command at a specific Path
- Fix: Missing the following required SSO configuration values: sso_start_url, sso_region
- Fix: zsh: command not found: aws (Mac/macOS)
- Configure AWS Access ID and Secret Keys using CLI on Mac
- Quick way to setup AWS DynamoDB locally on macOS
- Most Essencial AWS CLI 2 S3 ls Command Options
- How to Check AWS SNS Permissions using CLI
- AWS CLI Change Default Output Format
- How to install AWS CLI on Ubuntu
- Quick way to install AWS CLI for macOS Terminal
- Install AWS CLI using Brew Command
- AWS CLI Command to Get a List of SNS Topics
- Get List of AWS SNS Topic Subscriptions using CLI
- How to Setup AWS Credentials using Visual Studio Code
- Installing AWS CLI Version 2 on macOS Sonoma using Terminal
- AW3 CLI command to get list of all region names
- AWS SNS CLI Command Publish Message Attributes
- Create an S3 bucket in a specific AWS region using CLI Command
- [Fix] zsh: command not found: awscli [Mac Terminal]
- Understanding AWS Calculator: DynamoDB on-demand capacity
- [Solution] com.amazonaws.dynamodb.v20120810 MissingAuthenticationToken Key Id or X.509 certificate
More Posts:
- Vertically Center Text in a DIV Element - CSS
- [Fix] Sharepoint: Embedding content from this website isnt allowed, but your admin can change this setting. - SharePoint
- How to serialize-deserialize an object in java - Java
- How to take Screenshot on Android device - Android
- [fix] openssl No such file or directory error C++ - Ubuntu
- F2 Key Cell Editing Alternative for Excel for Mac - Windows
- Spring Boot: JdbcTemplate Update Query With Parameters Example - Java
- How to Perform Cut/Paste Operations in Nano Editor - Linux