Restoring /usr/bin with yum after accidental deletion

October 17, 2011
Restoring /usr/bin with yum after accidental deletion

I was recently writing a Makefile for cramfs, specifically the distclean and install sections. The installation would copy the program binaries to /usr/bin while the cleanup would remove them… simple enough right?

I wrote a for loop to go through $(PROGS) and remove them from $(INSTLOC):
01 INSTLOC = /usr/bin 

02 PROGS = mkcramfs cramfsck 

03 

04 all: $(PROGS) 

05 

06 distclean clean: 

07 for p in $(PROGS);\ 

08 do\ 

09 rm -rf $$p $(INSTLOC)/$$p;\ 

10 done 

11 

12 install: 

13 cp $(PROGS) $(INSTLOC) 

The problem was that I ran this as root (tsk tsk), and since Makefile requires that for loop variables be escaped (line 9: $$p not $p), the rm command translated to this:
1 rm -rf /usr/bin/ 
Great! So now I had no binaries in /usr/bin, which includes: yum, bash, crontab, python, perl… (800+ in total on a minimal install).

Since I only deleted the binaries, the programs were still listed as installed in the RPM database. The first thing I had to do was reinstall yum and it’s “usrbin” dependency python:

1 [root@demon ~]# mount /dev/sr0 /media/cdrom 

2 [root@demon ~]# cd /media/cdrom/Packages 

3 [root@demon ~]# rpm -Uvh --force python-2.6.5-3.el6.i686.rpm 

4 [root@demon ~]# rpm -Uvh --force yum-3.2.27-14.el6.noarch.rpm 


he next step was to figure out which packages had binaries in /usr/bin so I can reinstall them:

view sourceprint?
1 [root@demon ~]# rpm -qf $(rpm -qla|grep ^/usr/bin)|uniq|sort 
… and finally send those to yum to do a reinstall and get the binaries back:

view sourceprint?
1 [root@demon ~]# yum reinstall $(rpm -qf $(rpm -qla|grep ^/usr/bin)|uniq|sort) 

2 [root@demon ~]# ls -la /usr/bin|wc -l 

3 848 

4 [root@demon ~]# 
… crisis averted! Snapshot time.

One last note: If you manually installed third party RPMs (not listed in the /etc/yum.repos.d repositories), they will not be reinstalled. You can perform reinstall these one by one using the rpm -Uvh command above. Keep in mind that if these RPMs have not undergone proper QA they may overwrite your current configuration files

You can run these RPMs through rpmlint to see if they produce any warnings or errors that may cause a problem when reinstalling:

view sourceprint?1 [root@demon ~]# rpmlint -iv iplog-2.2.1-1_RH7.i386.rpm 

2 ... 

3 iplog.i386: W: conffile-without-noreplace-flag /etc/iplog.conf 

4 A configuration file is stored in your package without the noreplace flag. A 

5 way to resolve this is to put the following in your SPEC file: 

6 %config(noreplace) /etc/your_config_file_here 

7 ... 

8 [root@demon ~]# 

 

New Features in RHEL6

October 17, 2011

 New Features in RHEL6 


1. ext4 file system is introduced.
2. xen is removed and kernel virtualization machine (KVM) is introduced.
3. neat command is removed.
4. portmap service is removed.
5. iscsi is introduced, which supports for SAN.
6. rpmbuild is available, which is used to create our own rpms.
7. File encyption is added.
8. palimpsest is available for disk management.
9. Virtual machine will run only on 64bit processors.
10. postfix service is recommended instead of sendmail service.

Continue reading...
 

RHEL6 openldap server

October 17, 2011
RHEL6 openldap server


Please note that all double quote characters in this example are plain ASCII ” characters not typographical ones!

Step 1: first we need to install the required packages:

#yum install openldap-servers migrationtools

Step2: As the configuration for LDAP is stored inside the LDAP server itself the configuration has to be done by editing LDIF files under the /etc/openldap/slapd.d/ directory.

Now create the ldap password:

#slappasswd

you’ll get something like this ”{SSHA}r2or9...

Continue reading...
 

RHEL6 vsftp anonymous access selinux

October 17, 2011
RHEL6 vsftp anonymous access selinux

First install the vsftpd package

#yum install vsftpd

after that edit the /etc/vsftpd/vsftpd.conf

anonymous_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/vsftpd.log
xferlog_std_format=YES
ftpd_banner=Welcome to blah FTP service.
listen=YES
local_root=/var/ftp/upload
pam_service_name=vsftpd
userlist_enable=YES
tcp_w...

Continue reading...
 

RHEL6 virsh console domain

October 17, 2011
RHEL6 virsh console domain

To use the #virsh console command on a RHEL6 Virtual Server you need to configure the guests. If you do not configure them, this

Escape character is ^] Is all you get.

For RHEL6 clients you have to configure 2 files:

1./boot/grub/menu.lst
add the modification in bold:
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
serial –unit=0 –speed=115200
terminal –timeout=10 console serial
hiddenmenu
title Red Hat Enterprise Linux (2.6.32-71.el6.x86_64)
root (hd0,0)
kernel ...

Continue reading...
 

DHCP is working good in RHEL6

October 17, 2011
DHCP is working good in RHEL6 

Server Configuration: 
Step1: install the following rpm

rpm -ivh dhcp-4.1.1-12.P1.el6.i686.rpm
Step 2: cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf 
Step 3: change the range of ip address as per your wish.
Step 4: service dhcpd restart
Step 5: chkconfig dhcpd on

Client Configuration:
Step 1: dhclient
Step 2: check the following file
/etc/resolv.conf


Sample file: Copy and paste the specified location /etc/dhcp/dhcpd.conf and get the dhcp service

# dhcpd...

Continue reading...
 

RHEL secondary Name Server

October 17, 2011
RHEL secondary Name Server

 Open /etc/named.conf

//
// named.conf for Red Hat caching-nameserver
//

options {
directory “/var/named”;
dump-file “/var/named/data/cache_dump.db”;
statistics-file “/var/named/data/named_stats.txt”;

// query-source address * port 53; (only needed when there is a FW between master an slave)
allow-transfer {192.168.1.104/24;}; (slaveip)
};

//
// a caching only nameserver config
//

controls {
inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};

zone “localhost” IN...

Continue reading...
 

RHEL6 and SElinux

October 17, 2011
RHEL6 and SElinux

One of the most important packages to run successfully RHEL6 and SElinux is the setroubleshoot package. It includes useful tools like the setroubleshoot daemon and utils like sealert, sestatus…..

So lets see whats the sestatus of my system:
[root@rhel1 ~]# sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted

Ok so assuming i want to set up an ftp server. I know my conf...

Continue reading...
 

How To Install YUM Server in RHEL 6

October 17, 2011
How To Install YUM Server in RHEL 6 

Step By Step Configration of Yum Server
1. mount /dev/cdrom /mnt
2 rpm -ivh /mnt/Server/Packages/vsftpd*
3. cp -rv /mnt/* /var/ftp/pub/
4. rpm -ivh /mnt/Server/Packages/delta*
5. rpm -ivh /mnt/Server/Packages/Pythen-delta*
6. rpm -ivh /mnt/Server/Packages/createrepo*
7. vi /etc/yum.repos.d/server.repo
[yum-server]
name= This is my RPM store
baseurl=file:///var/ftp/pub/
enable=1
gpgcheck=0
8. createrepo -v /var/ftp/pub
9. rm -rf /var/ftp/pub/.olddata
10. yum clean all
11. y...

Continue reading...
 

Recent Posts