LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS
User Name
Password
CentOS This forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation.

Notices


Reply
  Search this Thread
Old 06-14-2019, 10:18 AM   #1
sim0
LQ Newbie
 
Registered: Jun 2019
Posts: 6

Rep: Reputation: Disabled
Exclamation deleted /usr/bin/passwd by accident


hi ,
as i mentioned in title i delete '/usr/bin/passwd' by accident on my CentOS Linux release 7.2.1511 (Core).. please help, the easy way i see is if anyone have the same Centos 7 uploads the /usr/bin/passwd.
thanks
 
Old 06-14-2019, 10:20 AM   #2
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,252

Rep: Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011
Oops, totally misread this as "etc/passwd", my bad...

Last edited by sevendogsbsd; 06-14-2019 at 10:33 AM.
 
Old 06-14-2019, 10:30 AM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by sim0 View Post
hi ,
as i mentioned in title i delete '/usr/bin/passwd' by accident on my CentOS Linux release 7.2.1511 (Core).. please help, the easy way i see is if anyone have the same Centos 7 uploads the /usr/bin/passwd.
thanks
Put in your installation media, and copy it from there. The /usr/bin/passwd program is a binary, and since you have the installation media (or can easily make one), you can just copy that program back.
 
Old 06-14-2019, 01:45 PM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
/usr/bin/passwd is part of the "passwd" RPM. You could just reinstall that package:

Code:
yum reinstall passwd
 
1 members found this post helpful.
Old 06-14-2019, 04:38 PM   #5
sim0
LQ Newbie
 
Registered: Jun 2019
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MensaWater View Post
/usr/bin/passwd is part of the "passwd" RPM. You could just reinstall that package:

Code:
yum reinstall passwd
You need to be root to perform this command... i don't have root account on the server

Last edited by sim0; 06-15-2019 at 12:16 AM.
 
Old 06-15-2019, 07:37 AM   #6
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,252

Rep: Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011
Then how did you delete /usr/bin/passwd? A standard user does not have permissions to delete a binary in that directory.
 
2 members found this post helpful.
Old 06-15-2019, 01:30 PM   #7
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by sim0 View Post
You need to be root to perform this command... i don't have root account on the server
As sevendogsbsd pointed out, you couldn't have done what you say you did, without root (or sudo/root-level) access. And even past that, you can simply power the system off, and boot in single-user mode (which IS root-enabled), mount the hard drive and install media manually, and copy the file.

Or copy the file using sudo.
 
Old 06-15-2019, 02:49 PM   #8
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by sevendogsbsd View Post
Oops, totally misread this as "etc/passwd", my bad...
That's probably what happened to OP, too.

But how, without superuser privileges?
 
Old 06-16-2019, 09:33 AM   #9
sim0
LQ Newbie
 
Registered: Jun 2019
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sevendogsbsd View Post
Then how did you delete /usr/bin/passwd? A standard user does not have permissions to delete a binary in that directory.
i have the permission to copy or move or delete /usr/bin/passwd without root or sudo... maybe a misconfiguration behind that
 
Old 06-16-2019, 09:35 AM   #10
sim0
LQ Newbie
 
Registered: Jun 2019
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post
That's probably what happened to OP, too.

But how, without superuser privileges?
misconfiguration.. maybe!!
 
Old 06-16-2019, 09:40 AM   #11
sim0
LQ Newbie
 
Registered: Jun 2019
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
As sevendogsbsd pointed out, you couldn't have done what you say you did, without root (or sudo/root-level) access. And even past that, you can simply power the system off, and boot in single-user mode (which IS root-enabled), mount the hard drive and install media manually, and copy the file.

Or copy the file using sudo.
as i say i don't have physical access to the server it's in on the other side of the earth.. thanks for the response
 
Old 06-16-2019, 10:02 AM   #12
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,252

Rep: Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011
Quote:
Originally Posted by sim0 View Post
i have the permission to copy or move or delete /usr/bin/passwd without root or sudo... maybe a misconfiguration behind that
Definitely a misconfiguration. So can you copy INTO /usr/bin? If you can, SSH into the server and mount installation medium locally, then copy the file from your local machine out to the server into /usr/bin with rsync or some other remote command.

After you get the system working, you need to reconfigure so you can use sudo.
 
Old 06-16-2019, 10:53 AM   #13
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
additionally you can download the mentioned rpm, unpack it and use the binary from that package.
 
2 members found this post helpful.
Old 06-16-2019, 11:49 AM   #14
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,252

Rep: Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011
Probably could also SSH into the remote machine and use wget to download the rpm and install from there, if you have internet access - many ways to do this.
 
1 members found this post helpful.
Old 06-17-2019, 08:22 AM   #15
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Quote:
Originally Posted by pan64 View Post
additionally you can download the mentioned rpm, unpack it and use the binary from that package.
To do this on CentOS:
1) Make yourself a subdirectory for the download and extract that follows:
Code:
mkdir passwd
2) Change to the new subdirectory:
Code:
cd passwd
3) Download the RPM:
Code:
yumdownloader passwd
4) Above should put a file like passwd-0.79-4.el7.x86_64.rpm in the directory. RPMs can be converted to cpio backup format (similar to tar format) with the rpm2cpio command. That cpio output can be extracted with the cpio command so the following pipeline does the conversion to cpio and the extract of the files the RPM contained:
Code:
rpm2cpio passwd-0.79-4.el7.x86_64.rpm |cpio -ivBcumd
5) That will install the files in subdirectories of the one you created so your new passwd subdirectroy will contain ./usr/bin/passwd (the . is important). You can copy that into the real /usr/bin:
Code:
cp -p ./usr/bin/passwd /usr/bin/passwd
Note:
You may need to prepend the "cp" with "sudo" or some other command as regular users don't have permission to write into /usr/bin but you seem to indicate you do.

Last edited by MensaWater; 06-17-2019 at 08:49 AM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: Cannot find 'ssh-keygen' in '/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin' venu.navat Linux - Software 3 03-08-2012 04:00 AM
Deleted /usr/lib by accident molossus Fedora 1 12-28-2010 06:23 PM
echo $PATH = /home/g3rc4n/bin:/usr/local/bin:/usr/bin:/bin:/usr/games ? i_heart_pandas Linux - Software 7 09-18-2009 08:33 AM
Just deleted /usr/lib/pkgconfig by accident. Hunter2 Slackware 3 06-25-2006 07:15 PM
chsh accident; big accident. shinystuffrox *BSD 3 06-06-2005 07:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS

All times are GMT -5. The time now is 01:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration