Find installation date and time of rpm package(s).

List all rpm package with date and time information, use the below given command to list all rpm package with date-stamp information:

rpm -qa --last

–cut
iotop-0.4.3-7.8.1 Fri Aug 7 12:24:02 2015
libgtop-lang-2.28.0-1.9.24 Fri Aug 7 12:20:57 2015
libgtop-2.28.0-1.9.24 Fri Aug 7 12:20:10 2015
libgtop-2_0-7-2.28.0-1.9.24 Fri Aug 7 12:20:06 2015
–cut

and for a single package:

rpm -q --last package-name

Boot Single User Mode – Resetting forgotten root user account password in RHEL/CentOS 6

While booting hit an arrow key, and it will take you to the GRUB menu. Again, use an arrow key to select the entry that you want to modify.
And hit “e” key to edit this. Find line which starts with “kernel“, and almost at the end of this line find “rhgb quiet“, and add “1” after “quiet“, so it will look like this: “rhgb quiet 1“. Once this is done hit enter. Now, it will take you to the kernel setting prompt. Just press “b” to boot from the kernel, and it takes you to the single user mode.

Now, you are in a single user mode, and you will be able to reset a root password, but before you do that check whether the SELinux is enabled or disabled.
Just type: “getenforce“. It has three contents: Enforcing – no permission to reset a root password. Permissive – permission to rest a root password, and Disabled – No policies are loaded. If you have Enforcing enabled you can disable it by using the following command: “setenforce 0“.
Once this is done, you can change a root password 🙂

CentOS7 – Samba mangles a long filename into an 8.3 filename.

Samba mangles a long filename into an 8.3 filename, for example:

-rw-r–r– 1 42781900 42781900 1432 Oct 16 21:00 2ZAOMT~P.XML
-rw-r–r– 1 42781900 42781900 1432 Sep 14 09:00 2ZCLAI~F.XML
-rw-r–r– 1 42781900 42781900 1432 Dec 3 21:00 2ZDTUD~9.XML
-rw-r–r– 1 42781900 42781900 66047 Sep 24 21:00 2ZG7PO~5.XML

Add “mangled names=no” to the [global] section in /etc/samba/smb.conf and then restart the smb service.

root# cat /etc/samba/smb.conf
–cut
[global]
unix charset = UTF-8
mangled names=no

–cut
root# systemctl restart smb

And now, everything is okay 😉

-rw-r–r– 1 42781900 42781900 1432 Oct 16 09:00 2016-10-16_09:00_Trading_Day_Exchange_Rate.xml
-rw-r–r– 1 42781900 42781900 1432 Oct 16 09:00 2016-10-16_09:00_Two_Day_Rolling_Wind_Forecast.xml
-rw-r–r– 1 42781900 42781900 1432 Oct 16 14:57 2016-10-16_14:57_Trading_Day_Exchange_Rate.xml
-rw-r–r– 1 42781900 42781900 1432 Oct 16 14:57 2016-10-16_14:57_Two_Day_Rolling_Wind_Forecast.xml

More information: http://www.oreilly.com/openbook/samba/book/ch05_04.html

Useful RPM Commands

Getting detailed information about the package telnet:
root# rpm -qi telnet
Name : telnet
Epoch : 1
Version : 0.17
Release : 59.el7
Architecture: x86_64
Install Date: Thu 16 Jul 2015 13:49:27 IST
Group : Applications/Internet
Size : 115772
License : BSD
Signature : RSA/SHA256, Fri 04 Jul 2014 06:12:17 IST, Key ID 24c6a8a7f4a80eb5
Source RPM : telnet-0.17-59.el7.src.rpm
Build Date : Mon 09 Jun 2014 23:06:27 IST
Build Host : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem
Vendor : CentOS
URL : http://web.archive.org/web/20070819111735/www.hcs.harvard.edu/~dholland/computers/old-netkit.html
Summary : The client program for the Telnet remote login protocol
Description :
Telnet is a popular protocol for logging into remote systems over the
Internet. The package provides a command line Telnet client
root#

Determining which package installed the file /usr/bin/telnet:
root# rpm -qf /usr/bin/telnet
telnet-0.17-59.el7.x86_64
root#

Showing all the files installed by the package telnet:
root# rpm -ql telnet
/usr/bin/telnet
/usr/share/doc/telnet-0.17
/usr/share/doc/telnet-0.17/README
/usr/share/man/man1/telnet.1.gz
root#

Viewing the documentation files for the command telnet:
root# rpm -qd telnet
/usr/share/doc/telnet-0.17/README
/usr/share/man/man1/telnet.1.gz
root#

Booting to Emergency Mode

Emergency mode provides the most minimal environment possible and allows you to repair your system even in situations when the system is unable to enter rescue mode. In emergency mode, the system mounts the root file system only for reading, does not attempt to mount any other local file systems, does not activate network interfaces, and only starts few essential services. In Red Hat Enterprise Linux 7, emergency mode requires the root password.
As soon as the boot process starts, press ESC to bring up the GRUB 2 boot prompt. You may need to turn the system off from the control panel and then back on to reach the GRUB 2 boot prompt. You will see GRUB 2 boot prompt – press “e” to edit the first boot option. Find the kernel line linux16 or linuxefi or linux (Each menuentry block that represents an installed Linux kernel contains linux on 64-bit IBM POWER Series, linux16 on x86_64 BIOS-based systems, and linuxefi on UEFI-based systems. Then the initrd directives followed by the path to the kernel and the initramfs image respectively) and add systemd.unit=emergency.target at the end of the line and then press CTRL-X to boot. System will boot and you will see the root prompt. Parameters, 1, s, and single, can be passed to the kernel as well.

Emergency Mode:
systemd.unit=emergency.target

It should look like this one:
–cut
1:
2: linux16 /vmlinuz-3.10.0-229.7.2.e17.x86_64 root=/dev/mapper/centos-root ro rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb quiet LANG=en_IE.UTF-8 systemd.debug systemd.unit=emergency.target
3: initrd16 /initramfs-3.10-0-229.7.2.el7.x86_64.img
4:
–cut

Booting to Rescue Mode

Rescue mode provides a convenient single-user environment and allows you to repair your system in situations when it is unable to complete a normal booting process. In rescue mode, the system attempts to mount all local file systems and start some important system services, but it does not activate network interfaces or allow more users to be logged into the system at the same time. In Red Hat Enterprise Linux 7 and CentOS 7, rescue mode is equivalent to single user mode and requires the root password.
As soon as the boot process starts, press ESC to bring up the GRUB 2 boot prompt. You may need to turn the system off from the control panel and then back on to reach the GRUB 2 boot prompt. You will see GRUB 2 boot prompt – press “e” to edit the first boot option. Find the kernel line linux16 or linuxefi or linux (Each menuentry block that represents an installed Linux kernel contains linux on 64-bit IBM POWER Series, linux16 on x86_64 BIOS-based systems, and linuxefi on UEFI-based systems. Then the initrd directives followed by the path to the kernel and the initramfs image respectively) and add systemd.unit=rescue.target at the end of the line and then press CTRL-X to boot. System will boot and you will see the root prompt. Parameters, 1, s, and single, can be passed to the kernel as well.

Rescue Mode:
systemd.unit=rescue.target

It should look like this one:
–cut
1:
2: linux16 /vmlinuz-3.10.0-229.7.2.e17.x86_64 root=/dev/mapper/centos-root ro rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb quiet LANG=en_IE.UTF-8 systemd.debug systemd.unit=rescue.target
3: initrd16 /initramfs-3.10-0-229.7.2.el7.x86_64.img
4:
–cut

Boot Single User Mode – Resetting forgotten root user account password in RHEL/CentOS 7

As soon as the boot process starts, press ESC to bring up the GRUB boot prompt. You may need to turn the system off from the control panel and then back on to reach the GRUB boot prompt. You will see a GRUB boot prompt – press “e” to edit the first boot option. Find the kernel line linux16 or linuxefi or linux (Each menuentry block that represents an installed Linux kernel contains linux on 64-bit IBM POWER Series, linux16 on x86_64 BIOS-based systems, and linuxefi on UEFI-based systems. Then the initrd directives followed by the path to the kernel and the initramfs image respectively) and add init=/bin/sh at the end of the line and then press CTRL-X to boot.
System will boot and you will see the root prompt. Type mount -rw -o remount / and then passwd to change the root password and then touch /.autorelabel and then exec /sbin/init

In short:
init=/bin/sh – In case of VMWare like KVM or VirtualBox use rb.break instead of inti=/bin/sh
# mount -o remount,rw /
# passwd root
[Enter New Password]
[Re-enter New Password]
# touch /.autorelabel
# exec /sbin/init

It should look like this one:
–cut
1:
2: linux16 /vmlinuz-3.10.0-229.7.2.e17.x86_64 root=/dev/mapper/centos-root ro rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb quiet LANG=en_IE.UTF-8 systemd.debug init=/bin/sh
3: initrd16 /initramfs-3.10-0-229.7.2.el7.x86_64.img
4:
–cut

Use the iptables and ip6tables services instead of firewalld – CentOS 7

To use the iptables and ip6tables services instead of firewalld, first disable firewalld by running the following command as root:

root# systemctl disable firewalld
root# systemctl stop firewalld

Then install the iptables-services package by entering the following command as root:

root# yum install iptables-services

The iptables-services package contains the iptables service and the ip6tables service.
Then, to start the iptables and ip6tables services, run the following commands as root:

root# systemctl start iptables
root# systemctl start ip6tables
root# systemctl enable iptables
root# systemctl enable ip6tables

An example script which blocks INPUT and FORWARD and runs /sbin/iptables-save and writes the current iptables configuration to /etc/sysconfig/iptables. Upon reboot, the iptables init script reapplies the rules saved in /etc/sysconfig/iptables by using the /sbin/iptables-restore command.

Continue reading “Use the iptables and ip6tables services instead of firewalld – CentOS 7”

How to install RHEL EPEL repository on Centos 7.x or RHEL 7.x

The following instruction assumes that you are running command as root user on a CentOS/RHEL 7.x system and you would like to use Fedora Epel repositories.

Install Extra Packages for Enterprise Linux repository configuration (recommended). Just type the following command on a CentOS 7 or RHEL 7:

root# yum install epel-release

or

Install the extra EPEL repositories from dl.fedoraproject.org :


root# cd /tmp
root# wget https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
root# ls *.rpm
root# rpm -i epel-release-7-5.noarch.rpm