Thứ Ba, 18 tháng 12, 2018

extend lvm

echo "- - -" > /sys/class/scsi_host/host#/scan
pvcreate /dev/sdc
pvscan
vgextend vgdata /dev/sdc
vgscan
lvextend -l +100%FREE /dev/vgdata/lvdata
lvscan

resize2fs /dev/vgdata/lvdata



Read More

Thứ Hai, 17 tháng 12, 2018

How to Add a New Disk Larger Than 2TB

Find Out Current Disk Size

Type the following command:
# fdisk -l /dev/sdb
Sample outputs:
Disk /dev/sdb: 3000.6 GB, 3000592982016 bytes
255 heads, 63 sectors/track, 364801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table

Linux Create 3TB partition size

To create a partition start GNU parted as follows:
# parted /dev/sdb
Output:
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)
Creates a new GPT disklabel i.e. partition table:
(parted) mklabel gpt
Sample outputs:
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes
(parted)
Next, set the default unit to TB, enter:
(parted) unit TB
To create a 3TB partition size, enter:
(parted) mkpart primary 0 0
OR
(parted) mkpart primary 0.00TB 3.00TB
To print the current partitions, enter:
(parted) print
Sample outputs:
Model: ATA ST33000651AS (scsi)
Disk /dev/sdb: 3.00TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags
 1      0.00TB  3.00TB  3.00TB  ext4         primary
Quit and save the changes, enter:
(parted) quit
Sample outputs:
Information: You may need to update /etc/fstab.
Use the mkfs.ext3 or mkfs.ext4 command to format the file system, enter:
# mkfs.ext3 /dev/sdb1
OR
# mkfs.ext4 /dev/sdb1
Sample outputs:
mkfs.ext4 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
183148544 inodes, 732566272 blocks
36628313 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
22357 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
 102400000, 214990848, 512000000, 550731776, 644972544

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
Type the following commands to mount /dev/sdb1, enter:
# mkdir /data
# mount /dev/sdb1 /data
df -H

Sample outputs:
Filesystem             Size   Used  Avail Use% Mounted on
/dev/sdc1               16G   819M    14G   6% /
tmpfs                  1.6G      0   1.6G   0% /lib/init/rw
udev                   1.6G   123k   1.6G   1% /dev
tmpfs                  1.6G      0   1.6G   0% /dev/shm
/dev/sdb1              3.0T   211M   2.9T   1% /data

Format Using gdisk 

The gdisk is an GPT alternative to fdisk command. The syntax is same as fdisk command. For example:
$ sudo fdisk /dev/sdb
OR
$ sudo gdisk /dev/sdb
Sample outputs:
GPT fdisk (gdisk) version 1.0.1

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries.

Command (? for help):
Type n to create a new partition:
Command (? for help): n
Partition number (1-128, default 1): 1
First sector (34-XXXXXXX, default = 2048) or {+-}size{KMGTP}: 
Last sector (2048-XXXXXXX, default = XXXXXXX) or {+-}size{KMGTP}: 
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300)
Press w to write new table to disk and exit to the shell prompt:
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to hdd.img.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.
Now you can format /dev/sdb1 and mount it as usual.
Read More

Thứ Tư, 21 tháng 11, 2018

Convert Apache (x509 cert) SSL Certificate to Tomcat (Keystore)

When setting up SSL certificate for a website, we mainly use two types of SSL certificate one is x509 mostly used with applications support OpenSSL library and other is Keystore which is used with Java 1.6+ applications.


Apache/Nginx uses x509 pem/crt files which is is very different than a Jetty/Tomcat (Java 1.6+) system that uses keystores and differences start right from generating a Certificate Signing Request (CSR). So, you could either generate separate CSR request for both and get different SSL certificate which obviously involve cost or you could use following steps to convert the working x509 certificate to the keystore.

1. Get x509 certificates from Apache/Nginx
You will need three certificates Private Key certificate used for generating CSR, Signed Certificate  provided by signing authority and Intermediate or Root certificate of signing authority.

For Apache:

Check your site’s configuration for below settings:

SSLCertificateFile /etc/apache2/ssl/10tut_blogspot_com.crt
SSLCertificateKeyFile /etc/apache2/ssl/10tut_blogspot_com.key
SSLCertificateChainFile /etc/apache2/ssl/intermediate.crt
For Nginx:

Check your site’s configuration for below settings:

ssl_certificate /etc/nginx/ssl/10tut_blogspot_com.crt;
ssl_trusted_certificate /etc/nginx/ssl/intermediate.crt;
ssl_certificate_key /etc/nginx/ssl/10tut_blogspot_com.key;
2. Copy the three files which can be found in the above to one location
(Ex. /opt/tomcat/ssl).
3. Using below OpenSSL command generate pkcs12 file:
cd /opt/tomcate/ssl
openssl pkcs12 -export -in 10tut_blogspot_com.crt -inkey 10tut_blogspot_com.key -certfile intermediate.crt -out 10tut_blogspot_com.p12

Note: You will be prompted for a password to secure the certificate, please enter the password and remember the password.

4. Convert pkcs12 certificate to keystore:
You will now convert our 10tut_blogspot_com.p12 file to a keystore by performing the following command line in Tomcat using keytool:

keytool -importkeystore -srckeystore 10tut_blogspot_com.p12 -srcstoretype PKCS12 -destkeystore 10tut_blogspot_com.jks

Note: It will ask for password of the pkscs12 that we generated earlier and a new password for the keystore, remember the password that you have given for keystore you will need it in configuration.

That’s it !! Your keystore is generated and ready to be used at: /opt/tomcat/ssl/10tut_blogspot_com.jks.

5. Test the Keystore
You can test your keystore if its generated properly with below command:

$keytool -list -v -keystore 10tut_blogspot_com.jks

Enter keystore password:

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

Alias name: 1
Creation date: 29 Apr, 2016
Entry type: PrivateKeyEntry
Certificate chain length: 2
Certificate[1]:
Owner: CN=*.livfame.com, OU=Media - Technology, O=Fame Digital Pvt. Ltd., L=Mumbai, ST=Maharashtra, C=IN
Issuer: CN=thawte SSL CA - G2, O="thawte, Inc.", C=US
.....
Hope this blog helped you in converting Apache (x509 cert) SSL Certificate to Tomcat (Keystore). I will be continuing to post some more important related blogs.
Read More

Thứ Ba, 30 tháng 10, 2018

Ways to kill parent and child processes in one command

Ways to kill parent and child processes in one command
On linux, kill a process is simple, but sometimes, when something goes wrong, a process could fork hundreds and thousands child processes, you can either create a script to kill them all, or find some quick ways to kill them all in one command.

Here is the ways I use, some of them may not work on all linux distributions.

1.kill a group of processes with negative PID(Process ID)
kill  -TERM -PID
Is to kill PID and all its child processes.

2. kill a group of processes with their PGID(Process Group ID)
kill -- -$PGID   Kill using the default signal (TERM = 15)
kill -9 -$PGID   Kill using the KILL signal (9)
3. kill a group processes with only PID info
kill -- -$(ps -o pgid= $PID | grep -o [0-9]*)
Actually, you may notice that it's just the way from #2

4.Using pkill, kill processes by PGID(Proess Group ID)
pkill -9 -g $PGID
5.Using pkill, kill processes by GID(Group ID)
pkill -9 -G $GID
6.Using pkill, kill processes by PPID(Parent Process ID)
pkill -9 -p $PPID
7.Using pkill, kill processes by terminal
pkill -9 -t $terminal
Note: without /dev/ prefix

8.Using pkill, kill processes by process name
pkill -9 -x $process_name
9.Using pkill, kill processes by session
pkill -9 -s $sess
How to get PID,PGID,sessionid etc?
# ps -o pid,ppid,pgid,gid,sess,cmd -U root
  PID  PPID  PGID   GID  SESS CMD
Read More

Thứ Tư, 10 tháng 10, 2018

Apache Tomcat SSL Configuration

Configuring Tomcat To Use SSL

Setting up SSL for Tomcat can be pided into two main tasks: creating a functional keystore, and configuring the Tomcat connectors and applications. Let's tackle them one at a time.

PART I - The Keystore

Step 1 - Creating the Keystore

The keys Tomcat will use for SSL transactions are stored in a password-protected file called, creatively, the "keystore." The first step to enabling SSL on your server is to create and edit this file. You can create this file in one of two ways - by importing an existing key into the keystore, or by creating an entirely new key.
A program called keytool, which is included with your JDK, will do the actual work of creating your new keystore. To create a new keystore using this program, enter the following command at the command-line, substituting syntax appropriate for your OS:
$JAVA_HOME/bin/keytool -genkey -alias [youralias] -keyalg RSA -keystore [/preferred/keystore/path]
Use an [alias] and [path] of your choice.

Step 2 - Creating the Certificate Signing Request

Now that you've created your keystore, it's time to create a file called the Certificate Signing Request, or CSR, which will be used by the Certificate Authority of your choice to generate the Certificate SSL will present to other parties during the handshake.
You can use the keytool to create this file, as well. To do so, enter the following at the command line:
$JAVA_HOME/bin/keytool -certreq -keyalg RSA -alias [youralias] -file [yourcertificatname].csr -keystore [path/to/your/keystore]
Substitute the values you chose earlier for the [placeholders].
If you follow the instructions correctly, keytool will create a file called yourcertificatename.csr, which you can submit to the CA you've chosen via the process they provide on their website. Using this file, they will generate a custom certificate for your server, which you can download according to the instructions they provide on their website.

Step 3 - Installing Your New Certificate

Getting tired yet? Don't worry - there's light at the end of the tunnel. This is the last thing you'll need to do to create a keystore for Tomcat to use. Well, the last two things. Hang in there!
SSL verifies the authenticity of a site's certificate by using something called a "chain of trust," which basically means that during the handshake, SSL initiates an additional handshake with the Certificate Authority specified in your site's certificate, to verify that you haven't simply made up your own CA.
In order to "anchor" your certificate's chain of trust, you have to download an additional certificate, called a "Root Certificate," from your CA, and then import both this certificate and your site's new certificate into your keystore. Your CA should provide information about obtaining a Root Certificate on their website.
Once you've downloaded both your own Certificate and the Root certificate provided by your CA, import them into your keystore with the following commands, replacing the [placeholders]:
To import the Root Certificate -
keytool -import -alias root -keystore [path/to/your/keystore] -trustcacerts -file [path/to/the/root_certificate]
To import your new Certificate -
keytool -import -alias [youralias] -keystore [path/to/your/keystore] -file [path/to/your_keystore]
Do everything right? Then pat yourself on the back - you are now the proud owner of a functional, certified keystore.

Step 1 - Configuring Tomcat's SSL Connectors

Tomcat's global Connector options are configured in Tomcat's main configuration file, "$CATALINA_BASE/conf/server.xml", so you should open this file now. The Connectors we are looking for connect on port 8443 by default, so search for this port, until you come across an entry that looks like this:
 
<!-- Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the JSSE configuration, when using APR, the
connector should be using the OpenSSL style configuration
described in the APR documentation -->
<!--
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"/>
-->
You'll notice that the comment enclosing this connector talks about a choice between APR and JSSE configurations. This refers to the implementation of SSL you are intending to use. JSSE, which is Tomcat's default configuration, is supported by default, and included in all JDKs after version 1.4. So if you don't even know what APR is, you only need to uncomment this entry, and add some additional information to allow Tomcat to find your keystore:
<Connector port="8443" maxThreads="150" scheme="https" secure="true" SSLEnabled="true" keystoreFile="path/to/your/keystore" keystorePass="YourKeystorePassword" clientAuth="false" keyAlias="yourAlias" sslProtocol="TLS"/>
If, on the other hand, you know that using the Apache Portable Runtime (APR), also known as Tomcat's "native library," is by far the best practice to follow, especially when using Tomcat as a standalone web server (which you probably are), and have already installed it on your server, then you'll need to alter this entry as follows to allow Tomcat to use APR's OpenSSL implementation in place of JSSE, or trying to use SSL will generate an error:
<Connector port="8443" scheme="https" secure="true" SSLEnabled="true" SSLCertificateFile="/path/to/your/certificate.crt" SSLCertificateKeyFile="/path/to/your/keyfile" SSLPassword="YourKeystorePassword" SSLCertificateChainFile="path/to/your/root/certificate" keyAlias="yourAlias" SSLProtocol="TLSv1"/>
Notice that if you are using APR, the "SSLCertificateFile" and "SSLCertificateKey"-type attributes are used in place of the keystoreFile attribute. For more information on the differences between using APR in place of JSSE, consult Apache's Tomcat APR Documentation.
Restart Tomcat. Once you're up and running again, test your configuration by connecting to a secure page, using a URL such as https:/[yourhost]:8443. If you followed the directions correctly, you should be able to view the page over a secure HTTPS connection!

Step 2 - Limiting SSL Usage

Enabling SSL in Tomcat's server.xml file causes all files to be run both as secure and insecure pages, which can cause unnecessary server load. You can choose which applications offer SSL connections on a per-application basis by adding the following <security-constraint> element to the application's WEB-INF/web.xml file:
 
<security-constraint>
<web-resource-collection>
<web-resource-name>YourAppsName</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
This configuration allows you to set SSL options for all an application's pages in one place. For example, to disable SSL for all your application's pages, change "CONFIDENTIAL" to "NONE".

Additional Considerations

In the interest of simplicity, this guide does not cover all of the elements of SSL configuration (although they are covered extensively in Apache's Tomcat SSL Documentation). We will, however, provide you with a short list of other options and important areas of note to consider as you tweak your SSL configuration.

Specifying Implementation

If you have configured connectors for both APR and JSSE, Tomcat will use APR by default if you have installed the native libraries. You can force it to use JSSE by modifying a Connector's "protocol" attribute as follows:
<Connector protocol="org.apache.coyote.http11.HTTP11NioProtocol">
If you want to force APR, you can do so with a similar edit:
<Connector protocol="org.apache.coyote.http11.Http11AprProtocol">

Common Errors Caused By Aliases and Passwords

If you encounter any errors with your SSL configuration, make sure that you have correctly entered settings such as keystore passwords and aliases. These values are case sensitive for some of the supported keystore formats.



Read More

Thứ Năm, 4 tháng 10, 2018

How to Flush Memory Cache and Buffer Cache on Linux

Many times systems faced low memory issues of Linux systems running a while. The reason is that Linux uses so much memory for disk cache is because the RAM is wasted if it isn’t used. Cache is used to keep data to use frequently by the operating system. Reading data from cache if 1000’s time faster than reading data from hard drive.
It’s good for the os to get data from the cache in memory. But if any data not found in the cache, it reads from hard disk. So it’s no problem to flush cache memory. This article has details about how to Flush Memory Cache on Linux Server.

Clear Linux Memory Buffer Cache

There are three options available to flush the cache of Linux memory. Use one of below as per your requirements.
  • Free pagecache, dentries and inodes in cache memory
    sync; echo 3 > /proc/sys/vm/drop_caches
    
  • Free dentries and inodes use following command
    sync; echo 2 > /proc/sys/vm/drop_caches
    
  • Free pagecache only use following command
    sync; echo 1 > /proc/sys/vm/drop_caches
    

Schedule Cron to Flush Cache Regularly

It’s a good idea to schedule following in crontab to automatically flush cache on the regular interval. Use ‘crontab -e’ command to edit cron on your system.
crontab -l

0 * * *  * sync; echo 3 > /proc/sys/vm/drop_caches
The above cron will execute on every hour and flushes the memory cache on your system.

Find Cache Memory uses in Linux

Use free command to find out cache memory uses by Linux system. Output of free command is like below
free -m
Sample Output
             total       used       free     shared    buffers     cached
Mem:         16050      15908        142          0        120      14953
-/+ buffers/cache:        834      15216
Swap:            0          0          0
Last column is showing cached memory ( 14953 MB) by system. -m option is used for showing memory details in MB’s.
Read More

Thứ Ba, 25 tháng 9, 2018

How to merge worksheets / workbooks into one worksheet?

1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Sub Combine()
Dim J As Integer
On Error Resume Next
Sheets(1).Select
Worksheets.Add
Sheets(1).Name = "Combined"
Sheets(2).Activate
Range("A1").EntireRow.Select
Selection.Copy Destination:=Sheets(1).Range("A1")
For J = 2 To Sheets.Count
Sheets(J).Activate
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select
Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
Next
End Sub
3. Then press F5 key to run the code, and all the data in the workbook has been merged into a new worksheet named Combined which will add before all worksheets.
Read More

Thứ Ba, 18 tháng 9, 2018

Share LUN giữa các host

Từ bước 1 -> 5 các bước này thực hiện trên tất cả các host
1. Cài đặt
yum install pcs pacemaker fence-agents-all -y
2. allow firewall
# firewall-cmd --permanent --add-service=high-availability
# firewall-cmd --add-service=high-availability
3. Đặt passwork cho user hacluster
# passwd hacluster
4. Start pcsd
# systemctl start pcsd.service
# systemctl enable pcsd.service
5. Add authentication trên mỗi hosts
[root@ubqlvnn-app01-48  ~]# pcs cluster auth ubqlvnn-app01-48 ubqlvnn-app02-49 ubqlvnn-app03-50 ubqlvnn-app04-51
Username: hacluster
6. thực hiện trên 1 host -> create cluster
pcs cluster setup --start --name my_cluster ubqlvnn-app01-48 ubqlvnn-app02-49 ubqlvnn-app03-50 ubqlvnn-app04-51
7. Enable run cluster service mỗi khi reboot
pcs cluster enable --all
start cluster service manual bằng pcs cluster start
8.Kiểm tra trạng thái của cluster
[root@ubqlvnn-app03-50 ~]# pcs cluster status
Cluster Status:
 Stack: corosync
 Current DC: ubqlvnn-app02-49 (version 1.1.18-11.el7_5.3-2b07d5c5a9) - partition with quorum
 Last updated: Fri Aug 31 23:18:42 2018
 Last change: Fri Aug 31 23:18:07 2018 by hacluster via crmd on ubqlvnn-app02-49
 4 nodes configured
 0 resources configured

PCSD Status:
  ubqlvnn-app03-50: Online
  ubqlvnn-app02-49: Online
  ubqlvnn-app04-51: Online
  ubqlvnn-app01-48: Online

8. Cấu hình STONITH trên cluster trên mỗi host
 pcs stonith create myapc fence_apc_snmp ipaddr="ubqlvnn-app01-48" pcmk_host_map="ubqlvnn-app01-48:1;ubqlvnn-app02-49:2;ubqlvnn-app03-50:3;ubqlvnn-app04-51:4" login="apc" passwd="apc"
 pcs stonith create myapc fence_apc_snmp ipaddr="ubqlvnn-app02-49" pcmk_host_map="ubqlvnn-app01-48:1;ubqlvnn-app02-49:2;ubqlvnn-app03-50:3;ubqlvnn-app04-51:4" login="apc" passwd="apc"
 pcs stonith create myapc fence_apc_snmp ipaddr="ubqlvnn-app03-50" pcmk_host_map="ubqlvnn-app01-48:1;ubqlvnn-app02-49:2;ubqlvnn-app03-50:3;ubqlvnn-app04-51:4" login="apc" passwd="apc" 
 pcs stonith create myapc fence_apc_snmp ipaddr="ubqlvnn-app04-51" pcmk_host_map="ubqlvnn-app01-48:1;ubqlvnn-app02-49:2;ubqlvnn-app03-50:3;ubqlvnn-app04-51:4" login="apc" passwd="apc"
9. Cài đặt trên tất cả các hosts
  yum install lvm2-cluster gfs2-utils
10. Set the global Pacemaker parameter no_quorum_policy to freeze.
  pcs property set no-quorum-policy=freeze
11. tạo 1 dlm resource trên 1 hosts
pcs resource create dlm ocf:pacemaker:controld op monitor interval=30s on-fail=fence clone interleave=true ordered=true
12. Thực hiện các câu lệnh sau trên tất cả các host
  /sbin/lvmconf --enable-cluster
13. Tạo 1 clvmd  resources
pcs resource create clvmd ocf:heartbeat:clvm op monitor interval=30s on-fail=fence clone interleave=true ordered=true
14.Tạo constrain clvmd phải start sau dlm và phải chạy trên cùng 1 host dlm.
# pcs constraint order start dlm-clone then clvmd-clone
# pcs constraint colocation add clvmd-clone with dlm-clone
15. tạo lvm
# pvcreate /dev/sdb1
# vgcreate -Ay -cy cluster_vg /dev/sdb1
# lvcreate -L5G -n cluster_lv cluster_vg
16. format
mkfs.gfs2 -j4 -p lock_dlm -t my_cluster:gfs2 /dev/cluster_vg/cluster_lv
chú ý tùy chọn -j bằng số host muốn mount và my_cluster
17. Mount
pcs resource create clusterfs Filesystem device="/dev/cluster_vg/cluster_lv" directory="/mnt/shares" fstype="gfs2" "options=noatime" op monitor interval=10s on-fail=fence clone interleave=true
18. Tạo constraint clusterfs phải chạy sau clvmd, và phải cùng host clvmd
# pcs constraint order start clvmd-clone then clusterfs-clone
# pcs constraint colocation add clusterfs-clone with clvmd-clone
Read More

Thứ Hai, 17 tháng 9, 2018

Using Powershell list of websites IIS using get-website

C:\Users\Administrator>powershell -ExecutionPolicy Bypass
Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.

PS C:\Users\Administrator> import-module WebAdministration
PS C:\Users\Administrator> get-website | select name,id,state,physicalpath, @{n="Bindings"; e= { ($_.bindings | select -expa collection) -join ';' }} ,@{n="LogFile";e={ $_.logfile | select -expa directory}}, @{n="attributes"; e={($_.attributes | % { $_.name + "=" + $_.value }) -join ';' }} |Export-Csv -NoTypeInformation -Path C:\sites_list.csv
PS C:\Users\Administrator>
Read More

Thứ Sáu, 14 tháng 9, 2018

How To Reset Root Password CentOS 7

1 – In the boot grub menu select option to edit.
Selection_003
2 – Select Option to edit (e).
Selection_005
3 – Go to the line of Linux 16 and change ro with rw init=/sysroot/bin/sh.
Selection_006
4 – Now press Control+x to start on single user mode.
Selection_007
5 – Now access the system with this command.
chroot /sysroot
6 – Reset the password.
passwd root
7 – Update selinux information
touch /.autorelabel
8 – Exit chroot
exit
9 – Reboot your system
reboot
That’s it. Enjoy.
Read More

Thứ Ba, 14 tháng 8, 2018

Microsoft Visual C++ Redistributable All Versions Direct Download Links

Microsoft Visual C++ Redistributable is the library that is having components which are required by many Applications to run, and the Apps which you develop on Visual C++ require components of the Microsoft Visual C++ Redistributable. These packages are used to run the contents that are developed or written in the C++ programming language.
There are many Microsoft Redistributable packages installed on your System. You can view them by going to Control Panel/Programs/Apps and Features. And in the list of installed programs, you will see that there is more than one package of Microsoft Visual C++ Redistributable.

Visual C++ Direct Download Links

Choose your version for Redistributable according to your Windows version. If you are having 32 bit Windows, then download only 32-bit Microsoft Visual C++ Redistributable. And if you have installed 64-bit Windows, then you need to download both 32-bit and 64-bit versions of the Microsoft Visual C++ Redistributable.

Microsoft Visual C++ Redistributable 2017

Microsoft Visual C++ Redistributable 2015

Microsoft Visual C++ Redistributable 2013

Microsoft Visual C++ Redistributable 2012

Microsoft Visual C++ Redistributable 2010

Microsoft Visual C++ Redistributable 2008

Microsoft Visual C++ Redistributable 2005

The Uninstallation of the Microsoft Visual C++ Redistributor is same as you do with any other program. Go to Control Panel/Programs/Apps and Features. And double-click the program you want to uninstall and the program will uninstall.
Read More

Thứ Tư, 8 tháng 8, 2018

How To Install Java on CentOS and Fedora


Introduction
This tutorial will show you how to install Java on CentOS 7 (also 6 and 6.5), modern Fedora releases, and RHEL. Java is a popular software platform that allows you to run Java applications and applets.

The installation of the following versions of Java are covered:

OpenJDK 8
OpenJDK 7
OpenJDK 6
Oracle Java 9
Oracle Java 8
Feel free to skip to your desired section using the Contents button on the sidebar!

Prerequisites
Before you begin this guide, you should have a regular, non-root user with sudo privileges configured on both of your servers--this is the user that you should log in to your servers as. You can learn how to configure a regular user account by following the steps in our initial server setup guide for Centos 7.

Variations of Java
There are three different editions of the Java Platform: Standard Edition (SE), Enterprise Edition (EE), and Micro Edition (ME). This tutorial is focused on Java SE (Java Platform, Standard Edition).

There are two different Java SE packages that can be installed: the Java Runtime Environment (JRE) and the Java Development Kit (JDK). JRE is an implementation of the Java Virtual Machine (JVM), which allows you to run compiled Java applications and applets. JDK includes JRE and other software that is required for writing, developing, and compiling Java applications and applets.

There are also two different implementations of Java: OpenJDK and Oracle Java. Both implementations are based largely on the same code but OpenJDK, the reference implementation of Java, is fully open source while Oracle Java contains some proprietary code. Most Java applications will work fine with either but you should use whichever implementation your software calls for.

You may install various versions and releases of Java on a single system, but most people only need one installation. With that in mind, try to only install the version of Java that you need to run or develop your application(s).

Install OpenJDK 8
This section will show you how to install the prebuilt OpenJDK 8 JRE and JDK packages using the yum package manager, which is similar to apt-get for Ubuntu/Debian. OpenJDK 8 is the latest version of OpenJDK.

Install OpenJDK 8 JRE
To install OpenJDK 8 JRE using yum, run this command:

sudo yum install java-1.8.0-openjdk
At the confirmation prompt, enter y then RETURN to continue with the installation.

Congratulations! You have installed OpenJDK 8 JRE.

Install OpenJDK 8 JDK
To install OpenJDK 8 JDK using yum, run this command:

sudo yum install java-1.8.0-openjdk-devel
At the confirmation prompt, enter y then RETURN to continue with the installation.

Congratulations! You have installed OpenJDK 8 JDK.

Install OpenJDK 7
This section will show you how to install the prebuilt OpenJDK 7 JRE and JDK packages using the yum package manager.

Install OpenJDK 7 JRE
To install OpenJDK 7 JRE using yum, run this command:

sudo yum install java-1.7.0-openjdk
At the confirmation prompt, enter y then RETURN to continue with the installation.

Congratulations! You have installed OpenJDK 7 JRE.

Install OpenJDK 7 JDK
To install OpenJDK 7 JDK using yum, run this command:

sudo yum install java-1.7.0-openjdk-devel
At the confirmation prompt, enter y then RETURN to continue with the installation.

Congratulations! You have installed OpenJDK 7 JDK.

Install OpenJDK 6
This section will show you how to install the prebuilt OpenJDK 6 JRE and JDK packages using the yum package manager.

Install OpenJDK 6
To install OpenJDK 6 JRE using yum, run this command:

sudo yum install java-1.6.0-openjdk
At the confirmation prompt, enter y then RETURN to continue with the installation.

Congratulations! You have installed OpenJDK 6 JRE.

Install OpenJDK 6 JDK
To install OpenJDK 6 JDK using yum, run this command:

sudo yum install java-1.6.0-openjdk-devel
At the confirmation prompt, enter y then RETURN to continue with the installation.

Congratulations! You have installed OpenJDK 6 JDK.

Install Oracle Java 9
This section of the guide will show you how to install Oracle Java 9 JRE and JDK (64-bit), the latest release of these packages at the time of this writing.

Throughout this section we will be using the wget command to download the Oracle Java software packages. wget may not be included by default on your Linux distribution, so in order to follow along you will need to install it by running:

sudo yum install wget
Note: You must accept the Oracle Binary Code License Agreement for Java SE, which is one of the included steps, before installing Oracle Java.

Install Oracle Java 9 JRE
Note: In order to install Oracle Java 9 JRE, you wil need to go to the Oracle Java 9 JRE Downloads Page, accept the license agreement, and copy the download link of the appropriate Linux .rpm package. Substitute the copied download link in place of the highlighted part of the wget command.

Change to your home directory and download the Oracle Java 9 JRE RPM with these commands:

cd ~
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://link_copied_from_site"
Then install the RPM with this yum command (if you downloaded a different release, substitute the filename here):

sudo yum localinstall jre-9.0.4_linux_x64_bin.rpm
At the confirmation prompt, enter y then RETURN to continue with the installation.

Now Java should be installed at /usr/java/jre-9.0.4/bin/java, and linked from /usr/bin/java.

You may delete the archive file that you downloaded earlier:

rm ~/jre-9.0.4_linux_x64_bin.rpm
Congratulations! You have installed Oracle Java 9 JRE.

Install Oracle Java 9 JDK
Note: In order to install Oracle Java 9 JDK, you will need to go to the Oracle Java 9 JDK Downloads Page, accept the license agreement, and copy the download link of the appropriate Linux .rpm package. Substitute the copied download link in place of the highlighted part of the wget command.

Change to your home directory and download the Oracle Java 9 JDK RPM with these commands:

cd ~
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://link_copied_from_site"
Then install the RPM with this yum command (if you downloaded a different release, substitute the filename here):

sudo yum localinstall jdk-9.0.4_linux-x64_bin.rpm
At the confirmation prompt, enter y then RETURN to continue with the installation.

Now Java should be installed at /usr/java/jdk-9.0.4/bin/java, and linked from /usr/bin/java.

You may delete the archive file that you downloaded earlier:

rm ~/jdk-9.0.4_linux-x64_bin.rpm
Congratulations! You have installed Oracle Java 9 JDK.

Install Oracle Java 8
This section of the guide will show you how to install Oracle Java 8 JRE and JDK (64-bit).

Note: You must accept the Oracle Binary Code License Agreement for Java SE, which is one of the included steps, before installing Oracle Java.

Install Oracle Java 8 JRE
Note: In order to install Oracle Java 8 JRE, you will need to go to the Oracle Java 8 JRE Downloads Page, accept the license agreement, and copy the download link of the appropriate Linux .rpm package. Substitute the copied download link in place of the highlighted part of the wget command.

Change to your home directory and download the Oracle Java 8 JRE RPM with these commands:

cd ~
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://link_copied_from_site"
Then install the RPM with this yum command (if you downloaded a different release, substitute the filename here):

sudo yum localinstall jre-8u161-linux-x64.rpm
At the confirmation prompt, enter y then RETURN to continue with the installation.

Now Java should be installed at /usr/java/jre1.8.0_161/bin/java, and linked from /usr/bin/java.

You may delete the archive file that you downloaded earlier:

rm ~/jre-8u161-linux-x64.rpm
Congratulations! You have installed Oracle Java 8 JRE.

Install Oracle Java 8 JDK
Note: In order to install Oracle Java 8 JDK, you will need to go to the Oracle Java 8 JDK Downloads Page, accept the license agreement, and copy the download link of the appropriate Linux .rpm package. Substitute the copied download link in place of the highlighted part of the wget command.

Change to your home directory and download the Oracle Java 8 JDK RPM with these commands:

cd ~
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://link_copied_from_site"
Then install the RPM with this yum command (if you downloaded a different release, substitute the filename here):

sudo yum localinstall jdk-8u161-linux-x64.rpm
At the confirmation prompt, enter y then RETURN to continue with the installation.

Now Java should be installed at /usr/java/jdk1.8.0_161/jre/bin/java, and linked from /usr/bin/java.

You may delete the archive file that you downloaded earlier:

rm ~/jdk-8u161-linux-x64.rpm
Congratulations! You have installed Oracle Java 8 JDK.

Set Default Java
If you installed multiple versions of Java, you may want to set one as your default (i.e. the one that will run when a user runs the java command). Additionally, some applications require certain environment variables to be set to locate which installation of Java to use. This section will show you how to do this.

By the way, to check the version of your default Java, run this command:

java -version
Using Alternatives
The alternatives command, which manages default commands through symbolic links, can be used to select the default Java command.

To print the programs that provide the java command that are managed by alternatives, use this command:

sudo alternatives --config java
Here is an example of the output:

output
There are 5 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
   1           java-1.7.0-openjdk.x86_64 (/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.161-2.6.12.0.el7_4.x86_64/jre/bin/java)
   2           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64/jre/bin/java)
   3           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
*+ 4           /usr/java/jre-9.0.4/bin/java
   5           /usr/java/jdk-9.0.4/bin/java




Enter to keep the current selection[+], or type selection number:
Simply enter the a selection number to choose which java executable should be used by default.

Using Environment Variables
Many Java applications use the JAVA_HOME or JRE_HOME environment variables to determine which java executable to use.

For example, if you installed Java to /usr/java/jdk1.8.0_161/jre/bin (i.e. java executable is located at /usr/java/jdk1.8.0_161/jre/bin/java), you could set your JAVA_HOME environment variable in a bash shell or script like so:

export JAVA_HOME=/usr/java/jdk1.8.0_161/jre
If you want JAVA_HOME to be set for every user on the system by default, add the previous line to the /etc/environment file. An easy way to append it to the file is to run this command:

sudo sh -c "echo export JAVA_HOME=/usr/java/jdk1.8.0_161/jre >> /etc/environment"
Conclusion
Congratulations, you are now set to run and/or develop your Java applications!

Read More