Posts

Showing posts from 2011

Command Line Tips

Image
Here is some of command line tricks that can help you a lot. I am working on this post So you will get more and more... 1.) Using vim to see Calender of two years in single window. #vim -O <(cal 2011) <(cal 2012) Here -O     Open  one window for each file. 2.) ifconfig eth0;sleep 60;ifconfig eth0)|grep "RX bytes" # Pass two runs of ifconfig 60 seconds apart through the same grep using a subshell. [root@server2 ~]#(ifconfig eth0;sleep 60;ifconfig eth0)|grep "RX bytes"           RX bytes:332299170 (316.9 MiB)  TX bytes:21752930 (20.7 MiB)           RX bytes:337602454 (321.9 MiB)  TX bytes:21927669 (20.9 MiB 3.) Here is One line coding for getting status of all init.d scripts(services) and store result in a file root@primary ~] for i in /etc/init.d/*; do echo -e $i status:; echo -e "\t";$i status ;echo -e "\n"; done > ~/daemon_status_list ...

Hard Link Vs Soft Link in Linux

Image
A Link is a connection of one file with other. Links allow more than one file name to refer to the same file, elsewhere. In Linux we make the use of ln command to create links of a file. There are two types of links, both of which are created by ln : symbolic links , which refer to a symbolic path indicating the abstract location of another file, and hard links , which refer to the specific location of physical data. These links behave differently when the source of the link (what is being linked to) is moved or removed. Symbolic links are not updated (they merely contain a string which is the pathname of its target); hard links always refer to the source, even if moved or removed. For  symbolic links we make use of ln -s and for hard links we make use of ln command as shown below : 1.) symbolic links :  [root@server199 ks]# ln -s sed.sh softlink.sh  [root@server199 ks]# ll -rs total 8 0 lrwxrwxrwx 1 root root   6 Dec 12 18:03 softlink.sh ...

Block Ping Linux

Image
How to block all incoming ping linux Steps to block: 1)Just edit this file /etc/sysctl.conf 2)Next look for this line: net.ipv4.icmp_echo_ignore_all NOTE: if you dont find net.ipv4.icmp_echo_ignore_all then simply added to the last line be sure the the value is equals to 1. So make it look like this: net.ipv4.icmp_echo_ignore_all = 1 After that to make changes effective without rebooting run following command: #sysctl -p !Enjoy Linux Kuldeep Sharma

tcpdump Packet Analyser some interesting commands

Image
tcpdump command is also called as packet analyzer. Mr. tcpdump  tcpdump command will work on most flavors of unix operating system. tcpdump allows us to save the packets that are captured, so that we can use it for future analysis. The saved file can be viewed by the same tcpdump command. We can also use open source software like wireshark to read the tcpdump pcap files. In this tcpdump tutorial, let us discuss some practical examples on how to use the tcpdump command. 1. Capture packets from a particular ethernet interface using tcpdump -i : When you execute tcpdump command without any option, it will capture all the packets flowing through all the interfaces. -i option with tcpdump command, allows you to filter on a particular ethernet interface. [root@server199 ~]# tcpdump -i eth1 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes 13:54:40.373435 IP ser...

Renaming Multiple files at Once

  Renaming Multiple files at Once # for i in *.arc;   do         mv "$i" "${i/.arc}".dbf;    done This is just simple one. There are lots of ways to do same task. I will come with those very soon, !Enjoy Linux Kuldeep Sharma

Find information about NIC in Linux

Image
Hi All,           In some scenarios, we want to find out the performance factors of our NIC card attached. Because, if we are working on network for doing some work, then surely we need to transfer data from one system to other. Maximum performance depends on the configuration of NIC Card we are using.                                       So here are some command Line tools in Linux to find out useful info. 1.) ethtool 2.) mii-tool 3.) dmesg 1.) ethtool: [root@server199 ~]# ethtool eth1 Settings for eth1:         Supported ports: [ TP ]         Supported link modes:   10baseT/Half 10baseT/Full                        ...

Moving Iptables logs to different file

Image
Dear All,               Today I am going to post regarding the Iptable logs. I was getting iptable in /var/log/messages, so its getting difficult to check other messages from /var/log/messages as iptables generates a huge bulk of logs.            So for that I decided to move iptables log to different directory. For this we have to do changes in foolowing configuration files. 1.) /etc/syslog.conf In the above file append the following line. kern.warning                                            /home/log/iptables.log Also as before I was getting all iptables log in /var/log/messages, So need to do some more changes in syslog.conf file as change below line... # Log anythin...

How DHCP Server Works?

Image
Hi Friends,                  Here I am going to post the whole process about the Interaction between DHCP Client and DHCP Server(How a DHCP client communicate with DHCP Server to get an IP Address).                          DHCP is a very common protocol and we often here about it. DHCP is much more complex than it looks. DHCP IP address assignment process goes through a few steps explained in this article.             DHCP stands for Dynamic Host Configuration Protocol and is used to automatically assign IP configuration to hosts connecting to a network. The Dynamic Host Configuration Protocol (DHCP) provides a framework for passing configuration information to hosts on a TCPIP network. DHCP is based on the Bootstrap Protocol (BOO...

Service does not support chkconfig error

Hi Friends,                   As u all know in Redhat or other derived distros to add any service to runlevel we make use of chkconfig   command as given below: #chkconfig --level *runlevel* *service name* on/off But before that we have to add that particular service to chkconfig, without adding this we can not run above command. So to add a service to chkconfig use following syntax: #chkconfig --add  *service name* But sometimes what happens when we run this command, we get following error message as:  service test does not support chkconfig . So to this working you have to add following line just after the shebang/hashbang  #!/bin/sh or #!/bin/bash .   #chkconfig: 2345 95 20 # description: Description of the script # processname:test   The first line, even if commented, is used by chkconfig and must be present defines that on runlevels 2,3,4 and 5, this subsystem will be activated wi...

bash: ./iptest.sh: /bin/bash: bad interpreter: Permission denied

Hello All,                Recently I have faced an interesting issue during command execution. I have given executable permission, But still getting permission denied error like " bash: ./iptest.sh: /bin/bash: bad interpreter: Permission denied " I have done some searching and finally found exact issue. Actually I was working on my externally USB hard Disk. So by default it mounts with executable permission. Let me show you below: Before doing any changes(default mount) [root@server199 scripts]# ./iptest.sh bash: ./iptest.sh: /bin/bash: bad interpreter: Permission denied Now I have check default permission on mounted Disk [root@server199 ~]# mount | grep disk /dev/sdb1 on /media/disk type vfat (rw, noexec ,nosuid,nodev,shortname=winnt,uid=0) So its mounted with noexec Permission. Now remount Disk with Executable permissions as shown below and then check: [root@server199 ~]# cd [root@server199 ~]# mo...

Replacing a string recurcively in all files of a folder in Linux

Today I have come to a situation in which I have to search for a particular string in a Directory/Directories recurcively and if found, then have to replace with other string.                   So here is simple one line command using for loop or you can also make a good script using the below command. Go to directory where you have to search the particular and fire below command. # for file in $(grep -rli *string to search* *);               do             sed -i 's/*string to search* /*String to be replaced */g' $file;    done Note : * at end of grep is compulsory, but don't put with string you want to search. eg if you want search linux then write linux not *linux*. The * at end of grep command is astrerisk for searching all files. Where, Option with grep do ...

Secure WEb-Console and JMX-Console in Jboss

Image
Hi All,             Here I am posting my first video on How to Secure web-console and jmx-console in JBOSS 5.1GA. !Enjoy Feel free to comment...

Setting PXE Network Boot Server in Linux

Dear All,                Here I am showing you another way to configure PXE Network Boot Server on Linux. I have shown this in my previous post PXE(Preboot eXecution Environment) Installation and Configuration . This will be really helpful when you have no CD/DVD Drive in your Client System. Requirements : You will need following thing to be configure for this... A DHCP server A TFTP server (tftpd-hpa) vmlinuz and initrd.img from your distribution of choice The PXELINUX.0 boot loader and a suitable config file Network installation Server that may be NFS, FTP, or HTTP. Here I am using ftp server.  system-config-netboot package for pxeos commands. Note : My server IP -- 192.168.2.199 1.) Install the TFTP server: Ensure you use the tftpd-hpa package, as PXELINUX requires that the boot server has a TFTP server which supports the “tsize” TFTP option. If you don’t use tftpd-hpa you will most likely...