- How do you take a single line of input from the user in a shell script?
- Write a script to convert all DOS style backslashes to UNIX style slashes in a list of files.
- Write
a regular expression (or sed script) to replace all occurrences of the
letter ‘f’, followed by any number of characters, followed by the
letter ‘a’, followed by one or more numeric characters, followed by the
letter ‘n’, and replace what’s found with the string “UNIX”. - Write a script to list all the differences between two directories.
- Write a program in any language you choose, to reverse a file.
- What are the fields of the password file?
- What does a plus at the beginning of a line in the password file signify?
- Using the man pages, find the correct ioctl to send console output to an arbitrary pty.
- What is an MX record?
- What is the prom command on a Sun that shows the SCSI devices?
- What is the factory default SCSI target for /dev/sd0?
- Where is that value controlled?
- What happens to a child process that dies and has no parent process to wait for it and what’s bad about this?
- What’s wrong with sendmail? What would you fix?
- What command do you run to check file system consistency?
- What’s wrong with running shutdown on a network?
- What can be wrong with setuid scripts?
- What value does spawn return?
- Write
a script to send mail from three other machines on the network to root
at the machine you’re on. Use a ‘here doc’, but include in the mail
message the name of the machine the mail is sent from and the disk
utilization statistics on each machine? - Why can’t root
just cd to someone’s home directory and run a program called a.out
sitting there by typing “a.out”, and why is this good? - What is the difference between UDP and TCP?
- What is DNS?
- What does nslookup do?
- How do you create a swapfile?
- How would you check the route table on a workstation/server?
- How do you find which ypmaster you are bound to?
- How do you fix a problem where a printer will cutoff anything over 1MB?
- What is the largest file system size in solaris? SunOS?
- What are the different RAID levels?
- Advantages/disadvantages of script vs compiled program.
- Name a replacement for PHP/Perl/MySQL/Linux/Apache and show main differences.
- Why have you choosen such a combination of products?
- Differences between two last MySQL versions. Which one would you choose and when/why?
- Main differences between Apache 1.x and 2.x. Why is 2.x not so popular? Which one would you choose and when/why?
- Which Linux distros do you have experience with?
- Which distro you prefer? Why?
- Which tool would you use to update Debian / Slackware / RedHat / Mandrake / SuSE ?
- You’re asked to write an Apache module. What would you do?
- Which tool do you prefer for Apache log reports?
- Your portfolio. (even a PHP guest book may work well)
- What does ‘route’ command do?
- Differences between ipchains and iptables.
- What’s eth0, ppp0, wlan0, ttyS0, etc.
- What are different directories in / for?
- Partitioning scheme for new webserver. Why?
Unix/Linux programming interview questions
Question 1: What is the major advantage of a hash table? (Asked by Silicon Magic Corp. people)
Answer:
The major advantage of a hash table is its speed. Because the hash
function is to take a range of key values and transform them into index
values in such a way that the key values are distributed randomly
across all the indices of a hash table.
Question 2: What are the techniques that you use to handle the collisions in hash tables?(Asked by Silicon Magic Corp. people)
Answer:
We can use two major techniques to handle the collisions. They are open
addressing and separate chaining. In open addressing, data items that
hash to a full array cell are placed in another cell in the array. In
separate chaining, each array element consist of a linked list. All
data items hashing to a given array index are inserted in that list.
Question 3: In Unix OS, what is the file server? (Asked by Silicon Magic Corp. people)
Answer: The file server is a machine that shares its disk storage and files with other machines on the network.
Question 4: What is NFS? What is its job?(Asked by Silicon Magic Corp. people)
Answer:
NFS stands for Network File System. NFS enables filesystems physically
residing on one computer system to be used by other computers in the
network, appearing to users on the remote host as just another local
disk.
Question 5: What is CVS? List some useful CVS commands.(Asked by Silicon Magic Corp.people)
Anser:
CVS is Concurrent Version System. It is the front end to the RCS
revision control system which extends the notion of revision control
from a collection of files in a single directory to a hierarchical
collection of directories consisting of revision controlled files.
These directories and files can be combined together to form a software
release.
There are some useful commands that are being used very often. They are
cvs checkout
cvs update
cvs add
cvs remove
cvs commit
Unix/Linux administration interview questions
What is LILO?
LILO
stands for Linux boot loader. It will load the MBR, master boot record,
into the memory, and tell the system which partition and hard drive to
boot from.
What is the main advantage of creating links to a file instead of copies of the file?
A:
The main advantage is not really that it saves disk space (though it
does that too) but, rather, that a change of permissions on the file is
applied to all the link access points. The link will show permissions
of lrwxrwxrwx but that is for the link itself and not the access to the
file to which the link points. Thus if you want to change the
permissions for a command, such as su, you only have to do it on the
original. With copies you have to find all of the copies and change
permission on each of the copies.
Write a command to find all of the files which have been accessed within the last 30 days.
find / -type f -atime -30 > December.files
This
command will find all the files under root, which is ‘/’, with file
type is file. ‘-atime -30′ will give all the files accessed less than
30 days ago. And the output will put into a file call December.files.
What is the most graceful way to get to run level single user mode?
A: The most graceful way is to use the command init s.
If you want to shut everything down before going to single user mode then do init 0 first and from the ok prompt do a boot -s.
What does the following command line produce? Explain each aspect of this line.
$ (date ; ps -ef | awk ‘{print $1}’ | sort | uniq | wc -l ) >> Activity.log
A:
First let’s dissect the line: The date gives the date and time as the
first command of the line, this is followed by the a list of all
running processes in long form with UIDs listed first, this is the ps
-ef. These are fed into the awk which filters out all but the UIDs;
these UIDs are piped into sort for no discernible reason and then onto
uniq (now we see the reason for the sort - uniq only works on sorted
data - if the list is A, B, A, then A, B, A will be the output of uniq,
but if it’s A, A, B then A, B is the output) which produces only one
copy of each UID.
These UIDs are fed into wc -l which counts the lines - in this
case the number of distinct UIDs running processes on the system.
Finally the results of these two commands, the date and the wc -l, are
appended to the file "Activity.log". Now to answer the question as to
what this command line produces. This writes the date and time into the
file Activity.log together with the number of distinct users who have
processes running on the system at that time. If the file already
exists, then these items are appended to the file, otherwise the file
is created.
Solaris interview questions
- List the files in current directory sorted by size ? - ls -l | grep ^- | sort -nr
- List the hidden files in current directory ? - ls -a1 | grep "^\."
- Delete blank lines in a file ? - cat sample.txt | grep -v ‘^$’ > new_sample.txt
- Search for a sample string in particular files ? - grep .Debug. *.confHere grep uses the string .Debug. to search in all files with extension..conf. under current directory.
- Display the last newly appending lines of a file during appendingdata to the same file by some processes ? - tail .f Debug.logHere tail shows the newly appended data into Debug.log by some processes/user.
- Display the Disk Usage of file sizes under each directory in currentDirectory ? - du -k * | sort .nr (or) du .k . | sort -nr
- Change to a directory, which is having very long name ? - cd CDMA_3X_GEN*Here original directory name is . .CDMA_3X_GENERATION_DATA..
- Display the all files recursively with path under current directory ? - find . -depth -print
- Set the Display automatically for the current new user ? - export
DISPLAY=`eval ‘who am i | cut -d"(" -f2 | cut -d")" -f1′`Here in above
command, see single quote, double quote, grave ascent is used. Observe
carefully. - Display the processes, which are running under yourusername ? - ps .aef | grep MaheshvjHere, Maheshvj is the username.
- List some Hot Keys for bash shell ? - Ctrl+l . Clears the Screen. Ctrl+r . Does a search in previously given commands in shell. Ctrl+u - Clears the typing before the hotkey. Ctrl+a . Places cursor at the beginning of the command at shell. Ctrl+e . Places cursor at the end of the command at shell. Ctrl+d . Kills the shell. Ctrl+z . Places the currently running process into background.
- Display the files in the directory by file size ? - ls .ltr | sort .nr .k 5
- How to save man pages to a file ? - man <command> | col .b > <output-file>Example : man top | col .b > top_help.txt
- How to know the date & time for . when script is executed ? - Add
the following script line in shell script.eval echo "Script is executed
at `date`" >> timeinfo.infHere, .timeinfo.inf. contains date
& time details ie., when script is executed and history related to
execution. - How do you find out drive statistics ? - iostat -E
- Display disk usage in Kilobytes ? - du -k
- Display top ten largest files/directories ? - du -sk * | sort -nr | head
- How much space is used for users in kilobytes ? - quot -af
- How to create null file ? - cat /dev/null > filename1
- Access common commands quicker ? - ps -ef | grep -i $@
- Display the page size of memory ? - pagesize -a
- Display Ethernet Address arp table ? - arp -a
- Display the no.of active established connections to localhost ? - netstat -a | grep EST
- Display the state of interfaces used for TCP/IP traffice ? - netstat -i
- Display the parent/child tree of a process ? - ptree <pid> Example: ptree 1267
- Show the working directory of a process ? - pwdx <pid> Example: pwdx 1267
- Display the processes current open files ? - pfiles <pid> Example: pfiles 1267
- Display the inter-process communication facility status ? - ipcs
- Display the top most process utilizing most CPU ? - top .b 1
- Alternative for top command ? - prstat -a
Powered by ScribeFire.
0 comments:
Post a Comment