Posts

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...

Basic Linux Commands Intervewer may Ask

1)Give me 15 commands which you use frequently Depends on the environment you work. Some examples are mkdir — For creating folders( use -p option to create multiple folders at a time) ls –List folders/files( check what ls -1 do) top — To monitor system activities lsof –To check whats happening on the server and which process open which file. netstat -tcp –Gives you complete picture about network connection details. vnstat –Gives you Network band width statics sh –For running shell scripts history –For monitoring the commands executed by users cd –For changing directories vi - -For editing configuration files. chmod –To change permissions of folders and files. mount –For mounting formated partitions. service –For start/restart/stop a service. chkconfig –For permanent on/off a service. fdisk -l –To list all the partitions This is my own list, you can have your list. 2)Give me some commands for user management. last, chage, chsh, lsof, chown, chmod, userad...

Removing Files in Linux having Name starting with special characters

Since on  Linux everything is to be considered as file, So a file may have any name that start with anything. So in case you got some file that has name starting with some unusual characters or you can say with special characters.                          This post will show you about "How to Delete files whose name start with special characters in Linux". e.g. files like --test2. There are two ways to delete such files. 1.) Find inode of that particular file to be deleted and then delete using find command.         Syntax:  ~]# find . -inum -exec rm -rf {} \; 2.) Second way is use rm command in following manner.        Syntax: ~]# rm -rf ./ Now let me show you with Example. Here suppose I have a file having name ~test1. So for deleting this file.... Using find command :  ...