Query NTP in milliseconds and seconds

For small and larger offsets, ntpd will reject the reference time for a while. In the latter case the operation system’s clock will continue with the last corrections effective while the new reference time is being rejected. After some time, small offsets (significantly less than a second) will be slewed (adjusted slowly), while larger offsets will cause the clock to be stepped (set anew). Huge offsets are rejected, and ntpd will terminate itself, believing something very strange must have happened. To query NTP use one of the following commands:

In milliseconds: ntpq -p
In seconds: ntpdc -p

For example:
In milliseconds
root@ntp:~# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
-chris.magnet.ie 193.120.10.3 2 u 3 64 377 9.274 9.759 5.386
-tbag.heanet.ie .PPS. 1 u 1 64 277 196.163 6.444 5.583
-ec2-54-171-104- 129.242.4.241 2 u 61 64 377 10.696 11.281 4.481
-lanczos.maths.t 140.203.204.77 2 u 65 64 376 216.847 -0.980 4.405
+ntp1.tp.pl .ATOM. 1 u 60 64 377 242.321 -1.206 1.913
*tshirt.heanet.i .PPS. 1 u 61 64 377 218.342 -5.035 3.481
+time1.google.co 204.153.230.130 2 u 57 64 377 150.045 -1.029 2.885
-time2.google.co 224.240.179.50 2 u 58 64 377 163.618 -3.737 1.734

In seconds:
root@ntp:~# ntpdc -p
remote local st poll reach delay offset disp
=======================================================================
=time1.google.co 2001:470:1c:d7a 2 64 377 0.15004 -0.001029 0.06841
=ec2-54-171-104- 192.168.1.44 2 64 377 0.00960 0.009266 0.04362
=lanczos.maths.t 2001:470:1c:d7a 2 64 377 0.21426 0.014209 0.04640
*tbag.heanet.ie 2001:470:1c:d7a 1 64 277 0.19615 0.006444 0.05617
=ntp1.tp.pl 2001:470:1c:d7a 1 64 377 0.22079 0.005051 0.03702
=tshirt.heanet.i 2001:470:1c:d7a 1 64 377 0.20105 0.005399 0.04185
=time2.google.co 2001:470:1c:d7a 2 64 377 0.16360 -0.003737 0.07126
=chris.magnet.ie 192.168.1.44 2 64 377 0.00926 0.009759 0.04625

Delete files/folders on OES11 – Permission denied

While deleting files/folders on the NSS volume on an OES11 server as root user via shell. Let’s say test1.doc and the following error will occur:

“rm: cannot remove `test1.doc’: Permission denied” or “S-1-1-0-1 on a Windows machine.”

You will get that error if you have flagged the file with NSS flag “Delete Inhibit” or “Rename Inhibit”. Clear those flags out and it should also be possible to delete the file directly from a Linux console. Use this command:

root# attrib -r -c all foldername

generic – Postfix generic table format

It has been taken from man – an interface to the on-line reference manuals.

The following shows a generic mapping with an indexed file. When mail
is sent to a remote host via SMTP, this replaces his@localdomain.local
by his ISP mail address, replaces her@localdomain.local by her ISP mail
address, and replaces other local addresses by his ISP account, with an
address extension of +local (this example assumes that the ISP supports
“+” style address extensions).

/etc/postfix/main.cf:
smtp_generic_maps = hash:/etc/postfix/generic

/etc/postfix/generic:
his@localdomain.local hisaccount@hisisp.example
her@localdomain.local heraccount@herisp.example
@localdomain.local hisaccount+local@hisisp.example

Execute the command “postmap /etc/postfix/generic” whenever the table
is changed. Instead of hash, some systems use dbm database files. To
find out what tables your system supports use the command “postconf -m”.
Continue reading “generic – Postfix generic table format”

Copy data from NSS to NSS with rights

This command “migfiles” copy data from the NSS volume DATA01:SLX on the source server with the IP address 171.16.12.56 to the tmp directory on the NSS volume DATA01 with verbose output:

root@nbsuse13:DATA01# migfiles -s 172.16.12.146 -V DATA01:SLX -x /media/nss/DATA 01/tmp -i
Enter the username (e.g cn=admin,o=mycompany)
for the server 172.16.12.146: cn=admin,ou=group,o=newbridge
Enter cn=admin,ou=group,o=newbridge password:
Enter the username (e.g root)
for the server : root
Enter root password:
Information: Source volume type is NSS
Information: Given destination path is NSS
Information: Copying /media/nss/DATA01/SLX/ to /media/nss/DATA01/tmp/
Information: Copying /media/nss/DATA01/SLX/a/ to /media/nss/DATA01/tmp/a/
Information: Copying /media/nss/DATA01/SLX/B/ to /media/nss/DATA01/tmp/B/
root@nbsuse13:DATA01#

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