Linux/Unix interviews Questions
________________________________________
These are questions 4 both of linux and Unix by which you can use to prepare your Linux or Unix job as a technicial or as engineer or as an administartor, there are some about programming. some of these questions were from ubinto forum...hope this will help people here..... some of these questions are answered ....be free for any comment or any help.

Linux network administrator questions

-Give an example of set of shell commands that will give you the number of files in a directory
-How do you tell what process has a TCP port open in Linux
-On a Red Hat Linux Variant how do you control whether a service starts when the system boots
-How do you tell the amount of free disk space left on a volume
-Give an example of a set of shell commands to tell how many times ”bob” has logged on to the system this month
-Give an example of a recursively copying a directory from one location to another.
-How do you modify the IP and Net mask of a system running a Red Hat Variant of Linux

-Give an example of a set of shell commands that will give you the number of ”httpd” processes running on a Linux box.
-On CentOS or Fedora based system using the package management application, how do you tell what package provided the file ”libnss_ldap.so”
-What is the difference between VTP client, server, and transparent
-What is the maximum length of CAT6
-How does one set up a layer two link to share VLANs
-How does one implement redundant links at Layer 2
-What is the difference between a hub, switch, and a router? What are the security advantages of switch vs. hub?
-Show an example of using telnet to learn the headers of an http server.
-In what OSI layer does PPP exist
-What’s the difference between TCP and UDP
-Given a DNS server that has just started (with an empty cache) and host contacting this DNS server (using it’s OS setting) to learn an address for google.com, list the steps the DNS server will take to learn it with IP addresses (each step will have multiple possible IP addresses – you need choose only one per step).
-Why are layer 2 loops bad, and what protocol was designed to prevent them
-Given a radius server at 10.0.0.2 and a shared key of ‘abc123′ show the IOS commands necessary to authenticate switch users against the radius server, while still allowing the use of local username / password pairs



Linux command line Q&A


-You need to see the last fifteen lines of the files dog, cat and horse. What command should you use?
tail -15 dog cat horse
The tail utility displays the end of a file. The -15 tells tail to display the last fifteen lines of each specified file.
-Who owns the data dictionary?
The SYS user owns the data dictionary. The SYS and SYSTEM users are created when the database is created.

-You routinely compress old log files. You now need to examine a log from two months ago. In order to view its contents without first having to decompress it, use the _________ utility.
zcat
The zcat utility allows you to examine the contents of a compressed file much the same way that cat displays a file.
-You suspect that you have two commands with the same name as the command is not producing the expected results. What command can you use to determine the location of the command being run?
which
The which command searches your path until it finds a command that matches the command you are looking for and displays its full path.
-You locate a command in the /bin directory but do not know what it does. What command can you use to determine its purpose.
whatis
The whatis command displays a summary line from the man page for the specified command.
-You wish to create a link to the /data directory in bob’s home directory so you issue the command ln /data /home/bob/datalink but the command fails. What option should you use in this command line to be successful.
Use the -F option
In order to create a link to a directory you must use the -F option.
-When you issue the command ls -l, the first character of the resulting display represents the file’s ___________.
type
The first character of the permission block designates the type of file that is being displayed.
-What utility can you use to show a dynamic listing of running processes? __________
top
The top utility shows a listing of all running processes that is dynamically updated.
-Where is standard output usually directed?
to the screen or display
By default, your shell directs standard output to your screen or display.
-You wish to restore the file memo.ben which was backed up in the tarfile MyBackup.tar. What command should you type?
tar xf MyBackup.tar memo.ben
This command uses the x switch to extract a file. Here the file memo.ben will be restored from the tarfile MyBackup.tar.
-You need to view the contents of the tarfile called MyBackup.tar. What command would you use?
tar tf MyBackup.tar
The t switch tells tar to display the contents and the f modifier specifies which file to examine.
-You want to create a compressed backup of the users’ home directories. What utility should you use?
tar
You can use the z modifier with tar to compress your archive at the same time as creating it.
-What daemon is responsible for tracking events on your system?
syslogd
The syslogd daemon is responsible for tracking system information and saving it to specified log files.
-You have a file called phonenos that is almost 4,000 lines long. What text filter can you use to split it into four pieces each 1,000 lines long?
split
The split text filter will divide files into equally sized pieces. The default length of each piece is 1,000 lines.
-You would like to temporarily change your command line editor to be vi. What command should you type to change it?
set -o vi
The set command is used to assign environment variables. In this case, you are instructing your shell to assign vi as your command line editor. However, once you log off and log back in you will return to the previously defined command line editor.
-What account is created when you install Linux?
root
Whenever you install Linux, only one user account is created. This is the superuser account also known as root.
-What command should you use to check the number of files and disk space used and each user’s defined quotas?
repquota
The repquota command is used to get a report on the status of the quotas you have set including the amount of allocated space and amount of used space.


Unix admin questions


-How do you list the files in an UNIX directory while also showing hidden files?
-How do you execute a UNIX command in the background?
-What UNIX command will control the default file permissions when files are created?
-Explain the read, write, and execute permissions on a UNIX directory.
-What is the difference between a soft link and a hard link?
-Give the command to display space usage on the UNIX file system.
-Explain iostat, vmstat and netstat.
-How would you change all occurrences of a value using VI?
-Give two UNIX kernel parameters that effect an Oracle install
-Briefly, how do you install Oracle software on UNIX.


Linux application programming questions


-Explain the difference between a static library and a dynamic library? - Static library is linked into the executable, while a dynamic library (or shared object) is loaded while the executable has started.
-How do you create a static library? - If you have a collection of object (.o) files, you can do it by running ar command. Generally a static library has a .a extension, and you can link it into an executable by providing -l libraryname to gcc.
-Where should the developed libraries be installed on the system? - GNU recommends /usr/local/bin for binaries and /usr/local/lib for libraries.
-What’s LD_LIBRARY_PATH? - It’s an environment variable that lists all the directories which should be searches for libraries before the standard directories are searched.
-How do you create a shared library? - Create the object file with -fPIC for position-independent code, then run gcc with -shared option.
-How do you install a shared library? - Run ldconfig in the standard directory that it’s installed in.
-What does ldd do? - It shows a list of installed shared libraries.
-How do you dynamically load a library in your app? - Use dlopen()
-What does nm command do? - It reports the list of symbols in a given library.


Apache interview questions



-On a fresh install, why does Apache have three config files - srm.conf, access.conf and httpd.conf? - The first two are remnants from the NCSA times, and generally you should be ok if you delete the first two, and stick with httpd.conf.
-What’s the command to stop Apache? - kill the specific process that httpd is running under, or killall httpd. If you have apachectl installed, use apachectl stop.
-What does apachectl graceful do? - It sends a SIGUSR1 for a restart, and starts the apache server if it’s not running.
-How do you check for the httpd.conf consistency and any errors in it? - apachectl configtest

-When I do ps -aux, why do I have one copy of httpd running as root and the rest as nouser? - You need to be a root to attach yourself to any Unix port below 1024, and we need 80.
-But I thought that running apache as a root is a security risk? - That one root process opens port 80, but never listens to it, so no user will actually enter the site with root rights. If you kill the root process, you will see the other kids disappear as well.
-Why do I get the message "… no listening sockets available, shutting down"? - In Apache 2 you need to have a listen directive. Just put Listen 80 in httpd.conf.
-How do you set up a virtual host in Apache?

ServerAdmin admin@techinterviews.com
DocumentRoot /home/apache/share/htdocs/hostedsites
ServerName www.techinterviews.com
ErrorLog /home/apache/logs/error/hostedsites/error_log
TransferLog /home/apache/logs/access/hostedsites/access_log

-What is ServerType directive? - It defines whether Apache should spawn itself as a child process (standalone) or keep everything in a single process (inetd). Keeping it inetd conserves resources. This is deprecated, however.
-What is mod_vhost_alias? - It allows hosting multiple sites on the same server via simpler configurations.
-What does htpasswd do? - It creates a new user in a specified group, and asks to specify a password for that user.
If you specify both deny from all and allow from all, what will be the default action of Apache? - In case of ambiguity deny always takes precedence over allow.


Topics for a Unix sysadmin interview



-Job Scheduling; mainly crontab, at, batch command
Backup stetegy; incremental, full system back up; diff between tar & ufsdump
-diff between hard link & softlink
-How to list only the directories inside a directory (Ans. ls -l|grep "^d")
-RAID levels; pros & cons of diffrent levels; what is RAID 1+0

-How to recover a system whose root password has lost?
-What is a daemon?
-How to put a job in background & bring it to foreground?
-What is default permissions for others in a file?
-Questions on shell initialization scripts?
-Questions on restricted shell
-What is diff betwn grep & find?
-What is egrep?
-Questions on shell programming
-What is a pipe?
-Questions on Solaris patch management like pkgadd etc
-Questions on file system creation; actually what happens when we create a file system?
-Questions on RBAC? what is a role accound & what is a profile?
-From command line how will you add a user account? the full command will all arguments.
-Fs it advisable to put a swap partion in RAID1 (mirroring?) pros & cons?



General UNIX interview questions



-What are the main differences between Apache 1.x and 2.x?
-What does the ”route” command do?
-What are the read/write/execute bits on a directory mean?
-What does iostat do?

-what does vmstat do?
-What does netstat do?
-What is the most graceful way to bring a system into single user mode?
-How do you determine disk usage?
-What is AWK?
-What is SED?
-What is the difference between binaries in /bin, and /usr/bin?
-What is a dynamically linked file?
-What is a statically linked file?



Linux admin interview questions



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



Linux admin interview questions



-How do you list the files in an UNIX directory while also showing hidden files? ls -ltra

-How do you execute a UNIX command in the background? Use the ”&”.
-What UNIX command will control the default file permissions when files are created? umask
-Explain the read, write, and execute permissions on a UNIX directory. Read allows you to see and list the directory contents. Write allows you to create, edit and delete files and subdirectories in the directory. Execute gives you the permissions to run programs or shells from the directory.
-What is the difference between a soft link and a hard link? A symbolic (soft) linked file and the targeted file can be located on the same or different file system while for a hard link they must be located on the same file system.
-Give the command to display space usage on the UNIX file system. df -lk
-Explain iostat, vmstat and netstat. iostat reports on terminal, disk and tape I/O activity. vmstat reports on virtual memory statistics for processes, disk, tape and CPU activity. netstat reports on the contents of network data structures.
-How would you change all occurrences of a value using VI? %s/(old value)/(new value)/g
-Give two UNIX kernel parameters that effect an Oracle install. SHMMAX & SHMMNI
-Briefly, how do you install Oracle software on UNIX? Basically, set up disks, kernel parameters, and run orainst.



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.


Hope this will help people here..for any comment or any help be free


This entry was posted on 7:49 AM and is filed under . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

1 comments:

    padmini said...

    Nice and good article.It will helpful for interview perspective.I have suggested to my friends to go through this blog. Thanks for sharing this useful information. If you want to learn Linux course in online, please visit below site.
    Linux online Training
    Linux online course
    Linux Online Training in Hyderabad
    Linux Online Training in Bangalore
    Linux Online Training in Chennai

  1. ... on September 28, 2018 at 4:12 AM