How to Configure FTP Server in Linux RHEL 6

In this post i will show how to install Very Secure FTP (Vsftpd) and how to configure ftp server in linux Red Hat Enterprise Linux 6 (RHEL 6). Vsftpd is a GPL licensed FTP server for UNIX systems, including Linux. It is secure and extremely fast and it is stable.

As an example I will install and configure the vsftpd server and will also transfer files from the clients running on the Windows XP command prompt.

-A linux server with ip address 192.168.1.43 running on RHEL 6 Operating system
-A window client with ip address 192.168.1.52 running on Windows XP Pro
-RHEL 6 server Running portmap/rpcbind and xinetd services
-Firewall and SElinux should be off on server

how to configure ftp server in linux

How to Install FTP Server in Linux ?

1. Install vsftpd, rpcbind and xinetd service using the following command :

# yum install vsftpd rpcbind xinetd -y

2. Check vsftpd, xinetd and rpcbind/portmap exist and installed on the server :

# rpm -qa vsftpd
vsftpd-2.2.2-6.el6.i686

# rpm -qa xinetd
xinetd-2.3.14-29.el6.i686

# rpm -qa rpcbind
rpcbind-0.2.0-8.el6.i686

3. Make all these services auto start at boot :

# chkconfig vsftpd on
# chkconfig xinetd on
# chkconfig rpcbind on

4. Check the xinetd and rpcbind status :

# service xinetd status
xinetd (pid  1326) is running...

# service rpcbind status
rpcbind (pid  1178) is running...

5. Create the a new user named ftpuser and set password :

# useradd ftpuser
# passwd ftpuser
Changing password for user ftpuser.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

6. Login as ftpuser on other terminal and create a new files named “files”.

# su - ftpuser
[ftpuser@rhel6 ~]$ cat > files
This is file created on RHEL 6 ftp server

7. Start the vsftpd service :

# service vsftpd start
Starting vsftpd for vsftpd:                                [  OK  ]

8. Stop the iptables linux firewall and disabled selinux :

# service ip6tables stop
ip6tables: Flushing firewall rules:                        [  OK  ]
ip6tables: Setting chains to policy ACCEPT: filter         [  OK  ]
ip6tables: Unloading modules:                              [  OK  ]

# service iptables stop
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
# setenforce 0
setenforce: SELinux is disabled

How to Configure FTP Server in Linux ?

9. It’s good to make backup of your original configuration file.

[root@rhel6 ~]# cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf-bak

10. login from user account and download the files :

D:\>ftp 192.168.1.43
Connected to 192.168.1.43.
220 (vsFTPd 2.2.2)
User (192.168.1.43:(none)): ftpuser
331 Please specify the password.
Password:
230 Login successful.
ftp> get files
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for files (42 bytes).
226 Transfer complete.
ftp: 42 bytes received in 0.00Seconds 42000.00Kbytes/sec.
ftp> quit
221 Goodbye.

11. Check the contain of downloaded files :

D:\>type files
This is file created on RHEL 6 ftp server

12. By default root account is not allowed to login the vsftpd server as it’s exist in /etc/vsftpd/ftpusers.

D:\>ftp 192.168.1.43
Connected to 192.168.1.43.
220 (vsFTPd 2.2.2)
User (192.168.1.43:(none)): root
530 Permission denied.
Login failed.
ftp>

13. Open /etc/vsftpd/ftpusers file. Remove or comment out the line for user “root” and add “ftpuser” instead. Users whose name are set in this file will not allowed to login from ftp.

[root@rhel6 ~]# vi /etc/vsftpd/ftpusers
# Users that are not allowed to login via ftp
#root
ftpuser
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody

14. Open /etc/vsftpd/user_list file. Remove or comment out entry in /etc/vsftpd/user_list files. Remove or comment out the line for user “root” and add “ftpuser” instead. Users whose names are set in this file are also not allowed to login from ftp even they are not prompt for password.

# vi /etc/vsftpd/user_list
# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.
#root
ftpuser
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody

15. Root now allowed to access ftp server :

D:\>ftp 192.168.1.43
Connected to 192.168.1.43.
220 (vsFTPd 2.2.2)
User (192.168.1.43:(none)): root
331 Please specify the password.
Password:
230 Login successful.
ftp> quit
221 Goodbye.

16. ftpuser now not allowed to access ftp server :

D:\>ftp 192.168.1.43
Connected to 192.168.1.43.
220 (vsFTPd 2.2.2)
User (192.168.1.43:(none)): ftpuser
530 Permission denied.
Login failed.
ftp>

17. How to set login banner for ftp server :
Open /etc/vsftpd/vsftpd.conf look for “ftpd_banner” :

# vi /etc/vsftpd/vsftpd.conf

Uncomment ftpd_banner and customize the login banner string as below :

# You may fully customise the login banner string:
ftpd_banner=Welcome to eHowStuff.com RHEL6 FTP server
#

18 Restart the ftp service :

# service vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]

19. Try login to ftp server. Check the banner, it will appear before user login as below :

D:\>ftp 192.168.1.43
Connected to 192.168.1.43.
220 Welcome to eHowStuff.com RHEL6 FTP server
User (192.168.1.43:(none)):

If you encounter any issues on how to configure ftp server in linux, you can put a few questions in the comments below.

How to a Add and Remove User Account on RHEL 6/7, CentOS 6/7, Oracle Linux 6/7

This article will explain and share how to add and remove user account with useradd(add) and userdel (remove) from the command-line on linux RHEL 6/7, CentOS 6/7, Oracle Linux 6/7 server.

1. Adding a New User to an Linux System.

a) Get the useradd manual :

# man useradd
useradd - create a new user or update default new user information

b) To creates the new account and the /home/john home directory :

# useradd --home /home/ehowstuff ehowstuff

c) useraddd command does not set any valid password by default, and user cannot log in until a password is set.To set the password user the following command :

# passwd ehowstuff
Changing password for user ehowstuff.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

d) Verify the values in /etc/password :

# cat /etc/passwd | grep ehowstuff
ehowstuff:x:501:501::/home/ehowstuff:/bin/bash

e) Verify the values in /etc/group :

# cat /etc/group | grep ehowstuff
ehowstuff:x:501:

f) Verify email user created for id ehowstuff :

# ls /var/spool/mail | grep ehowstuff
ehowstuff

More useradd options :

-c, –comment COMMENT
Add a value, such as a full name, to the GECOS field.

-g, –gid GROUP
Specify the primary group for the user account.

-G, –groups GROUPS
Specify a list if supplementary groups for the user account.

-a, –append
Used with the -G option to append the user to the supplemental groups mentioned without removing the user from other groups.

-d, –home HOME_DIR
Specify a new home directory to a new location. Must be used with the -d option.

-m, –move-home
Move a user home directory to a new location. Must be used with the -d option.

-s, –shell SHELL
Specify a new login shell for the user account.

-L, –lock
Lock a user account.

-U, –unlock
Unlock a user account.

2. Deleting a User from an Linux System.

a) Get userdel manual :

# man userdel
userdel - delete a user account and related files

b) userdel username removes the user from /etc/passwd, but leaves the home directory intact by default. Proper command to remove the user’s account, user’s home directory and mail spool as part of the deletion process :

# userdel --remove ehowstuff

or

# userdel -r ehowstuff

Warning :
When a user is removed with userdel without the -r option specified, the system will have files that are owned by an unassigned user ID number. This can also happen when files created by a deleted user exist outside their home directory. This situation can lead to information leakage and other security issues.

 

How to Enable EPEL and Remi Repository into CentOS 6

EPEL stand for Extra Packages for Enterprise Linux. EPEL repository is a Fedora Special Interest Group that creates, maintains, and manages a high quality set of additional packages for Enterprise Linux, including, but not limited to, Red Hat Enterprise Linux (RHEL), CentOS and Scientific Linux (SL), Oracle Enterprise Linux(OEL). Remi repository is a yum repository maintained by a French dude – Remi Collet. This post describe the basic steps to prepare and install the additional CentOS packages with EPEL and Remi Repository into CentOS 6.

EPEL Repository

rpm --import https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6
rpm -Uvh https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Remi Repository

rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

Example :

[root@centos6 ~]# rpm --import https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6
[root@centos6 ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Retrieving https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]
[root@centos6 ~]# rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
[root@centos6 ~]# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Retrieving http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Preparing...                ########################################### [100%]
   1:remi-release           ########################################### [100%]

Example of EPEl and Remi repo usage :

[root@centos6 ~]# yum --enablerepo=epel install httpd -y
[root@centos6 ~]# yum --enablerepo=remi install httpd -y

How to Add Network Adapter Without Reboot on CentOS 6/RHEL 6

This article will explain how to prepare more than one network interface on a VMware virtual machine (VM) without reboot the linux server. Normally, a network interface is sufficient to run a linux server. To ensure a balance of traffic or to enable multiple network segments in a VM, it is advisable to install more than one interface card. It was assumed that the card eth0 is configured properly and working. The process of adding a second network interface card is very easy in VMware ESXi / ESX and VMware workstation. What you need is through the vCenter or ESXi host, start the add hardware wizard and then select “Network Adapter” and let the wizard complete successfully. The following are the tested steps on CentOS 6.4 and may be applied on CentOS 6.5 and CentOS 6.6 operating system.

1. Check existing network setting.

[root@centos64 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:F1:24:F0
          inet addr:192.168.2.62  Bcast:192.168.255.255  Mask:255.255.0.0
          inet6 addr: fe80::20c:29ff:fef1:24f0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:735 errors:0 dropped:0 overruns:0 frame:0
          TX packets:81 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:72242 (70.5 KiB)  TX bytes:8635 (8.4 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

2. Enter network configuration folder, and look for ethx file. By default, first network interface will start with eth0. Next added network adapter will be eth1.

[root@centos64 ~]# cd /etc/sysconfig/network-scripts/
[root@centos64 network-scripts]# ls
ifcfg-eth0   ifdown-ippp  ifdown-routes  ifup-bnep  ifup-plip    ifup-sit          network-functions
ifcfg-lo     ifdown-ipv6  ifdown-sit     ifup-eth   ifup-plusb   ifup-tunnel       network-functions-ipv6
ifdown       ifdown-isdn  ifdown-tunnel  ifup-ippp  ifup-post    ifup-wireless
ifdown-bnep  ifdown-post  ifup           ifup-ipv6  ifup-ppp     init.ipv6-global
ifdown-eth   ifdown-ppp   ifup-aliases   ifup-isdn  ifup-routes  net.hotplug

3. After you add secondary network interface from VMware level, the file will automatically added the mac address in /etc/udev/rules.d/70-persistent-net.rules. Please take note on the mac address for eth1.

[root@centos64 ~]# more /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:f1:24:f0", ATTR{type}=="1", KERNEL=="
eth*", NAME="eth0"

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:f1:24:fa", ATTR{type}=="1", KERNEL=="
eth*", NAME="eth1"

4. Now you need to create the configuration file for your new interface. The network interface configuration files are placed in /etc/sysconfig/network-scripts/. change the mac address according based on /etc/udev/rules.d/70-persistent-net.rules.

[root@centos64 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1

Add below setting :

DEVICE=eth1
HWADDR=00:0c:29:f1:24:fa
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=192.168.2.63
NETMASK=255.255.0.0

5. Based on the type interface being added, issue an ifup command. In this case, we have added eth1.

[root@centos64 ~]# ifup eth1

6. Verify new Network interfaces :

[root@centos64 ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:0C:29:F1:24:F0
          inet addr:192.168.2.62  Bcast:192.168.255.255  Mask:255.255.0.0
          inet6 addr: fe80::20c:29ff:fef1:24f0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8019 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6949 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:804606 (785.7 KiB)  TX bytes:694075 (677.8 KiB)

[root@centos64 ~]# ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 00:0C:29:F1:24:FA
          inet addr:192.168.2.63  Bcast:192.168.255.255  Mask:255.255.0.0
          inet6 addr: fe80::20c:29ff:fef1:24fa/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:450 errors:0 dropped:0 overruns:0 frame:0
          TX packets:23 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:40087 (39.1 KiB)  TX bytes:1182 (1.1 KiB)

4 Top Command Howto on Linux RHEL 6/CentOS 6

In this article, i will help you to explore most frequently used top commands that linux system administrator use when analyzing the linux performance and use for daily system administrative jobs. Top command displays system summary information such as tasks currently being managed by the Linux kernel, displays ongoing look at processor activity in real time and will displays a listing of the most CPU-intensive tasks on the system. It also will show the processor and memory are being used and other information like running processes. It will help you to summarize how much of your system’s resources are taking up.

1. How to display top command result :

[root@rhel6 ~]# top

top
This command will show information like tasks, memory, cpu load average, swap and number of users. Press ‘q’ to quit window.

2. How to display selected user using top -u :

[root@rhel6 ~]# top -u apache

top

3. How to display specific process with given PIDs Using top -p(e.g PID 2449, 2450) :

[root@rhel6 ~]# top -p 2449,2450

top

4. How to quit top command after a specified number of iterations :

[root@rhel6 ~]# top -n 10

This top command will automatically exit after 10 number of repetition.

How to Check and Display Runlevel on Unix or Linux System

This example shows the correct ways to check run level on unix or linux server. The runlevel is a software configuration of the system which allows only a selected group of processes to exist. The processes spawned by init command/process for each of these runlevels are defined in the /etc/inittab file. Usually runlevel 0, 1 and 6 are the same and reserved for the following purposes :

0 – halt
1 – single mode
6 – reboot

Meanwhile runlevel 2,3,4 and 5 used for the following :

2 – Multi-User Mode
3 – Multi-User Mode with Networking
4 – Not used/User-definable
5 – Start the system normally with appropriate display manager. ( with GUI )

1. Check and display runlevel using “who” command :

[root@centos62 ~]# who -r
         run-level 3  2012-07-07 09:58

2. Check and display current and previous system runlevel using “runlevel” command :

[root@centos62 ~]# runlevel
N 3

How to Switching or Changing Between Different Runlevels on Linux

How to Properly Shutdown and Reboot Linux CentOS 5/CentOS 6/RHEL 5/RHEL 6

This post will show you the proper command to shutdown and reboot the linux server. To shut down Red Hat Enterprise Linux(RHEL) and CentOS, the root user may issue the /sbin/shutdown command. All the command has been tested on CentOS 6.2 but may workings on other CentOS and RHEL version. The shutdown man page has a complete list of options, but the two most common uses are:

Example 1. How to Properly Shutdown CentOS 5/CentOS 6/RHEL 5/RHEL 6 :

[root@centos62 ~]# /sbin/shutdown -h now

Example 2. How to Properly Reboot CentOS 5/CentOS 6/RHEL 5/RHEL 6 :

[root@centos62 ~]# /sbin/shutdown -r now

After shutting everything down, the -h option halts the machine, and the -r option reboots.

These are another useful shutdown command :

Example 3. To shutdown in next 10 minutes:

[root@centos62 ~]# /sbin/shutdown -h +10

Example 4. To reboot in next 10 minutes:

[root@centos62 ~]# /sbin/shutdown -r +10

Example 5. To shutdown the server in next 3 seconds :

[root@centos62 ~]# /sbin/shutdown -t3 -r now

The option “-t3” tells the shutdown command to wait 3 seconds before it starts killing processes.

Example 6. Resheduled to shutdown the server at 12:15 :

login as: root
root@192.168.1.44's password:
Last login: Fri Jun  1 12:05:27 2012 from 192.168.1.52
[root@centos62 ~]# date
Fri Jun  1 12:12:00 MYT 2012
[root@centos62 ~]# /sbin/shutdown -r 12:15

Broadcast message from root@centos62.ehowstuff.local
        (/dev/pts/0) at 12:12 ...

The system is going down for reboot in 3 minutes!

Broadcast message from root@centos62.ehowstuff.local
        (/dev/pts/0) at 12:13 ...

The system is going down for reboot in 2 minutes!

Broadcast message from root@centos62.ehowstuff.local
        (/dev/pts/0) at 12:14 ...

The system is going down for reboot in 1 minute!

How to Change Timezone Linux on RHEL 6/7 and CentOS 6/7

change timezone linux

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:

# timedatectl list-timezones | grep Asia
Asia/Aden
Asia/Almaty
Asia/Amman
..
..
Asia/Kuala_Lumpur

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 :

Edit ZONE= to the following:

# cat /etc/sysconfig/clock
ZONE="Asia/Kuala_Lumpur"

Create a new soft link to your time zone :

# mv /etc/localtime /root/localtime.old
# ln -sf /usr/share/zoneinfo/Asia/Kuala_Lumpur /etc/localtime

6) How to Change Timezone Linux RHEL 7 / CentOS 7 :

timedatectl set-timezone Asia/Kuala_Lumpur

7) How to Display current date and time and timezone :

# date
Thu Jan  5 19:54:38 MYT 2017

Reference :

How to Grep Multiples Lines and using Specific Keyword on Linux

grep is a command line text search utility originally written for Unix or linux. In linux you can grep multiple lines before or after matching the keywords. This examples has been tested on linux CentOS 6.2, but it may workings on other linux version such as Redhat Enterprise Linux 5 (RHEL5) or (RHEL6).

Get grep command help :

[root@centos62 ~]# grep --help

Example :

Context control:
  -B, --before-context=NUM  print NUM lines of leading context
  -A, --after-context=NUM   print NUM lines of trailing context
  -C, --context=NUM         print NUM lines of output context
  -NUM                      same as --context=NUM

Assumed that you have exported all log for 29 March 2012 from /var/log/messages into 29032012.txt as below :

[root@centos62 ~]# more /var/log/messages | grep "Mar 29" > 29032012.txt

1. How to Grep Multiples Lines

Please grep “cubic” with -B1 and -A4 :

[root@centos62 ~]# grep -B1 -A4 "cubic" 29032012.txt

The output will return like this :

Mar 29 21:04:16 centos62 kernel: usbhid: v2.6:USB HID core driver
Mar 29 21:04:16 centos62 kernel: TCP cubic registered
Mar 29 21:04:16 centos62 kernel: Initializing XFRM netlink socket
Mar 29 21:04:16 centos62 kernel: NET: Registered protocol family 17
Mar 29 21:04:16 centos62 kernel: Using IPI No-Shortcut mode
Mar 29 21:04:16 centos62 kernel: registered taskstats version 1

2. How to Grep using Specific Keyword :
Grep only keyword “BIOS-e820” from 29032012.txt file as below :

[root@centos62 ~]# more 29032012.txt | grep "BIOS-e820"

The output will return like this :

Mar 29 21:04:16 centos62 kernel: BIOS-e820: 0000000000000000 - 000000000009f800 (usable)
Mar 29 21:04:16 centos62 kernel: BIOS-e820: 000000000009f800 - 00000000000a0000 (reserved)
Mar 29 21:04:16 centos62 kernel: BIOS-e820: 00000000000ca000 - 00000000000cc000 (reserved)
Mar 29 21:04:16 centos62 kernel: BIOS-e820: 00000000000dc000 - 00000000000e0000 (reserved)
Mar 29 21:04:16 centos62 kernel: BIOS-e820: 00000000000e4000 - 0000000000100000 (reserved)
Mar 29 21:04:16 centos62 kernel: BIOS-e820: 0000000000100000 - 000000003fef0000 (usable)
Mar 29 21:04:16 centos62 kernel: BIOS-e820: 000000003fef0000 - 000000003feff000 (ACPI data)
Mar 29 21:04:16 centos62 kernel: BIOS-e820: 000000003feff000 - 000000003ff00000 (ACPI NVS)
Mar 29 21:04:16 centos62 kernel: BIOS-e820: 000000003ff00000 - 0000000040000000 (usable)
Mar 29 21:04:16 centos62 kernel: BIOS-e820: 00000000e0000000 - 00000000f0000000 (reserved)
Mar 29 21:04:16 centos62 kernel: BIOS-e820: 00000000fec00000 - 00000000fec10000 (reserved)
Mar 29 21:04:16 centos62 kernel: BIOS-e820: 00000000fee00000 - 00000000fee01000 (reserved)
Mar 29 21:04:16 centos62 kernel: BIOS-e820: 00000000fffe0000 - 0000000100000000 (reserved)

How to Create and Extract a gzip Compressed Archive File on Linux

Archiving and compressing files are useful when creating backups and transferring data across a network. One of the oldest and most common commands for creating and working with the backup archives is tar command. tar originally stood for tape archiver. With tar, we cab gather large sets of the files into a single file(archive). We can indicate that the archive should be compressed using gzip or bzip2 compression.

To use tar command, one of the three following options is required.
c = create and archive
x = extract and archive or
t = test or list the contents of an archive

Other options let you add vebosity(v), indicate the name of the archive file to create or extract and set the type of compression to use (g for gzip or j or bzip2).

This example will show an examples of tar syntax which will create (c) a gzip compressed(z) archive file (f /tmp/etc.tar.gz) of the /etc directory. Be verbose(v) with the output. This command has been tested on Redhat Enterprise Linux 6 (RHEL6) with root access and it will backup entire /etc directory.

[root@rhel6 ~]# tar cvzf /tmp/etc.tar.gz /etc

Meanwhile, this tar command will show hpw to extract(x) and view(v) all files from a gzip-compressed(z) archive(f /tmp/etc.tar.gz) to the /backup-test directory.

Create /backup-test directory and cd to /backup-test.

[root@rhel6 /]# mkdir /backup-test
[root@rhel6 /]# cd /backup-test
[root@rhel6 backup-test]# pwd
/backup-test

Extract(x) and view(v) all files from a gzip-compressed(z) archive(f /tmp/etc.tar.gz) to the /backup-test directory.

[root@rhel6 backup-test]# tar xvzf /tmp/etc.tar.gz

List the extracted directory ;

[root@rhel6 backup-test]# ls
etc

How to use Basic Regular Expression with grep command on Linux

Regular expressions are special text strings that used to search for and match patterns in text. To make the search expression more specific, it can work together with the grep command. The grep command is the General Regular Expression Parser; it searches a file for strings matching a given regular expression, and by default it the prints out any line containing a string that matches. There are many useful options which can be set for grep which affect it output. This examples will show how to use caret ^ and dollar sign $ to print more specific output. This examples has been tested on Redhat Enterprise Linux 6 server. It may works on CentOS as well.

The caret ^ is meta-characters that respectively match the empty string at the beginning of a line.

Anchor : line begins with...

Meanwhile, the dollar sign $ is a meta-characters that respectively match the empty string at the end of a line.

Anchor : line ends with...

Examples :
1. Print all usernames that begin with the letter e :

[root@rhel6 ~]# grep '^e' /etc/passwd
ehowstuff:x:503:503::/home/ehowstuff:/bin/bash

2. Print all usernames that begin with the letter g :

[root@rhel6 ~]# grep '^g' /etc/passwd
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin

3. Print all usernames that begin with the letter a :

[root@rhel6 ~]# grep '^a' /etc/passwd
adm:x:3:4:adm:/var/adm:/sbin/nologin
abrt:x:499:499::/etc/abrt:/sbin/nologin
apache:x:48:48:Apache:/var/www:/sbin/nologin

4. Print all lines that end with the letter h :

[root@rhel6 ~]# grep 'h$' /etc/passwd
root:x:0:0:root:/root:/bin/bash
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
test:x:500:500::/home/test:/bin/bash
sambauser1:x:501:501::/home/sambauser1:/bin/bash
ftpuser:x:502:502::/home/ftpuser:/bin/bash
ehowstuff:x:503:503::/home/ehowstuff:/bin/bash
testuser:x:504:504::/home/testuser:/bin/bash

How Display Logged in User Information and Terminal number on Linux Server

In this post i will show on how to display logged in user information and terminal number on Linux server. This post provides practical examples for future references. This steps has been tested on Redhat Linux Enterprise server 6 and may working CentOS server as well.

1. “who am i” command is use to display the username of currently logged.

[root@rhel6 ~]# who am i
root     pts/1        2012-04-17 06:14 (192.168.1.52)

2. who command will display all the user currently logged in all terminals.

[root@rhel6 ~]# who
root     tty1         2012-04-17 04:29
root     pts/0        2012-04-17 04:29 (192.168.1.52)
root     pts/1        2012-04-17 06:14 (192.168.1.52)
root     pts/2        2012-04-17 06:01 (192.168.1.52)

3. tty command is used to display the terminal number of currently logged in terminals.

[root@rhel6 ~]# tty
/dev/pts/1

4. The w command shows who is logged in to the system and what they are doing.

[root@rhel6 ~]# w
 06:18:39 up  1:50,  4 users,  load average: 0.02, 0.02, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     tty1     -                04:29    1:48m  4.80s  4.78s ping www.google.com
root     pts/0    192.168.1.52     04:29    1:49m  0.02s  0.02s -bash
root     pts/1    192.168.1.52     06:14    0.00s  0.05s  0.01s w
root     pts/2    192.168.1.52     06:01   26.00s  0.11s  0.03s -bash