Tuesday, May 15, 2012

Change the MTU of your interface

Command to change the MTU of your interface

1
2
ifconfig <interface> mtu <value> up
ifconfig eth1 mtu 1000 up

--ahamed


tcpdump - capturing output to a file

Command to capture tcpdump output to pcap format for analysis with Wireshark or other tools

tcpdump -i <interface> -w <output file>
tcpdump -i eth1 -w output.pcap

Have a good day!


Sunday, March 18, 2012

echo $SHELL and echo $0

"How do you identify your current shell?" is one of the frequently asked interview question.


Some would say "echo $SHELL" and some would say "echo $0". So, which is the right answer?


See for yourself!
root > grep ^root /etc/passwd
root:x:0:0:root:/root:/bin/bash

root > bash
root > echo $SHELL
/bin/bash
root > echo $0
-bash

root > ksh
root > echo $SHELL
/bin/bash
root > echo $0
ksh
Got it?


$SHELL will always print the login shell. $0 will print the current shell.


Good Day!

Saturday, March 17, 2012

Sharing files in Eclipse between Projects

Eclipse is one of the most prominent IDE's used today, that's what I think ;)

We may have many different projects in eclipse to manage, but what if you want to share a particular file say a header file across all your projects or among few projects?

Why do we need to share in the first place? Cause we don't want to have a separate copy of the same file in all the project workspace. In case if we had, then we will need to update all the files manually, right? Why take all the trouble, just share it across all the projects.

In this case, we want to share a header file across multiple projects. It's pretty simple actually.

Create a project with some name, say "Common" and add the header file there. In my case, I have a project named "log_utility" and have added a header file "global.h".

Now I want to share this "global.h" across other projects say "start_server", "start_client". Heard about "-I" flag in g++ or gcc? that's what we are going to use here also.


1. Right Click on the project where you want to add the file (start_server). [ Select the project and press Alt+Enter (shortcut) ]
2. Properties > C/C++ Build > Settings > Tool Settings > Includes
3. Now add the path/file you want to include


Here, I have added both the path and a particular file for reference.




Now, if you check the make file, there will be a line "-I/your/path"
Something like this

Good Day!