Convert comma separated items into new line

[root@test]# cat input
a,b,c,d
[root@test]# cat input | sed 's/','/\n/g'
a
b
c
d
[root@test]# cat input | awk '$1=$1' RS=, OFS="\n"
a
b
c
d
[root@test]# cat input | tr -s ',' '\n'
a
b
c
d

Enjoy 🙂

Advertisements

Install Oracle JDK

Go to the link : http://www.oracle.com/technetwork/java/javase/downloads/

Accept the license agreement and Download the tar.gz file (eg: jdk -8u65-linux-i586.tar.gz)

Extract the file using the command tar -xzvf jdk-8u65-linux-i586.tar.gz

Copy the extracted directory (In my case jdk1.8.0_65) to the required location say /scratch

alternatives –install /usr/bin/java java /scratch/jdk1.8.0_65/bin/java 20000

alternatives –config java

You can see the list of available java versions and select our installed one by typing the number corresponding to that one.

Run a script at boot time in CentOS 7

By default /etc/rc.local and /etc/rc.d/rc.local are no longer executable in CentOS7 with the new systemd-changes. Follow the below steps to make the script /root/g.sh run at boot time:

1. chmod +x /etc/rc.d/rc.local
2. chmod +x /root/g.sh
2. Mention your script at the bottom of the file /etc/rc.local (/etc/rc.local is a symlink to /etc/rc.d/rc.local)as below :

sh /root/g.sh

Restart and check 🙂

Reset the password from single user mode in CentOS7

While booting up your machine, select the existing kernel and press ‘e’

1

Replace the entry ‘ro‘ with ‘rw init=/sysroot/bin/sh’

2

changed to

3

Press ctrl+x to save and start single user mode using the bash shell we mentioned above.

Run the below command and change password after that:

chroot /sysroot

passwd

6

Update selinux parameters as below :

touch /.autorelabel

7

Now reboot your machine. It may take some time to apply the apply the changes while booting up.

8

Thanks 🙂

Import certificate and key into jks

1. First create a p12 file and import both the certificate and key into it using openssl.

openssl pkcs12 -export -name theg -in /etc/ssl/certs/theg.crt -inkey /etc/ssl/private/theg.key -out theg.p12

2.Convert the p12 format into jks format using keytool :

keytool -importkeystore -destkeystore theg.jks -srckeystore theg.p12 -srcstoretype pkcs12 -alias theg

Note : Here I used the name theg for my certificates and alias, change it accordingly.