InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

AWS and EC2

  • AWS benefits
  • Broken sudoers file
  • EBS and reliability/durability
  • EC2 api tools on Ubuntu
  • How to extend disk (EBS) size on Amazon Linux
  • Install wordpress AWS Classic Ubuntu
  • Linux instance on AWS Classic
  • Mysql access
  • Mysql service and micro instance
  • Route53 as DNS
  • Upgrade Linux micro instance to small
  • ssh automation
 
  • Home
  • > Tutorials
  • > AWS and EC2

How to fix a broken sudoers file on AWS/EC2 Linux

By admin on Aug 30, 2015

In case you are using Ubuntu or Amazon linux on Amazon EC2 and introduce a syntax error, you won’t be able to run any sudo command. That will pretty much disallow running any root command if you haven’t enabled root ssh access to the system. You are somewhat in a locked out situation. Here are the steps to fix this problem:

Stop the instance and detach root volume

First stop the instance (do not terminate) as shown below. Make sure that your instance is not in terminate on shutdown mode as you need to start it again.
ec2-instance-shutdown

After shutting down, detach the volume from the instance.

Attach root volume to another instance

Create a temporary instance and attache the above detached volume on it. Now you can run the following command to list available volumes:

$ sudo lsblk

Now create a tmp directory and mount the newly added device to that directory.

$ sudo mkdir -p /ihmnt/tmp1
$ sudo mount /dev/xvdf1 /ihmnt/tmp1

Now you can fix the corrupt sudoers file in it and umount it:

$ sudo umount /ihmnt/tmp1

Now you can detach this volume and attach us back to original instance (as root volume) and start that instance.

Suggested posts:

  1. Ubuntu – dpkg and apt-get beginner tutorial
  2. Linux rsync tutorial
  3. Memcache – how to dump all keys and values on command line
  4. PHP echo – comma (,) vs dot (.) performance benchmarks
  5. How to locally override website domain (or hostname) to IP mapping
  6. document querySelector examples
  7. Docker how to add a user to group docker on Linux
  8. Linux – how to run a command as different user
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged AWS and EC2, Devops Interview Questions, Linux, Tutorials, Ubuntu Linux
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress