Monday, February 10, 2014



In previous article, we understood the column wise information about netstat output. In this article, we will understand the different examples and uses of this command.

How to get interface statistics?

When we use –i flag with netstat command, it gives the currently configured interface statistics. If we use –a option then it gives all interface’s statistics.
[root@server1 Downloads]# netstat –I
Kernel Interface table
Iface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500   0    39784      0      0      0      568      0      0      0 BMRU
lo        16436   0       16      0      0      0       16      0      0      0 LRU
[root@server1 Downloads]#
[root@server1 Downloads]# netstat -ia
Kernel Interface table
Iface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500   0    40698      0      0      0      639      0      0      0 BMRU
lo        16436   0       16      0      0      0       16      0      0      0 LRU
pan0       1500   0        0      0      0      0        0      0      0      0 BM
sit0       1480   0        0      0      0      0        0      0      0      0 O
[root@server1 Downloads]#

Columns showing information about the packet status as follow:

MTU
Maximum transmission unit
Met
Metric values for that interface
RX-OK/TX-OK
How many packets received or transmitted successfully
RX-ERR/TX-ERR
Errors in packets(not delivered successfully)
RX-DRP/TX-DRP
Number of packets dropped
RX-OVR/TX-OVR
Number of packets are lost because of overrun
Flags
Flags that have been set for interface.

There are different types of flags. We got four types of flag in above example. Below is the short information about these flags.

B
Broadcast address has been set for this interface
O
Address resolution protocol is turned off for this interface
U
Interface is up
P
Point to point connection
R
Interface is running
L
Interface is a loopback device
M
All packets received successfully

How to display different types of connections using netstat command?
TCP, UDP and RAW and unix socket connection we can see by using –t, -u, -w, and –x flags with netstat command. Detailed description about this you will get in this article.
Posted by Machindra Dharmadhikari On 2/10/2014 10:19:00 PM No comments READ FULL POST


We have already gone through the netstat command uses but there are lots of uses of this command. We will understand some of the uses in this article.
·         When we use –r flag with linux netstat command then it is giving output same as route command. route command gives output info as kernel IP routing table. I have used –n flag with netstat, it gives IP information in dotted rather than symbolic host and network names.



Let’s understand column wise details about above output-

Destination

First column shows the destination IP address or symbolic hostname. 

Gateway

Second column shows the gateway to which the routing entry points. If gateway is not used then asterisk (*) is printed instead. 

Genmask

Third column is general mask, which is used when given IP address finding suitable route then kernel checks with each routing table entry and taking bitwise AND of the address and genmask before comparing it to the target of the route.

Flags

The fourth column can shows the following flags and their meaning as follows:
G             the route uses the gateway
U             the interface to be used is up.
H             only single host can be reached through the route. It is in case of loopback address.
D             this route is dynamically created.
M            sets when table entry was made by ICMP redirect message.
!              the route is reject route and datagram will be dropped.

MSS

Fifth column shows MSS i.e. Maximum segment size. i.e. this is largest datagram size which kernel has constructed for transmission via route.

Window

Sixth column shows the window i.e. it is the maximum amount of data system can accept from single burst from a remote host.

IRTT

Seventh column shows the irtt. i.e. Initial round trip time. The TCP protocol keeps the time to deliver a datagram and then acknowledgement of received, this is called round trip time. And initial round trip time is the time when connection established.
Iface
Eighth and last column gives information about network interface that this route will use.
Posted by Machindra Dharmadhikari On 2/10/2014 10:16:00 PM No comments READ FULL POST

Friday, October 25, 2013


Sticky bit is a bit set in permission of a file or directory to give special access –rights to user. When we set the sticky bit for any executable file, it will remain in swap space after the process exited. It will help to reduce time of execution in repeatedly used programs. So, we can set this sticky bit for frequently used programs like editors, commands etc. So, execution of them will be faster as compared to without sticky bit.
Main important use of sticky bit is on directory, when we set sticky bit for directory then files reside in the directory can delete or rename by owner only. This is helpful not to give access for renaming or deletion to unauthorized user. When sticky bit is not set for directory then any user having permission to write and execute on directory can rename and delete files inside the directory.

Sticky bit behavior or feature changes as per operating system. Linux Kernel ignores the sticky bit on files, it considers only on directories. In HP-UX work on sticky bit as above mentioned. In AIX, if we set the sticky bit for directory then only owner can link or unlink the directory or files specified in the directory.

How to set Sticky bit on file/directory in Linux?

We will set sticky bit by chmod command. For this purpose, we can use octal mode or by its symbol ‘t’. lets go through the example.

//Check the permissions of directory sticky
redhat@localhost:~/mywork$ ls -l
total 4
drwxr-xr-x 2 redhat adm 4096 2013-10-24 15:36 sticky
redhat@localhost:~/mywork$ ls -l sticky/                            //inside directory permissions
total 8
-rwxr-xr-x 1 redhat adm 57 2013-10-24 15:35 stickybit.sh
-rwxr-xr-x 1 redhat adm 57 2013-10-24 15:36 stickybit.sh_bak
//Adding sticky bit in permission by below syntax ..or use - chmod 1755 sticky
redhat@localhost:~/mywork$ chmod +t sticky/                         
redhat@localhost:~/mywork$ ls -l sticky/
total 8
-rwxr-xr-x 1 redhat adm 57 2013-10-24 15:35 stickybit.sh
-rwxr-xr-x 1 redhat adm 57 2013-10-24 15:36 stickybit.sh_bak
redhat@localhost:~/mywork$ ls -l
total 4
drwxr-xr-t 2 redhat adm 4096 2013-10-24 15:36 sticky
//In above line sticky bit added in permissions
redhat@localhost:~/mywork$


Now we have set the sticky bit to directory. Now we will try to remove file or script inside the directory.

//Changing the user. Sandeep and redhat having same group.
redhat@localhost:~/mywork/sticky$ su - Sandeep
Password:
Sandeep@localhost:~$
Sandeep@localhost:~$ pwd
/home/Sandeep
Sandeep@localhost:~$ cd ../redhat            //Change Directory to that sticky bit directory
Sandeep@localhost:/home/redhat$ ls
mywork
Sandeep@localhost:/home/redhat$ ls -l
total 4
drwxr-xr-x 3 redhat adm 4096 2013-10-24 15:39 mywork
Sandeep@localhost:/home/redhat$ cd mywork/
Sandeep@localhost:/home/redhat/mywork$ ls -l
total 4
drwxr-xr-t 2 redhat adm 4096 2013-10-24 15:36 sticky
Sandeep@localhost:/home/redhat/mywork$
Sandeep@localhost:/home/redhat/mywork$ cd sticky/
Sandeep@localhost:/home/redhat/mywork/sticky$ ls
stickybit.sh  stickybit.sh_bak
//Trying to remove sticky bit set directory content ..getting error permission denied
Sandeep@localhost:/home/redhat/mywork/sticky$ rm stickybit.sh
rm: remove write-protected regular file `stickybit.sh'? y
rm: cannot remove `stickybit.sh': Permission denied
Sandeep@localhost:/home/redhat/mywork/sticky$

Permission denied while removing the file which resides into the directory whose sticky bit has been set already. This is the actual use of sticky bit on directory.

How to remove sticky bit of directory/file ?

We need to login by redhat or root user before removing sticky bit then only we can remove the Sticky bit.

redhat@localhost:~/mywork$ ls –l
total 4
drwxr-xr-t 2 redhat adm 4096 2013-10-24 15:36 sticky
//use below syntax or use – chmod 755 sticky
redhat@localhost:~/mywork$ chmod -t sticky/
redhat@localhost:~/mywork$ ls -l
total 4
drwxr-xr-x 2 redhat adm 4096 2013-10-24 15:36 sticky
redhat@localhost:~/mywork$


Drop an email if you have any query regarding the Linux issue or like our page on Facebook and post a query.
Posted by Machindra Dharmadhikari On 10/25/2013 09:29:00 PM No comments READ FULL POST

Wednesday, October 23, 2013

Sticky bit concept and implementation                                      Check CPU usage of file system

SetUID:

SetUID is a set User ID upon execution. We can identify SetUID bit is set or not in permissions of file by long listing the details of file as below.

[linuxconcepts@localhost test]$ cat > setuid.sh
#!/bin/sh
echo "SET USER ID BIT";
date
[linuxconcepts@localhost test]$
[linuxconcepts@localhost test]$ ls -l setuid.sh
-rw-rw-r--. 1 linuxconcepts linuxconcepts 39 Oct 23 12:08 setuid.sh
[linuxconcepts@localhost test]$ chmod 4755 setuid.sh
[linuxconcepts@localhost test]$ ls -l setuid.sh
-rwsr-xr-x. 1 linuxconcepts linuxconcepts 39 Oct 23 12:08 setuid.sh
[linuxconcepts@localhost test]$
//We can set setUID bit by following method as well
[linuxconcepts@localhost test]$ touch setuid1.sh
[linuxconcepts@localhost test]$ ls -l setuid1.sh
-rw-rw-r--. 1 linuxconcepts linuxconcepts 0 Oct 23 13:22 setuid1.sh
[linuxconcepts@localhost test]$ chmod u+s setuid1.sh
[linuxconcepts@localhost test]$ ls -l setuid1.sh
-rwsrw-r--. 1 linuxconcepts linuxconcepts 0 Oct 23 13:22 setuid1.sh
[linuxconcepts@localhost test]$

We can see ‘s’ letter in permission of a setuid.sh file when we change permissions to 4755. We use 4 before actual permission digit to setUID bit to any file.

Benefit: When we set the setUID bit in linux then that script will execute with its owner’s permission. Means if any user is executing that script who have execution permission then it will execute with owner’s permission.

Generally, setUID bit is disabled in most of unix like operating systems because it is unsecure and it gives full access to execute the script.

We can remove setUID bit as follows:

[linuxconcepts@localhost test]$ chmod u-s setuid1.sh
[linuxconcepts@localhost test]$ ls -l setuid1.sh
-rw-rw-r--. 1 linuxconcepts linuxconcepts 0 Oct 23 13:22 setuid1.sh
[linuxconcepts@localhost test]$
SetGID :

SetGID is a set group ID upon execution. It is same as setUID. But setUID is for user and setGID bit is in linux is for group. It can bet set and remove as follows.

[linuxconcepts@localhost test]$ ls -l setuid1.shroup
-rw-rw-r--. 1 linuxconcepts linuxconcepts 0 Oct 23 13:22 setuid1.sh
[linuxconcepts@localhost test]$
[linuxconcepts@localhost test]$ chmod 2755 setuid1.sh
[linuxconcepts@localhost test]$  ls -l setuid1.sh
-rwxr-sr-x. 1 linuxconcepts linuxconcepts 0 Oct 23 13:22 setuid1.sh
[linuxconcepts@localhost test]$ chmod u-s setuid1.sh
[linuxconcepts@localhost test]$ ls -l setuid1.sh
-rwxr-sr-x. 1 linuxconcepts linuxconcepts 0 Oct 23 13:22 setuid1.sh
[linuxconcepts@localhost test]$

Generally SetGID or SetUID bit is set for commands or service commands.

You might be interested in other posts. Have a look on it :

Jinfo command to get details about java process                  Jstat command in Linux
Posted by Machindra Dharmadhikari On 10/23/2013 09:41:00 PM No comments READ FULL POST

Tuesday, September 17, 2013

Mostly Asked interview questions                                             How to recover delete files in linux

There are many open source applications in Linux available for graphic designer or image editing purpose.  Some of them, I have mentioned below and I will come with detailed description about them in later articles.

InkScape:

Inkscape is an open source application for graphic designers. It can replace to Adobe Illustrator or Corel Draw. Actually, Inkscape is a vector graphics editor. Vector graphics means resolution is independent on description of the actual shapes and objects in the image.
Inkscape supports many advanced features like alpha blending, clones, markers, object creation (Paths, Rectangles, 3D boxes, Stars/Polygons, spirals, clones, text), Object Manipulation (moving of object), styling object (fill, stroke fill, opacity), operations on paths, text support, Rendering etc.
You can visit Inkscape official site here.

Blender:

Blender is an open source tool which mostly used for 3D graphics design, for creating animated films, interactive 3D applications and games etc. I will prefer this tool if you want to create 3D animation film or games. Blender is available for Linux as well as Windows.
Blender is providing wide variety of advanced features like 3D animation creation, smoke simulation, provides game engine, python scripting tool for game logic, importing/exporting from other formats, task automation and custom tools, camera and object tracking, 3D rendering, procedural and node based textures, as well as texture painting, projective painting, vertex painting, weight painting.



Blender is mostly used open source tool for graphic designing.

ImageMagick

ImageMagick is a open source tool used to create, edit, compose, add special effects in image, adjust image colors, draw lines or polygons, add text in image and many more. ImageMagick is generally used like Adobe Photoshop to edit and add special effects in image. It is not having functionality that much of adobe photoshop but it is good to use as an open source tool.
ImageMagick can help us to do things like image format conversion, transform, draw, add special effects, animations, add texts and comments, overlap an image over another, motion picture support, large image support.

Know more about the ImageMagick

GIMP

GIMP stands for GNU Image Manipulation Program. It is a good graphics manipulation package. GIMP is mostly used for image editing or while adding special effects in image.
GIMP has many features like photo enhancement, digital retouching, hardware support, file formats. It is available in Linux. Windows, Sun Soalris, Mac OS X, Free BSD.

Click here to know more about the GIMP.

AERO 

A Physically based simulation and animation system. AERO is a simulation program based on rigid body systems.

You might have interested in this post. Have a look on it :

How to run windows applications on Linux                          Check java process statistics in Linux
Posted by Machindra Dharmadhikari On 9/17/2013 09:47:00 PM No comments READ FULL POST
  • RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
  • Youtube

    Chitika Ads 2

    Histat

    About

    Enter your email address:

    Delivered by FeedBurner