Labels

hpunix (63) marathi kavita (52) linux (21) solaris11 (11) AWS (5) numerology (5)

Wednesday, December 12, 2018

ec2-user is not able to do sudo - Linux + AWS


ec2-user is not able to do become root user:

ec2-user is not able to do sudo or ec2-user is not able become root user.

I was getting below error when I logged in as ec2-user with the .ppk file and then I was trying to become root user by using #sudo –i


[ec2-user@cloud_home]# sudo : effective uid is not 0, is sudo installed setuid root ?

While doing initial troubleshooting, we got to know that someone has changed the /usr/bin/sudo file permission accidentally. [But even he was unaware about that]

Answer :


1.      Login to AWS console and stop the instance
2.      Detach the root disk (/dev/sda1)
3.      Attach it to any running server [who are in same availability zone] as data disk [/dev/xvdg – device name of the disk given by AWS at the time of attaching it]
4.      Start the Instance from AWS console

5.      mount the disk on OS
[root@cloud_home2]# mount /dev/xvdg2 -o no-uuid /mnt ; cd  /mnt ; ls -l usr/bin/sudo

6.      Change permission of /usr/bin/sudo
[root@cloud_home2]# chmod u+s /mnt/usr/bin/sudo ; ls -l usr/bin/sudo

7.      Un-mount temporary mount point
[root@cloud_home2]# umount /mnt

8.      Detach the disk from this server
9.      And re-attach to original server as root disk where we are getting problem.
10. Start instance
11. Login with ec2-user

12. Now try to do sudo and this time you will be able to it.

[ec2-user@cloud_home]# sudo –i
[root@cloud_home]#

Regards,
Kirraan Jadhav


Saturday, December 8, 2018

How to uninstall package/rpm in Linux


How to uninstall package/rpm in Linux:


rpm (redhat package manager) is a powerful tool which can be used to build, install, query, verify, update, and remove/erase individual software packages. 

Below commands can be used to remove packages or rpm:


[root@cloud_home]# rpm –ev [Package Name]

-e = to erase specified package name or rpm

If we want to remove package without removing that package dependency then 

[root@cloud_home]# rpm –ev –-nodeps [Package Name]

Or we can remove package by using yum command as well.
[root@cloud_home]# yum remove [Package Name]

Above commands has given by assuming that we already know the exact package name.

If you don’t know the exact package name then to find out it use below command To get the package name. In below example we are finding package name for httpd:


[root@cloud_home]# rpm –q httpd


Regards,
Kirraan Jadhav