Posts

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

Network Bonding or Link Aggregation in Linux

Image
Link aggregation or trunking or link bundling or Ethernet/network/NIC bonding or NIC teaming are computer networking umbrella terms to describe various methods of combining ( aggregating ) multiple network connections in parallel to increase throughput beyond what a single connection could sustain, and to provide redundancy in case one of the links fails.  The Linux bonding driver provides a method for aggregating multiple network interfaces into a single logical bonded interface. The behavior of the bonded interfaces depends upon the mode; generally speaking, modes provide either hot standby or load balancing services. Additionally, link integrity monitoring may be performed. Here I am showing you configuration for Centos, it will be same for others, may be some change in file location(depends on distro you are using). [root@server199 ~]# cd /etc/sysconfig/network-scripts [root@server199 network-scripts]# [root@server199 network-scripts]# cat ifcfg-eth0 #Bonding eth0 to...

Linux Top Command

Linux top Command                                                             In most Unix-like operating systems, the top command is a system monitor tool that produces a frequently-updated list of processes. By default, the processes are ordered by percentage of CPU usage, with only the "top" CPU consumers shown. top shows how much processing power and memory are being used, as well as other information about the running processes. Some versions of top allow extensive customization of the display, such as choice of columns or sorting method.                         ...

How to know java bit version(32bit or 64bit) in Linux

To know about the JVM bit version i.e. currently running on Linux Server, use following command: #java -d64 -version or #java -d32 -version If you have 32 bit JVM and you run above command i.e. java -d64 -version, then you'll get some error message on the console like .... [root@localhost default]$  java -d64 -version Running a 64-bit JVM is not supported on this platform. And if you run command "java -d32 -version" , then you'll get.... [root@localhost default]$  java -d32 -version java version "1.6.0_26" Java(TM) SE Runtime Environment (build 1.6.0_26-b03) Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode) !Hope this will help you !Enjoy Kuldeep Sharma

Getting status of all services in Linux

Image
Below is the script to find out status of all services on linux system. #Created on:04-08-2011 #Last modified:04-08-2011 #Purpose:To Check the status of services #The below for loop will take inputs from chkconfig command to check the services which are running/stopped on the machine. for i in `chkconfig --list | awk '{print $1}' | grep -v :` do /sbin/service $i status done there is one another way of doing this task is just use single command. #service --status-all e.g. =================================================================== [root@localhost ~]$  service --status-all acpid (pid 2467) is running... amd is stopped anacron is stopped arpwatch is stopped atd (pid  2992) is running... auditd (pid  2253) is running... automount (pid 2660) is running... Avahi daemon is running Avahi DNS daemon is not running bgpd is stopped hcid (pid 2390) is running... sdpd (pid 2396) is running... capi not installed - No such file or directory (2) clamav-milter (pid 2834)...

Switching Back to yahoo Classic from Beta Version

Image
Hello All,          You know this is linux blog, But I am also adding some misc posts which I am finding some thing interesting. So Enjoy..                   Recently I was facing some issue with yahoomail, As I don't want any more Yahoo Beta Version and want to switch back to yahoo classic version. But now they don't have keep any option to switch back to yahoo Classic, they have made Beta version mendatory :(.     So after doing some R&D at last I was able to switch back. So here I am sharing the trick... Note : All done on firefox. 1.) Firstly just disable your java script as                                 *Click on Tools then option and finally on Contents*, their uncheck Enable Java Script. 2.) Now restart firefox. 3.) Now when you ...

Some Scripting Excersises

1.) Using Test Command to find Wether entered Argument is File or Directory. [root@server2 ~]#cat test.sh test -d $1 ks=`echo $?` if [ $ks -eq "0" ];  then  echo $1 is Directory;  else  echo "Entered Argument is not Directory" fi [root@server2 ~]# [root@server2 ~]#./test.sh /etc /etc is Directory [root@server2 ~]# [root@server2 ~]#./test.sh /etc/passwd Entered Argument is not Directory [root@server2 ~]# 2.) Bash For Loop Example for Unzip all the Zip file The following example finds the list of files which matches with “*.zip*” in the root directory, and creates a new directory in the same location where the zip file exists, and unzip the zip file content. # cat zip_unzip.sh #! /bin/bash # Find files which has .zip for file in `find /root -name "*.zip*" -type f` do # Skip the extension .zip dirname=`echo ${file} | awk -F'.' '{print $1}'` # Create the directory mkdir $dirname # Copy the zip file cp ${file} ${dirnam...

Yum groupinstall !

Yum groupinstall may save your hours! Today I was creating some kind of setup, So during performing those installation steps, I have found one interesting and time saving option that is used with yum command  and can make our tasks really easy. The option is groupinstall and the whole command is "yum groupinstall <"package name">". Though I was little aware of this But have never gone through this. So today I have just done some R&D on this and here is the result. The option "groupinstall" is used to install all the package related to particular type of software. Suppose I want to install all Mysql Database Packages, then instead of installing packages one by one you can make the use of command given below. [root@server2 ~]#yum groupinstall "MySQL Database"  Now question may arise from where I have got string <"MySQL Database">, So answer is before running above command use following command for listing available group...

Identifying main traffic sources with netstat and awk (one-liner explained)

This is line command to get rid of All the hosts using web server. For this we can make the use of handy netstat command. Sample of eventual output: #netstat -natp | grep :80 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n | tail      25 195.150.23.130      25 67.222.164.140      28 95.34.20.117      31 72.45.232.204      34 209.56.4.6      36 64.27.200.208     106 50.17.245.114     112 209.234.226.230     247 216.242.75.236     283 184.106.21.219 You can use this command on any other port that you want to search. Let me break this long command and explain the things to make them more understandabe. First of all – how many connections are there to the web server: #netstat -natp | grep :80 | wc -l 459 netstat is a very versatile tool. In this case, the flags being used state the following: “ -n ” Numerical representation of th...

Some Useful Info about Firefox's "about" Protocal

Image
Firefox "about" Protocol First of all : What is Protocol in Firefox?                        A protocol is the part of a web address before the colon. For example, web pages are normally http or https protocols. If you click on a link that specifies a protocol other than http: or https: (such as aim:goim?screenname=MozillaSupport ), you may receive an error message like: Firefox doesn't know how to open this address, because the protocol (aim) isn't associated with any program .             Today I have found some interesting thing about firefox.After that I have found that we can do a lots of things with firefox or we can make some changes in in "about:config" section to increase performance of Firefox. In Detail I'll write in Next post. In this post I will just show the different options with about protocol wit...

Reducing Swap on an LVM2 Logical Volume

To reduce an LVM2 swap logical volume (assuming /dev/VolGroup00/LogVol01 is the volume you want to extend): Replace /dev/VolGroup00/LogVol01 with your HD partition. Disable swapping for the associated logical volume: # swapoff -v /dev/VolGroup00/LogVol01 Reduce the LVM2 logical volume by 512 MB: # lvm lvreduce /dev/VolGroup00/LogVol01 -L -512M Format the new swap space: # mkswap /dev/VolGroup00/LogVol01 Enable the extended logical volume : # swapon -va Test that the logical volume has been reduced properly: # cat /proc/swaps or # free     !Enjoy Kuldeep Sharma

15 Examples To Master Linux Command Line History

When you are using Linux command line frequently, using the history effectively can be a major productivity boost. In fact, once you have mastered the 15 examples that I’ve provided here, you’ll find using command line more enjoyable and fun. 1. Display timestamp using HISTTIMEFORMAT Typically when you type history from command line, it displays the command# and the command. For auditing purpose, it may be beneficial to display the timepstamp along with the command as shown below. # export HISTTIMEFORMAT='%F %T ' # history | more 1 2008-08-05 19:02:39 service network restart 2 2008-08-05 19:02:39 exit 3 2008-08-05 19:02:39 id 4 2008-08-05 19:02:39 cat /etc/ redhat -release 2. Search the history using Control+R I strongly believe, this may be your most frequently used feature of history. When you’ve already executed a very long command, you can simply search history using a keyword and re-execute the same command without having to type it fully. Press Control+R ...

10 iozone Examples for Disk I/O Performance Measurement on Linux

Along with Monitoring different aspects on Linux server measuring IO subsystem performance is also going to be very important.        If someone is complaining that a database (or any application) running on one server (with certain filesystem, or RAID configuration) is running faster than the same database or application running on another server, you might want to make sure that the performance at the disk level is same on both the server. You can use iozone for this situation.            If you are running your database (or any application) on certain SAN or NAS environment, and would like to migrate it to different SAN or NAS environment, you should perform filesystem benchmakring on both the systems and compare it. You can use iozone for this situation.       If you know how to use iozone, you can pretty much use it for various filesystem benchmarking purpose. Download and Install IOZone Iozone is an open so...

Linux File Systems: Ext2 vs Ext3 vs Ext4

Linux File Systems: Ext2 vs Ext3 vs Ext4 ext2, ext3 and ext4 are all filesystems created for Linux. This article explains the following: High level difference between these filesystems. How to create these filesystems. How to convert from one filesystem type to another. Ext2 Ext2 stands for second extended file system. It was introduced in 1993. Developed by Rémy Card. This was developed to overcome the limitation of the original ext file system. Ext2 does not have journaling feature. On flash drives, usb drives, ext2 is recommended, as it doesn’t need to do the over head of journaling. Maximum individual file size can be from 16 GB to 2 TB Overall ext2 file system size can be from 2 TB to 32 TB Ext3 Ext3 stands for third extended file system. It was introduced in 2001. Developed by Stephen Tweedie. Starting from Linux Kernel 2.4.15 ext3 was available. The main benefit of ext3 is that it allows journaling. Journaling has a dedicated area in the file system, where...

How to Increase Screen Size or Resolution in Virtualbox for Ubuntu or Linux

Image
When a new Virtual Machine, or Virtual PC, is setup in Virtualbox for Ubuntu, or another Linux flavor, the screen size and screen resolution may be fixed smaller than your maximum resolution setting. This problem can be fixed by installing Guest Additions. Guest Additions comes with Virtualbox, but is installed after you setup your Virtual Machine, or Guest OS, to add features such as increased screen size or screen resolution. On the test PC for this example the maximum resolution is 1280 x 1024. After loading Ubuntu under Virtualbox bring up the Display Preference by going into System -> Preferences -> Display. The maximum resolution option listed is 800 x 600. Installing Guest Additions from Gnome Desktop To get a bigger screen resolution we will need to install Guest Additions. On the Virtualbox File Menu click on Devices -> Install Guest Additions.   You should now see a vboxadditions_x file now located on your Ubuntu desktop.   To o...