Posts

Showing posts from August, 2011

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

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