The JDK is a development tool for building applications, applets, and components using the Java programming language . It includes a useful tool for developing and testing programs written in the Java programming language and runs on the Java platform. You can go through this document to know more about new enhancement of Java JDK 8. This post describe how to install JAVA 8 (JDK 8u45) on CentOS 6 and CentOS 7 from rpm package.
1. Download Oracle Java 8 rpm from official website (64 bit):
One recommended way to manage virtual private server (VPS) or a dedicated linux server is not using the root account as the main access for SSH login. This is because usually the hackers will try to brute force your root password and potentially get access to your server. Instead of using the default root account, you can create a new account and assign root privileges to it and issue the sudo command line to root from it. Please make sure that the normal user account given root privileges accounts work properly before you disable the default root login access. The following command has been tested works on CentOS 6, CentOS 7, RHEL 6 and RHEL 7 VPS.
1. Create new account named skytech and set the password :
[root@vps ~]# useradd skytech
[root@vps ~]# passwd skytech
Changing password for user skytech.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
2. Grant a New User to Root Privileges
[root@vps ~]# visudo
Add the following code at the bottom of the file and save the file with the command :wq :
## Allow skytech user to run any commands anywhere
skytech ALL=(ALL) ALL
This will grant a root privileges to the normal user skytech.
I have a virtual private server (VPS) and plans to run a WordPress blog in it. A limited amount of RAM and swap size will be an issue because some software applications like MySQL, Apache, NGINX, PHP, HHVM and Varnish requires more memory to operate.
From my past experience in Ubiquity Hosting and Linode, the pre-allocated swap sizes of 2GB and 1GB VPS are 1GB and 512MB only. After switched to 2GB plan for RamNode VPS, linux swap also provided in the size of 1GB.
Why we need Linux Swap Space ?
To make your server more responsive and prevent crash when it runs out of memory, giving additional linux swap space will help. Linux swap is an area on the storage or hard disk where the operating system can temporarily store data that it no longer can hold in memory. Without the Linux swap, the VPS that runs out of memory can crash or start kill some applications to free up memory. This can cause lose for unsaved data or experience downtime.
However, swapping does have drawbacks. Reading from and writing to swap is slower than using memory. But swapping should take advantages on the SSD server. In the hard disk drive, If VPS started using linux swap space, the VPS performance can slow down significantly.
As a reference for webmasters and system administrators, here are the steps on how to increase the size of the linux swap on CentOS 6 VPS. This steps may also works and tested on CentOS 7 / RHEL 7 and oracle linux 7.
1. Check and verify the allocated disk partition for swap using “fdisl -l” command :
[root@vps ~]# fdisk -l
Disk /dev/vda: 53.7 GB, 53687091200 bytes
16 heads, 63 sectors/track, 104025 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00059ca1
Device Boot Start End Blocks Id System
/dev/vda1 * 3 1018 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1018 3099 1048576 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/vda3 3099 104023 50865920 83 Linux
Partition 3 does not end on cylinder boundary.
2. From the operating system, verify the swap size from command line utility “swapon -s” and “free -m“. The current swap size is 1GB :
[root@vps ~]# swapon -s
Filename Type Size Used Priority
/dev/vda2 partition 1048568 0 -1
3. Start Create the Swap file by determine the size of the new swap file and assign the swap file name. At a shell prompt as root, type the following dd command with count being equal to the desired block size. As an example i will add 2048MB as additional space size and assigned swap file name is /swapfile-ext.
[root@vps ~]# dd if=/dev/zero of=/swapfile-ext bs=1M count=2048
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 4.05978 s, 529 MB/s
4. Creating a linux swap area with mkswap command :
[root@vps ~]# mkswap /swapfile-ext
mkswap: /swapfile-ext: warning: don't erase bootbits sectors
on whole disk. Use -f to force.
Setting up swapspace version 1, size = 2097148 KiB
no label, UUID=cc49d098-52e3-4fdf-8157-c40b23e00eef
5. Assign the correct permission to prevent swap space from world-readable :
[root@vps ~]# chmod 600 /swapfile-ext
6. Activatethe swap file immediately :
[root@vps ~]# swapon /swapfile-ext
7. Verify by viewing the output using “free -m” utility. 1GB plus 2GB equal to 3GB new swap size :
On this day, Nginx web server is reported to be a most popular and fastest in the internet if installed properly. But it should always be updated from time to time in order to maintain stability and high security so that is not exposed to hackers. For system administrators and web masters, it is routine to constantly update the software Nginx if the latest version is launched on their official website, nginx.org. In this tutorial , I will explain how to remove the Nginx that was installed from source on CentOS 6/RHEL 6.
Red Hat Enterprise Linux 7 (RHEL 7) and CentOS 7 come with the new naming scheme for the network devices.
These features change the name of network interfaces on a system in order to make the network interfaces fully predictable, fully automatic, easier to differentiate and that broken hardware can be replaced seamlessly.
This affects both network adapters embedded on the motherboard (Lan-on-Motherboard, or additional adapters such as PCI network card and etc.
Traditionally, network interfaces in Linux used eth[0123…]. In RHEL7/CentOS7, the default network interface name is based on firmware, topology, and location information.
The following different naming schemes for network interfaces are now supported by udev natively:
Names incorporating Firmware or BIOS provided index numbers for on-board devices (example: eno1)
Names incorporating Firmware or BIOS provided PCI Express hotplug slot index numbers (example: ens1)
Names incorporating physical location of the connector of the hardware (example: enp2s0)
Names incorporating the interface’s MAC address (example:enx78e7d1ea46da)
The traditional unpredictable kernel-native ethX naming (example: eth0)
The names have two character prefixes based on the type of interface:
ifconfig utility is not installed by default in minimal installation. You can use “ip link show“, “ip addr” or “ip address” to display the auto assigned devices name :
[root@centos7 ~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000
link/ether 00:0c:29:ba:3e:fe brd ff:ff:ff:ff:ff:ff
[root@centos7 ~]# ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 00:0c:29:ba:3e:fe brd ff:ff:ff:ff:ff:ff
inet 192.168.0.18/24 brd 192.168.0.255 scope global dynamic ens160
valid_lft 604707sec preferred_lft 604707sec
inet6 fe80::20c:29ff:feba:3efe/64 scope link
valid_lft forever preferred_lft forever
This post will show you the list of ldapsearch examples for 389 Directory. This ldapsearch examples assumes the following:
a)This ldapsearch is search for uid in the directory. b)The 389 directory is configured to not support anonymous access, then the user “Directory Manager” and the password is required c)This ldapsearch command has been run on the 389 server itself, so “localhost” for host is enough. d)The server uses port number 389. Since this is the default port, the port number does not have to be sent in the search request.
-D binddn bind DN
-b basedn base dn for search
-h host LDAP server
-w passwd bind password (for simple authentication)
-W prompt for bind password (Recommended to use this to hide password)
This post assumed that we will change the System Timezone from the command line without using redhat-config-date.
There are several files and directories that are used for time zones. In RHEL 6 and RHEL 6, there is one directory that very useful to select the appropriate time zone which is /usr/share/zoneinfo directory.
Sometimes we forget to set the correct time zone for the new linux system. This quick steps show how to change timezone on RHEL 6/7 and CentOS 6/7.
/usr/share/zoneinfo – this directory contains the System Timezone files that were compiled by zic. These are binary files and cannot be viewed with a text viewer. The files contain information such as rules about DST. They allow the kernel to convert UTC UNIX time into appropriate local dates and times.
In order to change the System Timezone of your system you will need to access the file or configuration using root.
How to Change Timezone Linux on RHEL / CentOS
1) How to list all available time zone on RHEL 6 / CentOS 6:
#ls /usr/share/zoneinfo
2) How to list all available time zone on RHEL 7 / CentOS 7:
3) How to check timezone in linux RHEL 6 / CentOS 6 :
# cat /etc/sysconfig/clock
4) How to check timezone in linux RHEL 7 / CentOS 7 :
# timedatectl status
Local time: Thu 2017-01-05 20:00:22 MYT
Universal time: Thu 2017-01-05 12:00:22 UTC
RTC time: n/a
Time zone: Asia/Kuala_Lumpur (MYT, +0800)
NTP enabled: n/a
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
5) How to Change Timezone Linux RHEL 6 / CentOS 6 :
Question : How to mount CDROM/DVDROM media on linux CentOS server ?
Solution : In certain situations, system administrators will need to mount cdrom containing the installer or data on linux CentOS or RHEL. Once cdrom mounted, they can access the data in the media discs directly. For reference, here is the easy way to do it through the command line on Linux CentOS 5 or CentOS 6 or CentOS 7 :
Note : This example will mount the device /dev/cdrom to /mnt.
[root@centos6 ~]# mount /dev/cdrom /mnt
Examples :
[root@centos6 ~]# mount /dev/cdrom /mnt
mount: block device /dev/sr0 is write-protected, mounting read-only
Tcpdump is a packet sniffer that able to capture traffic that passes through a machine. It operates on a packet level, meaning that it captures the actual packets that fly in and out of your computer. It can save the packets into a file. In this post, i will show how to install tcpdump on CentOS 5/CentOS 6/ CentOS 7/RHEL 5/RHEL 6/ RHEL 7 server. You can proceed to read the example usage of tcpdump in this article.
How to Install tcpdump on CentOS / RHEL
1. Run any tcpdump command to check whether tcpdump installed or not :
[root@centos62 ~]# tcpdump -D
-bash: tcpdump: command not found
2. To install tcpdump, simply run the following command :
[root@centos62 ~]# yum install tcpdump -y
3. Show available interface that can be monitor :
# tcpdump -D
1.eth0
2.usbmon1 (USB bus number 1)
3.usbmon2 (USB bus number 2)
4.any (Pseudo-device that captures on all interfaces)
5.lo
During the deployment of Samba and NFS services on one of the RHEL 6 server, I’m hit by this message when trying to start, stop and restart service portmap :
[root@rhel6 ~]# service portmap start
portmap: unrecognized service
Answer : Portmap is replaced by rpcbind on some linux distributions such as Fedora 8,RHEL 6 and CentOS 6. Portmap is now started and stopped as part of the rpcbind service. You may not able to find the portmap service, but you can see rpcbind instead. http://www.archlinux.org
Command line below provides the required dependency packages. It can also be used to track a package containing a specific executable :
[root@rhel6 ~]# yum whatprovides portmap
Loaded plugins: rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
rpcbind-0.2.0-8.el6.i686 : Universal Addresses to RPC Program Number Mapper
Repo : DVD-RHEL6-Repository
Matched from:
Other : portmap
rpcbind-0.2.0-8.el6.i686 : Universal Addresses to RPC Program Number Mapper
Repo : installed
Matched from:
Other : Provides-match: portmap
When you try to install portmap on RHEL 6, it will install rpcbind instead :
[root@rhel6 ~]# yum install portmap -y
Loaded plugins: rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Package rpcbind-0.2.0-8.el6.i686 already installed and latest version
Nothing to do
What is Portmap : Portmap is a server that converts RPC (Remote Procedure Call) program numbers into DARPA protocol port numbers. It must be running in order to make RPC calls. Server services that use RPC include NFS, NIS and Samba. When an RPC server is started, it will tell portmap what port number it is listening to, and what RPC program numbers it is prepared to serve. When a client wishes to make an RPC call to a given program number, it will first contact portmap on the server machine to determine the port number where RPC packets should be sent. Therefore, portmap must be started before any RPC servers are invoked. This because RPC-based services rely on portmap to make all connections with incoming client requests.
What is rpcbind : rpcbind is a server that converts RPC program numbers into universal addresses. It must be running on the host to be able to make RPC calls on a server on that machine. When an RPC service is started, it tells rpcbind the address at which it is listening, and the RPC program numbers it is prepared to serve. When a client wishes to make an RPC call to a given program number, it first contacts rpcbind on the server machine to determine the address where RPC requests should be sent. rpcbind should be started before any other RPC service. Normally, standard RPC servers are started by port monitors, so rpcbind must be started before port monitors are invoked.
Server service that use RPC : 1. NFS NFS uses Remote Procedure Calls (RPC) to route requests between clients and servers, meaning that the portmap service must be enabled and active at the proper runlevels for NFS communication to occur.
2. Samba Samba is an Open Source software that based on the common client/server protocol of Server Message Block (SMB) and Common Internet File System (CIFS). It’s allows end users to access and use files, printers and sharing the company resources.
Example portmap instance The rpcinfo command shows each RPC-based service with its port number, RPC program number, version, and IP protocol type (TCP or UDP). This is to make sure the proper NFS RPC-based services and portmapper are enabled for portmap.
[root@rhel6 ~]# rpcinfo -p
program vers proto port service
100000 4 tcp 111 portmapper
100000 3 tcp 111 portmapper
100000 2 tcp 111 portmapper
100000 4 udp 111 portmapper
100000 3 udp 111 portmapper
100000 2 udp 111 portmapper
100024 1 udp 56670 status
100024 1 tcp 54564 status
In this article, I will share about how to update and install RPM packages from the image CD-ROM/DVD-ROM in Red Hat Enterprise Linux 6 (RHEL 6). This step can also be used on CentOS 6 or older versions such as CentOS 5. It would be very useful if the server you have a slow internet connection, or no internet connection. Instead of using internet connection directly to RHEL repositories registered, it is possible to use the Local CD/DVD- ROM as your yum repository. There are two methods to install and configure local yum repository RHEL 6. Both methods have been tested and works well on Linux RHEL 6 server. You can choose whichever method you choose :
Method 1: 1. Insert DVD/ISO into DVD-Drive. 2. Mount the ISO from the DVD-ROM into /mnt directory :
[root@rhel6 ~]# mount /dev/cdrom /mnt
mount: block device /dev/sr0 is write-protected, mounting read-only
3. Check the existing partition on your RHEL 6 server :
[root@rhel6 ~]# yum install httpd
Loaded plugins: rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
RHEL6-Repository | 1.3 kB 00:00 ...
RHEL6-Repository/primary | 5.4 MB 00:00 ...
RHEL6-Repository 13395/13395
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.i686 0:2.2.15-5.el6 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================
Package Arch Version Repository Size
====================================================================================================
Installing:
httpd i686 2.2.15-5.el6 RHEL6-Repository 813 k
Transaction Summary
====================================================================================================
Install 1 Package(s)
Upgrade 0 Package(s)
Total download size: 813 k
Installed size: 2.8 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : httpd-2.2.15-5.el6.i686 1/1
Installed:
httpd.i686 0:2.2.15-5.el6
Complete!
useradd is a low-level utility to create new users to the system. When used without the -D option, useradd command will create a new user account using the command line plus the default values ??of the system. Depending on the command line option, useradd command will update system files and also can create new user’s home directory. In this article, I will explain to you how to create a user then add it to the particular group in CentOS 5 and CentOS 6. Prior to that , this article assumes that the server CentOS 5 or CentOS 6 has been fully installed.
1. Add a new user. In this example, the username will be ‘myroot‘.
[root@CentOS57 ~]# useradd myroot
[root@CentOS57 ~]# passwd myroot
Changing password for user myroot.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
2. Check current groups for ‘root‘ user.
[root@CentOS57 ~]# groups
root bin daemon sys adm disk wheel
3. Add ‘myroot‘ into root group as below: useradd -G {group-name} username
[root@CentOS57 ~]# usermod -G root myroot
Above is example, we are adding a user ‘myroot‘ into group ‘root‘.
4. Switch to ‘myroot‘ user. Then Check current group for ‘myroot‘. root group will be the second group for ‘myroot’.
[root@CentOS57 ~]# su - myroot
[myroot@CentOS57 ~]$ groups
myroot root