Friday, September 14, 2012

Unix Shell Interview question part-1

Unix Shell Interview question part-1

In shell scripting How to indentify that the previous command was run successfully?
•    How will you write a shell script to connect to SQL database?
•    What does UID and GID signify?
•    What are the different security mechanisms available in UNIX?

Unix is having 3 ways of Security Mechanism:

1. By granting or revoking File permissions. Owner or Admin can change permissions to be given to group or others by using chmod command in Unix.

2. Login is restricted using login credentials (User name and Password).

3. Password is kept in encrypted format in the file /etc/passwd

•    What are the different types of shells available in UNIX?
•    How many users have logged in and logged out in last five or 10 minutes.  Last command gives last logins of user.

•    How do you search the string for vowel's occurrence and number of occurrences of each vowel
•    What is make used for? How is it different from a shell script?
•    How to compare floating point number in shell scripting .
•    How to delete a word from a file using shell scripting???
•    How to extract the second row of a text-file?
•    How to compare two floating point numbers?
•    How to compress files by using shell scripting
•    What are the steps to take files from unix server to windows?
•    How to find see the file which is created today,s date with time after 10 a.m to 5 p.m?
•    What is the basic difference u find between a shell script and perl.I mean the advantages of one over

•    What is use of "cut" command ? Give some examples. Can we use "awk" or "sed"
•    How Connect to a Database in Shell Programming? Please tell me Step by Step?

•    What is this line in the shell script do #!/bin/ksh?
•    Write a shell script to identify the given string is palindrome or not?
•    What is the difference between writing code in shell and editor?
•    What is INODE?
•     What is the difference between a 'thread' and a 'process'?   Process uses its own own state information, use their own address spaces, and only interact with each other via interprocess communication mechanisms (generally managed by the operating system).

Process contains threads.

A single process might contains multiple threads; all threads within a process share the same state and same memory space, and can communicate with each other directly, because they share the same variables.

•    What does $# stand for? –total number of parameteres
•    What is $*? – All Arguments
•    If you have a string "one two three", Which shell command would you use to extract the strings?
•    What is the difference between a shell variable that is exported and the one that is not exported?
•     How will you list only the empty lines in a file (using grep)?   Grep “^$” file_name

Count the number of empty lines:
grep -c '^$' list.txt

•    How do you schedule a command to run at 4:00 every morning?
By Cron 

0 4 * * *


min hour DayOfMonth Month dayOfWeek Command

{MHDMD C} shortcut to remember

1.0    Format
Field name    Mandatory?    Allowed values    Allowed special characters
Minutes    Yes    0-59    * / , -
Hours    Yes    0-23    * / , -
Day of month    Yes    1-31    * / , - ? L W
Month    Yes    1-12 or JAN-DEC    * / , -
Day of week    Yes    0-6 or SUN-SAT    * / , - ? L #
Year    No    1970–2099    * / , -

•    How do u open a read only file in Unix?
•    What are the different kinds of loops available in shell script? – For, While, Until,

Name                                 ID Number

/dev/stdin                          0
/dev/stdout                       1
/dev/stderr                        2

W    whoami    Who    Finger  [ Or f]
•    Tells Idle Time
•    who is logged in, and what are they doing

    •    display your username    •    identifies the users currently logged in    •    Tells Idle Time
•    display information about users


Soft link    Hard Link
•    Symbolic link ‘is’ a file that only contains the pathname of another file or directory. it is created with ln –s

•    Operation on the symbolic link is directed to the file pointed by the it

•    A softlink fills the same role as a Windows shortcut

•    ln -s [target] [link name]

•    Creating a softlink is creating a new file, and will consume a small amount (usually 4KB) of space on your filesystem.

•    If the original file is deleted, then all softlinks to it become invalid
    •    when you create a hardlink, you are creating another pointer to the data location on disk, not a pointer to the existing file.

•    That means that editing a hard link of a file is equivalent to editing the original instance of the file.

•    You can’t use a hardlink to link to a directory.

Because a hardlink is a direct reference to the underlying filesystem, you can’t hardlink across filesystems.

•    With a hardlink, you can delete any of the instances, including the original, and as long as at least one instance exists the file will remain on the system.


1 comment:

  1. Some Links