Skip to main content

Posts

How to install DHCP server in Centos and Redhat

The  dhcp ( Dynamic Host Configuration Protocol)   package contains an Internet Systems Consortium (ISC) DHCP server.  DHCP is used to assign IP addresses and other stuff like gateway and DNS details automatically to the clients. we need a DHCP server configured for offering ipaddress to the clients when it is required.  First, install the package as the superuser: # yum install dhcp Installing the dhcp package creates a file, /etc/dhcp/dhcpd.conf, which is merely an empty configuration file: cat /etc/dhcp/dhcpd.conf # # DHCP Server Configuration file. #   see /usr/share/doc/dhcp*/dhcpd.conf.sample The sample configuration file can be found at /usr/share/doc/dhcp-<version>/dhcpd.conf.sample . You should use this file to help you configure /etc/dhcp/dhcpd.conf , which is explained in detail below. DHCP also uses the file  /var/lib/dhcpd/dhcpd.leases  to store the client lease database. After installing dhcp server ...

Network Monitoring tools in Linux

Network monitoring tools are used to monitor the network, systems present on the network, various service running on the network, traffic etc. Ping: Ping command is used to check if the system is in the network or not. To check if the host is operating. e.g. ping ip_address [root@server1 ~]# ping 172.26.128.132 PING 172.26.128.132 (172.26.128.132) 56(84) bytes of data. 64 bytes from 172.26.128.132: icmp_seq=0 ttl=58 time=3.27 ms 64 bytes from 172.26.128.132: icmp_seq=1 ttl=58 time=3.12 ms 64 bytes from 172.26.128.132: icmp_seq=2 ttl=58 time=1.92 ms 64 bytes from 172.26.128.132: icmp_seq=3 ttl=58 time=3.10 ms 64 bytes from 172.26.128.132: icmp_seq=4 ttl=58 time=2.14 ms --- 172.26.128.132 ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4006ms rtt min/avg/max/mdev = 1.922/2.715/3.279/0.564 ms, pipe 2 [root@server1 ~]# When the command is executed, it returns a detailed summary of the host. Packets sent, received, lost by...

How to keep a script running even after logging out of the system

There are times when we need to do some job or run some script which takes a lot of time. During this the connection can get aborted which results in the job getting killed. There is simple solution for this, Use NOHUP. The command syntax is easy:- nohup <command>  & here  <command> is the command or script you're running. An & is need to put the command in the background as nohup doesn't do this itself. For example, when you log-in to the remote server using ssh. # ssh user@remoteserver now you want to run a backup script rsync_script.sh  which takes a long time, then you can run, # nohup rsync_script.sh & you can now logout from the terminal & the script will continue to run until its completed.

Using Vagrant to create virtual machines with Virtual Box

I'm a Linux System Admin & I play with lots of virtual machines to try & test various software & services. I use Virtual Box for creating virtual machine. Everything works fine except the part of installing same virtual machine again & again which takes a lot of time installing & configuring it. Recently I came across a tool called Vagrant which can automate that process or at least can make it easy for us to make a base image & then create virtual machines from that image without any worry. Now the real work:- Make sure you've Virtual Box installed on your machine, if not already done, download from  https://www.virtualbox.org/wiki/Downloads  & install it. Its available for almost all popular platforms. Download Vagrant from  http://downloads.vagrantup.com/  & install it. Binary packages available for MAC, Windows, debian & RPM based systems. I used Centos 6 heavily so I installed Centos 6. Location specific mirro...

SD MMC MS-Pro card reader not working on DELL INSPIRON 15R 5520

Not sure how many of you've come across this, but for me this was unusual. Usually Ubuntu has great compatibility built out of the box. All the wifi,graphics etc are picked on boot. But when I inserted my SD card on its slot, it was not recognized & I'm running Ubuntu 12.04 LTS with 3.9.2 kernel. But it was simple google search & I found a simple solution for this problem:- Create the file "sdhci-pci.conf" that contains one single line "options sdhci debug_quirks=0x40" in a directory "/etc/modprobe.d" root@infra:/etc/modprobe.d# cat ./sdhci-pci.conf options sdhci debug_quirks=0x40 and then reload the modules: root@infra:/etc/modprobe.d# rmmod sdhci-pci root@infra:/etc/modprobe.d# rmmod sdhci root@infra:/etc/modprobe.d# modprobe sdhci-pci (or reboot) and plug-in the SD card now, it works... I'm Happy again... Hope it helps you too..

CentOS / Redhat : Configure CentOS as a Software Router with two interfaces

Linux can be easily configured to share an internet connection using iptables. All you need to have is, two network interface cards as follows: a) Your internal (LAN) network connected via eth0 with static ip address 192.168.0.1 b) Your external WAN) network is connected via eth1 with static ip address 10.10.10.1  ( public IP provided by ISP ) Please note that interface eth1 may have public IP address or IP assigned by ISP. eth1 may be connected to a dedicated DSL / ADSL / WAN / Cable router: Step # 1: Enable Packet Forwarding Login as the root user. Open /etc/sysctl.conf file # vi /etc/sysctl.conf Add the following line to enable packet forwarding for IPv4: net.ipv4.conf.default.forwarding=1 Save and close the file. Restart networking: # service network restart Step # 2: Enable IP masquerading In Linux networking, Network Address Translation (NAT) or Network Masquerading (IP Masquerading) is a technique of tra...

CentOS | RHEL: Check If A Service Is Running Or Not

We can use service command to get the status of services running on the system. It runs a System V init script in  as predictable environment as possible, removing most environment variables and with current working directory set to /. Syntax is: service <service-name> status OR /etc/init.d/<service-name> status Example: Find, out if a service called httpd (Apache Web Server) is running on CentOS OR RHEL. Open a terminal or login using ssh, enter:   #  service httpd status Sample outputs: [root@myserver ~]# service httpd status httpd (pid  21585) is running... Find out status of all services The  service --status-all  command runs all init scripts, in alphabetical order, with the status command:  #  service --status-all Sample output:- [root@myserver ~]# service --status-all anacron is stopped atd is stopped auditd is stopped cpuspeed is stopped crond (pid 3442) is running... cupsd (pid 5...

Linux: Find Out Directory Size Command

To get the size of a Directory in Linux, use du command. du command is used to find the file space usage & summarize disk usage of each file/directory. To find the size of /usr directory:   du /usr OR  Pass -s option to see the total disk space summary & -h option for human readable format.   du -sh /usr We can also list the contents of the directory (whether file or directory) with size:- du -sh /usr/* Sample output: [root@myserver ~]# du -sh /usr/* 71M     /usr/bin 8.0K    /usr/etc 8.0K    /usr/games 87M     /usr/include 122M    /usr/java 1.8M    /usr/kerberos 535M    /usr/lib 199M    /usr/lib64 12M     /usr/libexec 212M    /usr/local 17M     /usr/sbin 563M    /usr/share 57M     /usr/src 4.0K    /usr/tmp 48M     /usr/X11R6

Shell Script: Find Number Of Arguments Passed

Many times , when we create shell scripts we try to do repetitive tasks through functions. Some functions take arguments & we have to check the no. of arguments that are passed to it. Each bash shell function has the following set of shell variables: [a] All function parameters or arguments can be accessed via  $1, $2, $3,..., $N . [b]  $*  or  $@  holds all parameters or arguments passed to the function. [c]  $#  holds the number of positional parameters passed to the function. [d] An array variable called  FUNCNAME  ontains the names of all shell functions currently in the execution call stack. Example Create a shell script as follows: #!/bin/bash # Purpose: Demo bash function # -----------------------------   ## Define a function called test() test(){   echo "Function name:  ${FUNCNAME}"   echo "The number of positional parameter : $#"   echo "All parameters or arguments pass...

Linux : Shell Remove Empty Lines

Many time we face situations where we have many empty lines in a file or script. Then how can we delete only those empty lines & make the file compact? I tried following steps & they worked like charm.  for deleting all empty lines from the file input.txt, run the following command: sed command                      sed '/^$/d' input.txt > output.txt         OR                  sed -i '/^$/d' input.txt awk command                 awk 'NF > 0' input.txt > output.txt     

Linux Find Command: Find Files Modified On Specific Date

There are many situations in which we have to find out  all files that have been modified on a specific date  using find command under Linux. There are two ways to list files in given directory modified after given date of the current year. The latest version of GNU/find command use the following syntax: Syntax GNU/find latest version: find /path/to/dir -newermt "date" find /path/to/dir -newermt "May 13" find /path/to/dir -newermt "yyyy-mm-dd" ## List all files modified on given date find /path/to/dir -newermt yyyy-mm-dd ! -newermt yyyy-mm-dd -ls ### print all *.sh ### find /path/to/dir -newermt "yyyy-mm-dd" -print -type f -iname "*.sh" The other way of doing this works on the versions of find before v4.3.3: touch -t 02010000 /tmp/timestamp find /usr -newer /tmp/timestamp then we can remove the reference file: rm -f /tmp/stamp$$ To  find out all Shell Script files  (*.sh) in /home/linux/scripts that have been modifie...