Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts

Friday 30 August 2013

Top Most How to Find Runtime of a Process in UNIX and Linux

So you checked your process is running in Linux operating system and it's running find, by using ps command. But now you want to know, from how long process is running, What is start date of that process etc. Unfortunately ps command in Linux or any UNIX based operating system doesn't provide that information. But as said, UNIX has commands for everything, there is a nice UNIX tip, which you can use to check from how long a process is running. It’s been a long time, I have posted any UNIX or Linux command tutorial, after sharing some UNIX productivity tips . So I thought to share this nice little tip about finding runtime of a process in UNIX based systems e.g. Linux and Solaris. In this UNIX command tutorial, we will see step by step guide to find, since when a particular process is running in a server.
Read more »

Thursday 29 August 2013

Top Most 10 tips on working fast in UNIX or Linux


10 tips for working fast in UNIX
fast unix command tutorial and tipsHave you ever amazed to see someone working very fast in UNIX, firing commands and doing things in mille seconds? Yes I have seen and I have always inspired to learn from those gems of guys. This article or tutorial or whatever you call it I have dedicated to share UNIX command practices I follow to work fast, quick or efficiently in UNIX. I work for financial services industry and my work involves development and support of online stock and futures trading application in Electronic trading, Derivatives etc. all our services runs of UNIX servers so its very important for me to work efficiently and quickly in Linux machine.

This article is in continuation of my earlier article Top 10 basic networking Commands in Unix  and Top 10 most useful CVS command in Unix  and 10 examples of using find command in UNIX .

if you have not read those you can see if you find them interesting and useful. In this UNIX command tutorial I am going to share my experience on how to work quick, fast and efficiently in UNIX.

If your server also resides in UNIX machine and your day 2 day work involves lots of searching and playing around UNIX commands. Below tips are of my years of experience in UNIX which I have summarized as 10 tips to work fast in UNIX :) What I am looking forward is to get some more tips from you guys to enhance my arsenal so please share how you work in UNIX, how you make most of powerful commands and shell utilities provided by UNIX?

Please share your experience by posting comments to make this post useful and get most of it and benefit from each others experience.


1) Use !  For executing last command
This has saved my 30% time on average. It always happens that you fire same UNIX command multiple times within a fraction of seconds, before knowing this trick I used to use up and down arrow for finding my command and then executing them which takes some of my time but after
Knowing this trick I just have to remember command name e.g. !ls will execute your last "ls -lrt" , !vim will open your last file without
Typing full commands. Use it and experience it , It definitely save loads of time and its also useful on shell other than bash where up and down arrow generally doesn't give you previous commands.

For example After doing ls –l stocks.txt if you want to open stocks.txt you can use vi !$ (last argument)

2) use  !! for executing last command
This is an extension of previous tip which is used to execute the very last command you have executed. Since it just involves two keystrokes and that too for same key it’s amazingly fast. This will also works on the shells in which up and down arrow don’t work.This is extremely useful if you are stopping or starting your trading application for debug purpose frequently


3) Use "CRTL+R" for repeating the last matching command
Best out of lot if you remember your last command executed sometime back and just want to find that command with same argument and execute
This is the tip you need to remember. just press "CRTL+R" and type words that you had in your last command and UNIX will find that command for you then just press enter.

All above three tips will save lot of your time if you execute commands frequently and percentage of repetition is quite high. for me
I have saved almost 50-60% time by following above three tips. let me know how it works for you guys.

4) Using history command for getting some of the most frequently used UNIX command
This is the first thing I learn when I started working on UNIX :) This is your most helpful command in UNIX or shell. In most of the
Cases there are certain command like starting, stopping, checking log files, making build or doing release. Which we need to execute very frequently and if you don't remember exact command no need to worry, just do history | grep "keyword" and you will get that command from
UNIX history. There are certain environment variable e.g. HISTSIZE which defines how many command UNIX history can store, so have it big
Enough to save your time and avoid referencing your command booklet now and then.

5) Using regular expression in grep and find.
UNIX command tutorials and tips
grep and find is two best tools UNIX provide to us. almost everybody needs to search something in UNIX e.g. a file , a directory , certain words in file e.g. ERROR or Exception and if you know how to use grep and find with regular expression you will save lot of your time by typing less commands.

For example by knowing about egrep you can fire egrep "ERROR|Exception" *.xml instead of firing two grep command for finding ERROR and Exception individually.

6) Using pipe instead of firing two commands
Just shown above this nice and little tip I guess everybody knows :)

7) Using aliases and defining them in bash profile or bashrc file.
Have you seen some strange commands working in someone's machine and not yours, which might be aliases he would have setup in either his .bashrc or .profile file. Always do such kind of setup for commonly used command. There are lots of usage of .bashrc and .profile file but
One of the most important one is setting up aliases e.g.  "l." which finds all hidden files. "ls" which includes all useful option e.g. -lrtH to show all relevant information.

8) Using pushd, popd , cd - , ~ for moving across directory.
Based on my experience navigation in UNIX shell takes almost 50% times of people and if you are going to write directory path every now and then just forget about working fast. so instead of typing full name use all above tips and make best use of pushd, popd, cd - and cd ~ command. cd - is best if your switching between two directory location in UNIX.

9) Minimize the key strokes or increase the speed of typing.
That I guess you know isn't it the less you type the more fast you work so make use of your last typed command, make use of tab in bash so that let the UNIX bash shell complete your command, use Ctrl+R if the last command you have typed is very long and you want to change just few lines.

10) Try to learn more commands and their options and usage this will reduce thinking time for a particular task and use  ctrl+z and fg and bg to suspend a process. it saves almost 10% time if you are viewing multiple files or log files so instead of every now and then executing vim commands just do Ctrl+Z to suspend it and fg 1 or fg 2 to bring it on foreground.

I hope these examples, tips on UNIX command will help you to do more in less time and enhance your productivity and experience while working in UNIX. This list is by no means complete so please share how you working in UNIX and of course how fast are you working in UNIX?

If you are preparing for any job interview on Investment bank for Trading floor support or any other Trading support role you may find my FIX protocol interview questions and  FIX protocol tutorials series helpful. most of the investment bank support role checks three things UNIX, Perl , SQL and FIX protocol so if you are good on these four you have more chances of landing a  good job in Investment bank.

Wednesday 28 August 2013

Top Most 10 xargs command example in Linux - Unix tutorial

xargs command in unix or Linux is a powerful command used in conjunction with find and grep command in UNIX to divide a big list of arguments into small list received from standard input. find and grep command produce long list of file names and we often want to either remove them or do some operation on them but many unix operating system doesn't accept such a long list of argument. UNIX xargs command divide that list into sub-list with acceptable length and made it work. This Unix tutorial is in continuation of my earlier post on Unix like 10 examples of chmod command in Unix and How to update soft link in Linux. If you haven’t read those unit tutorial than check them out. By the way In this tutorial we will see different example of unix xargs command to learn how to use xargs command with find and grep and other unix command and make most of it. Though what you can do with xargs in unix can also be done by using options provided in find but believe xargs is much easy and powerful.
Read more »

Monday 26 August 2013

Top Most 5 example of sort command in UNIX or Linux >>>> Unix Tutorial

Sorting is one of essential task we always need to perform and UNIX or Linux has great support for sorting by using sort command. No matter what kind of shell script you are writing or you are looking for some information or reports many times you need to sort the output from one command or a set of line, with combination of sort with find command and grep in unix you can handle support request and reporting quite easily. In this UNIX sort command tutorial we will see how we can use sort command in UNIX to achieve our sorting goal. This tutorial contains some of practical example of sort command for sorting data in UNIX. With the use of “uniq” and “sort” command you can remove duplicates and present a sorted data in UNIX.
Read more »

Sunday 25 August 2013

Top Most List of special bash parameter used in Unix or Linux script


Meaning of bash parameter used in Unix script

Many of us use bash script for doing housekeeping and other stuff but occasionally and not much aware of special bash parameters. When I was new to bash shell and Linux and looking on some already written bash script I used to get baffled with special bash symbols like $@, $_, $1 etc. I did know that they are bash parameter and has special meaning but I don't have all meanings of special bash parameter on top of my head and I always go to Google and search endlessly for those special bash parameter, some time I got and found meaning of those special bash script parameters quickly but sometime I need spend some time to get what I am actually looking for, so I thought to document meanings and expansion of those special bash parameters or bash script parameters.

This bash script parameter tutorial is in continuation of my earlier UNIX tutorials find examples in UNIX, grep command examples in UNIX, and UNIX networking commands tutorial if you haven’t read already you may find them interesting and useful.
Read more »

Saturday 24 August 2013

Top Most How to delete empty files directories in Unix Linux

Deleting empty file and directory in Unix
Many times we need to find and delete empty files or directories in UNIX/Linux. Since there is no single command in Unix/Linux which allows you to remove empty files or empty directories rather we need to rely on find command and xargs command. In this UNIX and linux example we will see How to delete empty files and directories. Before removing empty files and directories we need to find those files and there are lots of option available to search for empty directories like find, grep, awk etc. You just need to know correct option. Like in any other operating system empty files and directories in Unix are those whose size is zero. Empty files doesn't contains any content while empty directories does not contain anything at all e.g files or sub-directories. As discussed in previous post 10 frequently used  find command exampleswe can also use find command to search and delete empty files and directories as it provides searching files based on size as well.
Read more »

Friday 23 August 2013

Top Most How to find file and directory size in Unix with Example - Linux tutorial

How to find size of directory in unix
Finding file size or directory size in Unix and Linux is not very difficult but if you came from windows background than it may sounds difficult to you because you need to remember unix commands for file and directory size. This is a common complain from windows user when they exposed to Unix operating system be it Linux or Solaris. but In my opinion having commands for doing things is more powerful because you can write powerful scripts for removing large files or taking backup of directories in unix which is not possible with GUI based operating systems like Windows. In this unix command tutorial we will see how to find size of file and directory in unix, how to find large files in unix, how to find disk space in file system and some other file and directory related stuff.

This article is continuation of my earlier post on Unix e.g. 10 Example of grep command in Unix, 10 example of chmod command in unix and How to sort files and directory in Unix using sort command. If you haven’t read them already, You may find them useful and interesting.
Read more »

Wednesday 21 August 2013

Top Most How to create update or remove symbolic or soft link in Unix and Linux

Symbolic links , Symlink or Soft link in Unix are very important concept to understand and use in various UNIX operating systems e.g. Linux , Solaris or IBM AIX. Symlinks gives you so much power and flexibility that you can maintain things quite easily.I personally feel that along with find, grep and other UNIX commands, command to create soft link and update soft link i.e. ln -s  is also must for any one working in UNIX machine. Whenever I do scripting or write any UNIX script I always write for symlinks rather than pointing to absolute path of directories in UNIX. It gives you flexibility of changing the symlink or soft link without making any change on your tried and tested scripts. I have worked on many different core Java projects which run on Linux and UNIX machine and make extensive use of UNIX symbolic links or symlinks. All my project which are on finance domain and on electronic trading systems have there server running on Linux,  Since speed is major concern in online stock or futures trading where orders has to hit the market within micro seconds Linux server is ideal choice for electronic and fix trading systems and since your server is on UNIX you have to be expert of Unix command to work efficiently and these articles are my result of those effort to learn and share new UNIX commands. In this UNIX fundamental tutorial we will see How to create soft link in UNIX, How to update soft link and Difference between Soft link and Hard link in Unix and Linux. By the way this UNIX command tutorial is  in continuation of my earlier article top networking commands in Unix  and CVS command examples ,  if you haven’t read already you may find some useful information based on my experience in Unix and Linux commands.
Read more »

Tuesday 20 August 2013

Top Most 10 example of using Vim or VI editor in UNIX and Linux


Vim or VI editor tutorial in UNIX

vi editor in unixVI Editor is like notepad in UNIX but it’s extremely powerful and have sophisticated feature to work as complete IDE. No matter which version of UNIX you are working or which flavor you are using you always find either VI editor or VIM there. VI is a very large topic and I am not covering every aspect of it what I am sharing here is some examples of using VI editor in UNIX or Linux. most of the time we use only 10% of VI editor and never know 90% of it , to be frank I also don't know many of VI feature by heart but I always search for it , see people working in VI and learn from there experience as well. after working on VI editor what I found that every day we learn something new in VI editor but we  forget something equally important and there I thought lets document whatever VI commands I have learned so far and using regularly. Idea is to keep this VI Editor tutorial updated with every single useful VI commands I learn and I also ask you guys to contribute with something useful. If you see 10 peoples working in VI editor you realize that they use it differently then use some new VI commands which you are not familiar of and which could improve your productivity as well. so if you would like to know more and more about VI editor I would suggest observe people around you when they work in VIM or VI editor and learn from there experience. Don’t confuse with both VIM and VI, VIM stands for VI improved and has some more feature than VI editor. Many a times you will find that VI command is aliased to VIM to make it default editor in UNIX.
Read more »

Sunday 18 August 2013

Top Most 10 Example of find command in Unix and Linux

find command is one of the versatile command in UNIX and Linux  and I used it a lot in my day to day work. I believe having knowledge of find command in UNIX and understanding of its different usage will increase your productivity a lot in UNIX. If your works involve lots of searching stuff on Linux machine or if you are a java or C++ programmer and your code resides in UNIX, find command can greatly help you to look for any word inside your source file in the absence of an IDE, It is the alternative way of searching things in UNIX. grep is another Linux command which provides similar functionality like find but in my opinion later is much more powerful than grep in UNIX.

I have been sharing my experience on Unix and Linux command and its different options, usage and example and this article is in continuation of my earlier post like How to convert IP address to hostname in Linux . If you are new here you may find those tips useful for your day 2 day development and support work.

Read more »

Saturday 17 August 2013

Top Most File permissions in UNIX Linux with Example >> Unix Tutorial

Whenever we execute ls command in UNIX you might have observed that it list file name with lot of details e.g.
stock_options:~/test ls -lrt
total 8.0K
-rw-r--r-- 1 stock_options Domain Users 1.1K Jul 15 11:05 sample

If you focus on first column you will see the file permissions as "-rw-r--r--" this is made of three parts user, group and others. User part is permission relate to user logged in, group is for all the members of group and others is for all others. also each part is made of three permissions read, write and execute so "rw-" means only "read and write" permission and "r--" means read only permission. So if you look permission of example file it has read and writes access for user, read only access for groups and others. Now by using chmod command in UNIX we can change the permissions or any file or directory in UNIX or Linux. Another important point to remember is that we need execute permission in a directory to go inside a directory; you can not go into directory which has just read and write permission.
Read more »

Thursday 15 August 2013

Top Most UNIX and Linux commands tutorial , tips and examples for beginners.


Unix commands tutorials for beginners

UNIX and Linux commands tutorial and tips for beginners.

Hi, this is a kind of revision post where I would like share some of my earlier posted UNIX commands tutorial. Purpose of this post is to put together all UNIX commands tutorial in one place for easy access to anyone. These are collection of my favorite UNIX commands which you guys may find it interesting. I have been working in UNIX from almost 4 years and I have learned many UNIX commands during these year which has helped me a lot during by day 2 day working on Unix shell. These UNIX command s tutorials are based on my experience; I have shared UNIX command which I used so these are quite practical tips and tricks. It may not be in proper tutorial format like any other UNIX commands tutorial but I am sure this will be useful. This list is by no means complete so please share your UNIX commands experience so that we both can benefit from each others experience.

10 Unix commands to working fast in Linux

Have you ever amazed to see someone working very fast in UNIX shell, Executing UNIX commands with lighting speed and doing things in milli seconds? Yes I have seen and I have always inspired to learn from those gems of guys. This article or tutorial or whatever you call it I have dedicated to share UNIX commands practices which I follow to work fast, quick or efficiently in UNIX. I work for financial services industry and my work involves development and support of trading application in Electronic trading, Derivatives etc. all our services runs of UNIX servers so it’s very important for me to work efficiently and quickly in Linux machine. By using these UNIX commands I am sure your speed will increase and you would be able to do more with less time. There is no end of learning Unix commands everyday you discover something new but you forget something equally important , best way to keep you updated is learn new Unix commands everyday and utilize them share them.  
To read more see here 10 examples of working fast in Linux

10 examples of using find command in UNIX


Unix commands tutorials examples and tips for beginners
find is very versatile UNIX command  and I used it a lot in my day to day work. I believe having knowledge of find command in UNIX and understanding of its different usage will increase your productivity a lot in UNIX. If your works involve lots of searching stuff or if you are a java or C++ programmer and your code resides in UNIX, find can greatly help you to look for any word inside your source file in the absence of an IDE, find is the alternative way of searching things in UNIX. Grep is another UNIX command which provides similar functionality like find but in my opinion find is much more powerful than grep in UNIX. There are some more UNIX commands which are equally important than find and grep but in my opinion these two covers all searching functionality in Unix and you won’t require any other UNIX commands to run for any searching purpose if you master these two.

To read more see here 10 tips of using find command in Linux.



10 Most useful CVS  Unix commands

Here is my list of most useful UNIX commands in Linux for CVS. CVS is very popular source repository and heavily used in Java development for source control, most of the time your source code needs to built in UNIX machine for release purpose and you need to checkout and make build in UNIX machine. Having knowledge of essential CVS Unix commands will help you a lot and saves your time.

Checking out code 

cvs co –A folder or filename ( -A means head , this will checkout from head)
cvs co -rtag1 folder or filename (-r means tag or branch, this will checkout from tag “tag1”)
cvs co -rbranch1 folder of filename ( checking out from cvs branch)

To read full article please see here CVS Command Tutorial in UNIX and Linux

Top 10 basic networking Unix Commands

Unix commands examples tutorials and tips for beginners
These are most useful Unix commands in my list while working on Linux server , this enables you to quickly troubleshoot any kind of Unix connection issues e.g. whether other system is connected or not , whether other host is responding or not and while working for FIX connectivity for advanced trading system this tools saves quite a lot of time . Having knowledge of networking UNIX commands is essential for anybody who is working in Investment banking and cash equities area. Since financial application built for electronic trading for equities, futures and option heavily used TCP IP and FIX Protocol If you don’t know basic networking UNIX commands like telnet, ping, netstat it would be very difficult to quickly sort out any FIX connection issue.

• finding host/domain name and IP address - hostname
• test network connection – ping
• getting network configuration – ifconfig
• Network connections, routing tables, interface statistics – netstat
• query DNS lookup name – nslookup

To read full list of UNIX commands tutorial on UNIX networking commands please see here Networking UNIX commands tutorial


If you like MySQL as your database you may find my MySQL commands tutorial series useful. 

Wednesday 14 August 2013

Top Most 5 Example of kill command in UNIX and Linux

Kill command in UNIX and Linux is normally used to kill a suspended or hanged process or process group. Though kill is mainly associated with kill operation its mere a signal transporter and can send specified signal to specified process in UNIX or UNIX like systems e.g. Linux, Solaris or FreeBSD. Like in windows when we see a particular process hung the system we go to task-manager find the process and kill it, similarly in UNIX and Linux we first find the process ID (PID) of offending process and then kill it. Though we have killAll command also which doesn't require PID instead it can kill the process with just process name. Kill commands is often a wrapper around kill () system call but some Linux systems also has built-in kill in place. In this article we will see some examples of kill command in UNIX and how we can use kill command to kill the locked process.

Read more »

Top Most Top 30 UNIX command Interview Questions asked in Investment Banks

UNIX command Questions Answers asked in Interview
UNIX or Linux operating system has become default Server operating system and for whichever programming job you give interview you find some UNIX command interview questions there. These UNIX command interview questions are mostly asked during Java development and Support role interviews on various investment banks mostly because most of electronic trading systems or stock trading system works on Unix servers. As we know that high volume low latency systems which wants to take advantage of little bit of volatility in market for Equity , Futures and options or Foreign exchange trading need a stable server side operating system and Redhat Linux is doing great job there. with the advent of Algorithmic trading this speed factor becomes more important so getting someone who has good knowledge of operating system and commands on which these trading system runs is definitely required. but these UNIX command interview questions are equally applicable for any job interview which requires some work on Unix Operating System. With the growing use of Linux in form of RedHat, Solaris and IBM AIX its must to keep you familiar with essential Linux commands available on various platforms. 

Unix and Linux Command Interview Questions and AnswersLong back I had once asked one of my friend why are you preparing Unix Command interview questions if you going for a Java Interview and he told me that this job doesn't only require knowledge of Java but also knowledge of Unix, Linux, SQL and other scripting language , which is quite true. After that I thought to collect various UNIX command interview questions asked to Java developers or trading system support interviews and this is the result of that compilation. This list of UNIX command interview questions are by means complete and would be great if you guys contribute some genuine and good Unix Command Interview questions and answers asked during interviews. I have divided the questions on three categories for sake of managing and keeping this list of Unix Interview questions up to date.


Beginners UNIX Interview Questions Answers

1. Write command to list all the links from a directory?
In this UNIX command interview questions interviewer is generally checking whether user knows basic use of "ls" "grep" and regular expression etc
You can write command like:
ls -lrt | grep "^l"


2. Create a read-only file in your home directory?
This is a simple UNIX command interview questions where you need to create a file and change its parameter to read-only by using chmod command you can also change your umask to create read only file.
touch file
chmod 400 file
3. How will you find which operating system your system is running on in UNIX?
By using command "uname -a" in UNIX

4. How will you run a process in background? How will you bring that into foreground and how will you kill that process?
For running a process in background use "&" in command line. For bringing it back in foreground use command "fg jobid" and for getting job id you use command "jobs", for killing that process find PID and use kill -9 PID command. This is indeed a good Unix Command interview questions because many of programmer not familiar with background process in UNIX.

5. How do you know if a remote host is alive or not?
You can check these by using either ping or telnet command in UNIX. This question is most asked in various Unix command Interview because its most basic networking test anybody wants to do it.


6. How do you see command line history in UNIX?
Very useful indeed, use history command along with grep command in unix to find any relevant command you have already executed. Purpose of this Unix Command Interview Questions is probably to check how familiar candidate is from available tools in UNIX operation system.

7. How do you copy file from one host to other?
Many options but you can say by using "scp" command. You can also use rsync command to answer this UNIX interview question or even sftp would be ok.

8. How do you find which process is taking how much CPU?
By using "top" command in UNIX, there could be multiple follow-up UNIX command interview questions based upon response of this because “TOP” command has various interactive options to sort result based upon various parameter.

9. How do you check how much space left in current drive ?
By using "df" command in UNIX. For example "df -h ." will list how full your current drive is. This is part of anyone day to day activity so I think this Unix Interview question will be to check anyone who claims to working in UNIX but not really working on it.

10. What is the difference between Swapping and Paging?
Swapping:
Whole process is moved from the swap device to the main memory for execution. Process size must be less than or equal to the available main memory. It is easier to implementation and overhead to the system. Swapping systems does not handle the memory more flexibly as compared to the paging systems.
Paging:
Only the required memory pages are moved to main memory from the swap device for execution. Process size does not matter. Gives the concept of the virtual memory. It provides greater flexibility in mapping the virtual address space into the physical memory of the machine. Allows more number of processes to fit in the main memory simultaneously. Allows the greater process size than the available physical memory. Demand paging systems handle the memory more flexibly.


Intermediate UNIX Interview Questions Answers

1. What is difference between ps -ef and ps -auxwww?
UNIX interview questions answers, UNIX Linux questionsThis is indeed a good Unix Interview Command Question and I have faced this issue while ago where one culprit process was not visible by execute ps –ef command and we are wondering which process is holding the file.
ps -ef will omit process with very long command line while ps -auxwww will list those process as well.

2. How do you find how many cpu are in your system and there details?
By looking into file /etc/cpuinfo for example you can use below command:
cat /proc/cpuinfo

3. What is difference between HardLink and SoftLink in UNIX?
I have discussed this Unix Command Interview questions  in my blog post difference between Soft link and Hard link in Unix

4. What is Zombie process in UNIX? How do you find Zombie process in UNIX?
When a program forks and the child finishes before the parent, the kernel still keeps some of its information about the child in case the parent might need it - for example, the parent may need to check the child's exit status. To be able to get this information, the parent calls 'wait()'; In the interval between the child terminating and the parent calling 'wait()', the child is said to be a 'zombie' (If you do 'ps', the child will have a 'Z' in its status field to indicate this.)
Zombie : The process is dead but have not been removed from the process table.

5. What is "chmod" command? What do you understand by this line “r-- -w- --x?

6. There is a file some where in your system which contains word "UnixCommandInterviewQuestions” How will find that file in Unix?
By using find command in UNIX for details see here 10 example of using find command in Unix

7. In a file word UNIX is appearing many times? How will you count number?
grep -c "Unix" filename

8. How do you set environment variable which will be accessible form sub shell?
By using export   for example export count=1 will be available on all sub shell.

9. How do you check if a particular process is listening on a particular port on remote host?
By using telnet command for example “telnet hostname port”, if it able to successfully connect then some process is listening on that port. To read more about telnet read networking command in UNIX

10. How do you find whether your system is 32 bit or 64 bit ?
Either by using "uname -a" command or by using "arch" command.


Advanced UNIX Interview Questions and Answers

1. How do you find which processes are using a particular file?
By using lsof command in UNIX. It wills list down PID of all the process which is using a particular file.

2. How do you find which remote hosts are connecting to your host on a particular port say 10123?
By using netstat command execute netstat -a | grep "port" and it will list the entire host which is connected to this host on port 10123.

3. What is nohup in UNIX?

4. What is ephemeral port in UNIX?
Ephemeral ports are port used by Operating system for client sockets. There is a specific range on which OS can open any port specified by ephemeral port range.

5. If one process is inserting data into your MySQL database? How will you check how many rows inserted into every second?
Purpose of this Unix Command Interview is asking about "watch" command in UNIX which is repeatedly execute command provided with specified delay.

6. There is a file Unix_Test.txt which contains words Unix, how will you replace all Unix to UNIX?
You can answer this Unix Command Interview question by using SED command in UNIX for example you can execute sed s/Unix/UNIX/g fileName.

7. You have a tab separated file which contains Name, Address and Phone Number, list down all Phone Number without there name and Addresses?
To answer this Unix Command Interview question you can either you AWK or CUT command here. CUT use tab as default separator so you can use
cut -f3 filename.

8. Your application home directory is full? How will you find which directory is taking how much space?
By using disk usage (DU) command in Unix for example du –sh . | grep G  will list down all the directory which has GIGS in Size.

9. How do you find for how many days your Server is up?
By using uptime command in UNIX

10. You have an IP address in your network how will you find hostname and vice versa?
This is a standard UNIX command interview question asked by everybody and I guess everybody knows its answer as well. By using nslookup command in UNIX, you can read more about Convert IP Address to hostname in Unix here.

I hope this UNIX command interview questions and answers would be useful for quick glance before going for any UNIX or Java job interview. Please share any interesting UNIX command interview you have come across and I will add into this list. If you are going for any Unix interview on brokerage firm or stock trading company or any Investment bank you can have a quick look here, though most of questions you might already know but its good to review it. if you like this you can see my other unix command tutorial for beginners as well 


Some of my favorite interview questions post , you may find interesting


Enjoy :)

Monday 12 August 2013

Top Most 10 examples of grep command in UNIX and Linux

grep command examples in Unix and Linux
grep command is one of the most frequently used UNIX command stands for "Global Regular Expression Print"  like  find command, chmod command or tar command in Unix. grep command in Unix operating system e.g. Linux, Solaris, BSD, Ubuntu or IBM AIX is used to search files with matching patterns, by using grep command in Unix you can search a file which contains a particular word or particular pattern. UNIX grep command also provides several useful command line option which can be used to enhance functionality of grep command e.g. by using grep -v you can list down all files which doesn't contains a word i.e. excluding files which matches a pattern, grep -c will print count of matching pattern in a file etc. One of the popular example of  grep command is to find empty files and directories in Unix. This grep command tutorial is not about theory of UNIX grep but practical use of grep command in UNIX and here I am sharing my experience on use of grep command in Linux with an aim that this would serve as quick guide or tutorial for using grep in UNIX for new beginners and help them to understand the grep command better and its thoughtful usage in UNIX or Linux. Many people use grep just for finding words in a file and missed the real potential of grep by not using all its powerful command line options and its regular expression capability which could not only save a lot of time but also works as a great and powerful tool while analyzing large set of data or log files.  Also find command in UNIX can be used in place of grep at many places.
Read more »

Sunday 11 August 2013

Top Most How to find IP Address from hostname in Windows Linux and Unix

IP Address from hostname in Windows and Linux
How many times in a day you have a hostname and you want to know the IP address? Host name to IP address and IP address to hostname conversion is one of frequent thing which we need to do for many things when dealing with networking command in unix. For one command we need IP address for other we need hostname even from bash script some time we require hostname and some time we look for IP address. networking commands are not as popular as find command or grep command but they are equally important and if you working in Windows or UNIX environment you must learn them and they should also be included in any list of Unix commands for beginners. By the way In this hostname to IP address tutorial I will show you how to get IP address from hostname or computer-name in Unix or Linux and how to get hostname if you have IP address. If you are looking a way to do it via Java program then you can also see my post how to find IP address of localhost in Java.
Read more »

Friday 9 August 2013

Top Most 10 example of chmod command in UNIX Linux

chmod command in UNIX or Linux is used to change file or directory permissions. This is one of many UNIX basic commands which a UNIX or Linux user must be familiar with. In this UNIX command tutorial we will see how to change file permissions using chmod command, what are file permissions in UNIX, how to change permissions of directory and sub-directory using UNIX chmod command and finally how to create executable files in UNIX using chmod command. Before going directly into examples of chmod command let's spend few minutes on understanding file permissions in UNIX and why do we need to change file permissions etc.
Read more »

Wednesday 7 August 2013

Top Most 10 examples of Date command in Unix

Date command in unix or Linux is one of important command to learn and master because we always need date information. no matter you want to know current date in unix or your bash script needs current date in unix for archiving purpose you need to use date command. In its simplest format date command shows the current date and time in unix while with sophisticated option we can extract many useful information from unix date command. In this Unix command tutorial  we will see some useful tips on using date command in unix and learn more around date in unix and Linux. One important thing to note is that different implementation of unix date command may not be exactly same e.g. AIX version of date command doesn't support option "-d" or "date". Anyway let's see some example of unix date command:

By the way this is fifth article in my series of covering examples of important and frequently used commands e.g. find examples, grep examples, chmod example and sort command example.
Read more »

Monday 5 August 2013

Top Most 10 Examples of tar command in UNIX and Linux

tar command in UNIX or Linux is one of the important command which provides archiving functionality in unix. we can use UNIX tar command to create compressed or uncompressed archive files by using either gzip or bzip2. In this unix tar command tutorial we will see examples of unix tar command related to basic archiving task e.g. How to create tar archive in Unix and Linux, How to extract files from tar archive in unix, How to view contents of tar file in Unix and Linux or how to update and existing tar file in Unix. Examples of tar command in unix are kept simple and easy to understand and master each of basic task using unix tar command.
Read more »

Top Most How to use Regular Expression in Unix Linux

One of the most powerful tools available to programmers are Regular Expressions, if you are good with regular expressions you can solve many day to day problem extremely quickly e.g. find all the lines with ERROR in log file , find count of any particular ID in log file , find exceptions etc.

regular expression is generic concept which has implemented on many different language and many different tools including Java , here is some of the tools and languages which use regular expression.

  • The vi editor which comes standard with the Unix/Linux operating system.

  • Any decent programmer's editor e.g. EditPlus

  • The grep command found standard on many operating systems including Unix/Linux

  • The Perl programming language.  

  • The PHP programming language. 


regular Even if you feel regular expression is complex and hard to learn I would suggest to familiarize with atleast basic set of regex and try to use it as much as possible and later you will only want to learn more and more to do the stuff quickly.

here are some of the basic regex and there examples:

1) you want to find ERROR in log file in linux ?    
grep ERROR logfile

2) you want to find lines starts with ERROR ?
grep ^ERROR logfile     (^ is used to find for startswith)

3) you want to find lines ends with ERROR ?
grep ERROR$ logfile     ($ is used to find for endswith)

4) you want to find empty lines in log file ?
grep ^$ logfile

5) you want to match upper or lower case ERROR ?
grep [Ee]RROR logfile               ([] is used to include letters]

6) find all lines that contains Error or Exception ?
egrep ERROR|Exception logfile   ( | is used for OR condition)

7) Match the letter E when it appears at least 3 times in a row but possibly 4 or more times in a row: E {3,} 

8) Match the letter E when it appears 3 times in a row or 6 times in a row or anything in between. E{3,6}

9)Match E when it appears 1 or more times in a row.
E+ 

10) (E+ and E{1,} mean exactly the same thing!)

LinkWithin

Related Posts Plugin for WordPress, Blogger...

Labels

Core Java programming core java interview question Core Java Faq's Servlets coding database jsp-servlet spring Java linux unix interview questions java investment bank Web Services Interview investment bank mysql Senior java developer interviews best practices java collection tutorial RMI SQL Eclipse FIX protocol tutorial tibco J2EE groovy java questions SCJP grails java 5 tutorial jdbc beginner error and exception Design Patterns Java Programming Tutorials fundamentals general object oriented programming xml Java Programs Hibernate Examples Flex JAMon Java xml tutorial logging Jsp Struts 2.0 Sybase and SQL Server debugging java interviews performance FIX Protocol interview questions JUnit testing WebSphere date and time tutorial experienced java IO tutorial java concurrency thread Ejb Freshers Papers IT Management Java Exapmle Java Script SQL and database tutorial examples Scwcd ant tutorials concurrency example and tutorial future state homework java changes java threading tricky Agile Business of IT Development JSTL Java JSON tutorial Java multithreading Tutorials PM Scrum data structure and algorithm java puzzles java tips testing tips windows 8 5 way to create Singleton Object Architect Interview Questions and Answers Architecture Architecure Bluetooth server as swing application that searches bluetooth device in 10 meter circle and show all devices. You can send file to any bluetooth device. C Programming CIO Callable Statement in Java Circular dependency of Objects in Java Comparable Example in Collection Custom annotation in Java Developer Interview Divide and rule example in java Drupal Example of Singleton Pattern FIX protocol ForkJoin Example in Java 7 Get data from dynamic table with Java Script Git HTML and JavaScript Health Hello World TCP Client Server Networking Program Hibernate Basics Hibernate Interview Question Answer J2EE Interview Question And Answers J2ME GUI Program JEE Interview QA JMS interview question Java J2EE Hibernate Spring Struts Interview Question Java System Property Java Threads Manager Portlets Provident Fund Read data from any file in same location and give the required result. Reading Properties File in Java Redpoint Rest WebService Client Rest Webservice Test SAL join with ven diagram SCP UNIX COMMAND SSL Singleton Pattern in Java Spring Bean Initialization methods and their order Spring Interview Questions Struts Struts 2.0 Basics Struts 2.0 Design Pattern Submit Html Form With Java Script On The Fly Unix executable For Java Program XOM DOM SAX XP books computers core java; core java; object oriented programming data structure; java investment bank; design pattern dtd duplicate rows in table get browser name with jquery grails podcast inner class java beginners tutorial java cache java networking tutorial java spring java util; java collections; java questions java.java1.5 linked list mailto function with all browser oracle database oracle duplicate rows orm schema social spring mvc questions struts transaction tricks tweet windows xslt