0% found this document useful (0 votes)
501 views89 pages

Linux

This document summarizes the key differences between Samba and NFS. Samba uses the SMB protocol, which is commonly supported on Windows systems, while NFS uses its own protocol. Samba handles authentication at the server level, while NFS by default trusts all clients. SMB does not support UNIX file permissions directly, making it better suited for Windows clients accessing UNIX files than vice versa. NFS supports standard UNIX file attributes.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
501 views89 pages

Linux

This document summarizes the key differences between Samba and NFS. Samba uses the SMB protocol, which is commonly supported on Windows systems, while NFS uses its own protocol. Samba handles authentication at the server level, while NFS by default trusts all clients. SMB does not support UNIX file permissions directly, making it better suited for Windows clients accessing UNIX files than vice versa. NFS supports standard UNIX file attributes.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 89

The difference between Samba and NFS is primarily that Samba uses the SMB (aka Lanmanager) protocol

which is considered "standard" for PCs (Windows and OS/2 both have built in support for it, a free client is also available for DOS, I'm not sure about MacOS), whereas NFS uses its own protocol (usually just called "NFS") which is not commonly available for PCs (NFS clients do exist for operating systems other than UNIX/Linux, but they're usually neither free or easy to setup). Samba's SMB protocol allows the server machine to handle authentication, so it can decide what files the client has access to based on the particular machine and user connecting. NFS by default trusts all client machines completely (it's really not intended to share files to unsecured workstations) and lets the client machines handle authentication all on their own (once an NFS server has been told to accept connections from a client machine the client does not require any further server-side authentication, and can do anything it wants with the filesystem NFS gives it access to). SMB does not (directly) support UNIX style file permissions, so it is probably a bad idea to routinely use it to map filesystems between machines which expect this information to be present and mutable, NFS of course supports all standard UNIX file information (this also means that SMB is fine for accessing a UNIX filesystem from a Windows machine,

but not so hot the other way around). Network File System (also known as NFS) is a protocol developed by Sun Microsystems. It allows a user on a computer to access files that are sent across a network similar to the way one accesses local storage. It is most common in systems with a similar composition to the UNIX system Samba is a re-implementation of SMB/CIFS networking protocol (meaning a re-imaging of Server Message Block or Common Internet File System). As with the NFS, Samba runs most naturally on a system with qualities not unlike those of the UNIX systems. It comes standard with almost every distribution of Linux, and is used as a basic system service on all other UNIX-based systems. a. NFS is a protocol that allows a user to access files over a network; Samba is essentially a re-imaging of the Common Internet File System. b. NFS has four versions, the newest of which includes a stateful protocol; Samba has multiple versions, the latest of which allows file and print sharing between multiple computers.
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. In order to run fsck on the root partition, the root partition must be mounted as readonly You cannot run fsck on a partition that is mounted as read-write. In order to improve your system's security you decide to implement shadow passwords. What command should you use? pwconv The pwconv command creates the file /etc/shadow and changes all passwords to 'x' in the /etc/passwd file. Bob Armstrong, who has a username of boba, calls to tell you he forgot his password. What command should you use to reset his command? passwd boba The passwd command is used to change your password. If you do not specify a username, your password will be changed.

The top utility can be used to change the priority of a running process? Another utility that can also be used to change priority is ___________? nice Both the top and nice utilities provide the capability to change the priority of a running process. What command should you type to see all the files with an extension of 'mem' listed in reverse alphabetical order in the /home/ben/memos directory. ls -r /home/ben/memos/*.mem The -c option used with ls results in the files being listed in chronological order. You can use wildcards with the ls command to specify a pattern of filenames. What file defines the levels of messages written to system log files? kernel.h To determine the various levels of messages that are defined on your system, examine the kernel.h file. What command is used to remove the password assigned to a group? gpasswd -r The gpasswd command is used to change the password assigned to a group. Use the -r option to remove the password from the group. What command would you type to use the cpio to create a backup called backup.cpio of all the users' home directories? find /home | cpio -o > backup.cpio The find command is used to create a list of the files and directories contained in home. This list is then piped to the cpio utility as a list of files to include and the output is saved to a file called backup.cpio. What can you type at a command line to determine which shell you are using? echo $SHELL The name and path to the shell you are using is saved to the SHELL environment variable. You can then use the echo command to print out the value of any variable by preceding the variable's name with $. Therefore, typing echo $SHELL will display the name of your shell. What type of local file server can you use to provide the distribution installation materials to the new machine during a network installation? A) Inetd B) FSSTND C) DNS D) NNTP E) NFS E - You can use an NFS server to provide the distribution installation materials to the machine on which you are performing the installation. Answers a, b, c, and d are all valid items but none of them are file servers. Inetd is the superdaemon which controls all intermittently used network services. The FSSTND is the Linux File System Standard. DNS provides domain name resolution, and NNTP is the transfer protocol for usenet news. If you type the command cat dog & > cat what would you see on your display? Choose one:

a. Any error messages only. b. The contents of the file dog. c. The contents of the file dog and any error messages. d. Nothing as all output is saved to the file cat. d When you use & > for redirection, it redirects both the standard output and standard error. The output would be saved to the file cat. You are covering for another system administrator and one of the users asks you to restore a file for him. You locate the correct tarfile by checking the backup log but do not know how the directory structure was stored. What command can you use to determine this? Choose one: a. tar fx tarfile dirname b. tar tvf tarfile filename c. tar ctf tarfile d. tar tvf tarfile d The t switch will list the files contained in the tarfile. Using the v modifier will display the stored directory structure. You have the /var directory on its own partition. You have run out of space. What should you do? Choose one: a. Reconfigure your system to not write to the log files. b. Use fips to enlarge the partition. c. Delete all the log files. d. Delete the partition and recreate it with a larger size. d The only way to enlarge a partition is to delete it and recreate it. You will then have to restore the necessary files from backup. You have a new application on a CD-ROM that you wish to install. What should your first step be? Choose one: a. Read the installation instructions on the CD-ROM. b. Use the mount command to mount your CD-ROM as read-write. c. Use the umount command to access your CD-ROM. d. Use the mount command to mount your CD-ROM as read-only. d Before you can read any of the files contained on the CD-ROM, you must first mount the CD-ROM. When you create a new partition, you need to designate its size by defining the starting and ending _____________. cylinders

When creating a new partition you must first specify its starting cylinder. You can then either specify its size or the ending cylinder. There are seven fields in the /etc/passwd file. Which of the following lists all the fields in the correct order? Choose one: a. username, UID, GID, home directory, command, comment b. username, UID, GID, comment, home directory, command c. UID, username, GID, home directory, comment, command d. username, UID, group name, GID, home directory, comment Answer: b The seven fields required for each line in the /etc/passwd file are username, UID, GID, comment, home directory, command. Each of these fields must be separated by a colon even if they are empty. Which of the following commands will show a list of the files in your home directory including hidden files and the contents of all subdirectories? Choose one: a. ls -c home b. ls -aR /home/username c. ls -aF /home/username d. ls -l /home/username Answer: b The ls command is used to display a listing of files. The -a option will cause hidden files to be displayed as well. The -R option causes ls to recurse down the directory tree. All of this starts at your home directory. In order to prevent a user from logging in, you can add a(n) ________at the beginning of the password field. Answer: asterick If you add an asterick at the beginning of the password field in the /etc/passwd file, that user will not be able to log in. You have a directory called /home/ben/memos and want to move it to /home/bob/memos so you issue the command mv /home/ben/memos /home/bob. What is the results of this action? Choose one: a. The files contained in /home/ben/memos are moved to the directory /home/bob/memos/memos. b. The files contained in /home/ben/memos are moved to the directory /home/bob/memos. c. The files contained in /home/ben/memos are moved to the directory /home/bob/. d. The command fails since a directory called memos already exists in the target directory. Answer: a When using the mv command to move a directory, if a directory of the same name exists then a subdirectory is created for the files to be moved. Which of the following tasks is not necessary when creating a new user by editing the /etc/passwd file? Choose one: a. Create a link from the user's home directory to the shell the user will use.

b. Create the user's home directory c. Use the passwd command to assign a password to the account. d. Add the user to the specified group. Answer: a There is no need to link the user's home directory to the shell command. Rather, the specified shell must be present on your system. You issue the following command useradd -m bobm But the user cannot logon. What is the problem? Choose one: a. You need to assign a password to bobm's account using the passwd command. b. You need to create bobm's home directory and set the appropriate permissions. c. You need to edit the /etc/passwd file and assign a shell for bobm's account. d. The username must be at least five characters long. Answer: a The useradd command does not assign a password to newly created accounts. You will still need to use the passwd command to assign a password. You wish to print the file vacations with 60 lines to a page. Which of the following commands will accomplish this? Choose one: a. pr -l60 vacations | lpr b. pr -f vacations | lpr c. pr -m vacations | lpr d. pr -l vacations | lpr Answer: a The default page length when using pr is 66 lines. The -l option is used to specify a different length. Which file defines all users on your system? Choose one: a. /etc/passwd b. /etc/users c. /etc/password d. /etc/user.conf Answer: a The /etc/passwd file contains all the information on users who may log into your system. If a user account is not contained in this file, then the user cannot log in. Which two commands can you use to delete directories? A) rm B) rm -rf C) rmdir D) rd E) rd -rf Answer(s): B, C - You can use rmdir or rm -rf to delete a directory. Answer a is incorrect, because the rm command without any specific flags will not delete a directory, it will only delete files. Answers d and e point to a non-existent command. Which partitioning tool is available in all distributions? A) Disk Druid

B) fdisk C) Partition Magic D) FAT32 E) System Commander Answer(s): B - The fdisk partitioning tool is available in all Linux distributions. Answers a, c, and e all handle partitioning, but do not come with all distributions. Disk Druid is made by Red Hat and used in its distribution along with some derivatives. Partition Magic and System Commander are tools made by third-party companies. Answer d is not a tool, but a file system type. Specifically, FAT32 is the file system type used in Windows 98. Which partitions might you create on the mail server's hard drive(s) other than the root, swap, and boot partitions? [Choose all correct answers] A) /var/spool B) /tmp C) /proc D) /bin E) /home Answer(s): A, B, E - Separating /var/spool onto its own partition helps to ensure that if something goes wrong with the mail server or spool, the output cannot overrun the file system. Putting /tmp on its own partition prevents either software or user items in the /tmp directory from overrunning the file system. Placing /home off on its own is mostly useful for system re-installs or upgrades, allowing you to not have to wipe the /home hierarchy along with other areas. Answers c and d are not possible, as the /proc portion of the file system is virtual-held in RAM-not placed on the hard drives, and the /bin hierarchy is necessary for basic system functionality and, therefore, not one that you can place on a different partition. When planning your backup strategy you need to consider how often you will perform a backup, how much time the backup takes and what media you will use. What other factor must you consider when planning your backup strategy? _________ what to backup Choosing which files to backup is the first step in planning your backup strategy. What utility can you use to automate rotation of logs? Answer: logrotate The logrotate command can be used to automate the rotation of various logs. In order to display the last five commands you have entered using the history command, you would type ___________ . Answer: history 5 The history command displays the commands you have previously entered. By passing it an argument of 5, only the last five commands will be displayed. What command can you use to review boot messages? Answer: dmesg The dmesg command displays the system messages contained in the kernel ring buffer. By using this command immediately after booting your computer, you will see the boot messages. What is the minimum number of partitions you need to install Linux? Answer: 2

Linux can be installed on two partitions, one as / which will contain all files and a swap partition. What is the name and path of the main system log? Answer: /var/log/messages By default, the main system log is /var/log/messages. Of the following technologies, which is considered a client-side script? A) JavaScript B) Java C) ASP D) C++ Answer: A - JavaScript is the only client-side script listed. Java and C++ are complete programming languages. Active Server Pages are parsed on the server with the results being sent to the client in HTML * To display a list of all manual pages containing the keyword "date", what command would you type? * What command will display the first several lines of a file called "junk"? == Users and permissions practicum == * Rig it so everything in the folder gets deleted tonight at 10pm. Every night at 10pm. == Local security == * How do you feel about `sudo`? * What's the difference between `telnet` and `ssh`? What's a good use for each? * How do you ensure your users have hard-to-guess passwords? == Filesystem == * What is the difference between a symbolic and hard link? When would you use each? * I have a file named `-fr`. How do I get rid of it? * Why did I just ask that question? * To partition or not? How? * What are RAID 0, 1, 5, 0+1? What level would you use for a web server and why? A database server? == `/etc` == * `ls -l /etc`. What is all this stuff? * You added a line to `/etc/aliases`, but it doesn't seem to be working. Why? * You've created a `zope` user to run Zope under. How do you secure it so someone doesn't guess its password, log in with it, and mess with stuff? * Bring up `/etc/passwd`. What is all this junk? * What are shadow passwords? == Processes == * How many processes are running on your machine right now? == Shells == * Name as many shells as you can. * What's your favorite shell? Why? * Write a shell script to append "snork" to the file "test" but only if "test" already exists. * A user performed a `cd; chmod 644 .` before logging out. What problem occurs when he logs in the next time, and what level of privilege is required to correct the problem? == Startup == * Describe the boot process of your favorite Linux in as much detail as you can. * What are runlevels? == Social ==

* Describe an experience you had with a difficult user. * How do you keep up with current tools and practices? * How did you document your work at your last job so someone else could pick up where you left off? == Totally miscellaneous == * When debugging a core in gdb, what does the command `bt` give: core memory, heap usage, or calling stack? * A user complains the web site is slow. What do you do? == Apache == * How do you rig Apache to start up on boot? * Apache doesn't start up on boot, and the thing above checks out okay. How do you track down the problem? *To display a list of all manual pages containing the keyword "date", what command would you type? Code:
man -k date man -f date

Linux / UNIX: Getting help with man page * What command will display the first several lines of a file called "junk"? Code:
head junk man head

== Users and permissions practicum == * Rig it so everything in the folder gets deleted tonight at 10pm. Every night at 10pm. Set cronjob, see How do I add jobs to cron under Linux or UNIX oses? == Local security == * How do you feel about `sudo`? sudo allows a permitted user to execute a command as the superuser or another user. sudo is much better than su and you don't have to share root password with other users/admin. Linux sudo Configuration * What's the difference between `telnet` and `ssh`? What's a good use for each? TELNET, by default, does not encrypt any data sent over the connection (including password, and so it is often practical to eavesdrop on the communications and use the password later for malicious purposes; SSH by default encrypt password and traffic. SSH is recommended for all use. * How do you ensure your users have hard-to-guess passwords? Set password policy, see Howto: Protect account against a password cracking attack Linux check passwords against a dictionary attack Linux Password Cracking: Explain unshadow and john commands ( john the ripper tool )

== Filesystem == * What is the difference between a symbolic and hard link? When would you use each? How to: Linux / UNIX create soft link with ln command Understanding UNIX / Linux symbolic (soft) and hard links * I have a file named `-fr`. How do I get rid of it? Code:
rm -- -fr rm \-rf

How to: Linux / UNIX Delete or Remove Files With Inode Number * Why did I just ask that question? For testing UNIX concepts and command line args. * To partition or not? How? Sure. See The importance of Linux partitions * What are RAID 0, 1, 5, 0+1? What level would you use for a web server and why? A database server? See level @ What are the different RAID levels for Linux / UNIX and Windows Server? More about RAID - Can RAID Act As The Reliable BACKUP Solution For Linux / UNIX / Windows Server? Linux Check The Health of Adaptec RAID array == `/etc` == * `ls -l /etc`. What is all this stuff? See, Linux / UNIX - Display the permissions of a file * You added a line to `/etc/aliases`, but it doesn't seem to be working. Why? Restart sendmail so that file get updated. The program "newaliases" must be run after this file is updated for any changes to show through to sendmail / postfix. Code:
newaliases

* You've created a `zope` user to run Zope under. How do you secure it so someone doesn't guess its password, log in with it, and mess with stuff? Deny login access to zope and set shell to /sbin/nologin. There are other ways too... * Bring up `/etc/passwd`. What is all this junk? See, Understanding /etc/passwd file format * What are shadow passwords? /etc/shadow file stores actual password in encrypted format for user's account with additional properties related to user password Understanding /etc/ shadow file

== Processes == * How many processes are running on your machine right now? Code:
top atop ps -e ps aux ps aux | wc -l man ps

== Shells == * Name as many shells as you can. Bourne shell (sh) Almquist shell (ash) Debian Almquist shell (dash) Bourne-Again shell (bash) Friendly interactive shell (fish) Korn shell (ksh) C shell (csh) TENEX C shell (tcsh) Es shell (e esh (Unix) Easy Shell rc shell (rc) - shell for Plan 9 and Unix runscript The initial shell interpreter used to process startup scripts in Gentoo scsh (Scheme Shell) Stand-alone Shell (sash) Z shell (zsh) * What's your favorite shell? Why? bash - it rocks and feature rich. * Write a shell script to append "snork" to the file "test" but only if "test" already exists. Code:
[ -f test ] && echo "snork" >> test ||:

* A user performed a `cd; chmod 644 .` before logging out. What problem occurs when he logs in the next time, and what level of privilege is required to correct the problem? User will not able to login. A root user can this problem by resting permission cmod perm /home/user . is current directory .. parent directory == Startup == * Describe the boot process of your favorite Linux in as much detail as you can. See redhat or any other distro doc * What are runlevels? The term runlevel refers to a mode of operation in one of the computer operating systems that implement Unix System V-style initialization. Conventionally, seven runlevels exist, numbered from zero to six, though up to ten, from zero to nine, may be used.

Code:
man init man runlevel

== Social == * Describe an experience you had with a difficult user. * How do you keep up with current tools and practices? * How did you document your work at your last job so someone else could pick up where you left off? Use our social skillz == Totally miscellaneous == * When debugging a core in gdb, what does the command `bt` give: core memory, heap usage, or calling stack? Code:
man gdb Read gdb page

* A user complains the web site is slow. What do you do? Ask user to upgrade internet connection. If using windows ask to reboot windows .. LOL just kidding, google for slow apache problem. There could be zillions of causes == Apache == * How do you rig Apache to start up on boot? Code:
chkconfig httpd on

* Apache doesn't start up on boot, and the thing above checks out okay. How do you track down the problem? Code:
chkconfig httpd on httpd -t service httpd on netstat -tulpn | grep 80 tail -f /var/log/httpd/access_log tail -f /var/log/httpd/error_log

HTH

Share Share this post on


Digg Del.icio.us Technorati

Twitter

__________________ Rocky Jr. What's wrong? I hope I am not making you uncomfortable... Never send a boy to do a mans job. Last edited by nixcraft; 3rd June 2008 at 05:12 PM. Reason: Typo added link to articles

#3 (permalink) 5th June 2008, 02:15 PM Join Date: Jun 2008 OS: Debian Posts: 9 Thanks: 0 Thanked 0 Times in 0 Posts Rep Power: 0

shanthiavari Junior Member

thanks hai thanks for posting answers

Share Share this post on


Digg Del.icio.us Technorati Twitter

#4 (permalink) 26th June 2008, 01:56 PM pansarevai Join Date: Jan 2008 OS: Debian/Redhat

Member

Posts: 39 Thanks: 0 Thanked 0 Times in 0 Posts Rep Power: 0

Hi All, I think this thread is really gud and helpful 4 interview. But we should put some tricky questions here...based on the subject. Every interview is going to be differenet and based on past experience and persent requirement.After getting the question rest u can google and find your answers.Here are some from me. 1. What is the transpernet proxy? 2.Can a squid proxy server is used as DNS, if yes how? 3.Is swap partisition mandetory in any installation, and why it is nessesary to define at the time of installation? 4.can apache be use as proxy server? how? wht is reverse proxy? 5.wht is the ssh version you are using. What are the drawbacks of ssh? What is the defference between ssh version 1 and 2? These are some of the questions...I will update some more as well as dont remember all of them. Also I will try to answer some of them if you need. Thnx and looking 4 some more questions .....

Share Share this post on


Digg Del.icio.us Technorati Twitter

#5 (permalink) 26th June 2008, 05:20 PM

nixcraft Never say die

Join Date: Jan 2005 Location: BIOS OS: RHEL Scripting language: Bash, Perl, Python Posts: 3,963 Thanks: 14 Thanked 608 Times in 430 Posts Rep Power: 10

Quote: Originally Posted by pansarevai 1. What is the transparent proxy? The client / browser does not need to configure a proxy and cannot directly detect that its requests are being proxied via squid or other proxy server. Linux: Setup a transparent proxy with Squid in three easy steps Quote: Originally Posted by pansarevai 2.Can a squid proxy server is used as DNS, if yes how? No, you need to use caching dns or use ISP dns. How To Set Caching DNS Server Quote: Originally Posted by pansarevai 3.Is swap partition mandatory in any installation, and why it is necessary to define at the time of installation? Yes, it is used to improve performance. Most installer force to create swap partition. You can install Linux w/o swap if you have tons of ram. Quote: Originally Posted by pansarevai 4.can Apache be use as proxy server? how? What is reverse proxy? A reverse proxy is a proxy server that is installed in the neighborhood of one or more web servers. All traffic coming from the Internet and with a destination of one of the web servers goes through the proxy server. Apache has mod_proxy for proxy support. Quote: Originally Posted by pansarevai 5.What is the ssh version you are using. What are the drawbacks of ssh? No drawbacks,

Code:
sshd -v

What are setuid/setgid in relation to file permissions? What are setuid/setgid in relation to directory permissions? What is an inode? What does init do? What does inetd do? Whats PGP/GPG; Public/Private Key cryptographic systems Whats ssh? Setting up trust between accounts. How does ssl work? What are different directories in / for? What to do , if the newly build kernel does not boot.? Do you know what source management is? have you used it? what software? How does the boot process (init levels) work on Linux What do you know about configuring and/or compiling Apache; Virtual Hosts? .htaccess files? mod_perl? mod_php? log files and log management What shell do you use? bash? do you know any other? Name some basic shell command like cut and explain what they do Sed/awk? Which editor? vim/emacs/something else How to check all open ports on linux machine and block unsed ports? netstat -t #nmap -v localhost for tcp #nmap -sU localhost for udp #netstat -tulp or #netstat -tulpn to verfy the open ports ------------------------------* how u use the iptable firewall to restrict ssh,telnet,ftp For SSH iptables -A INPUT -s -p tcp --dport <22> -j REJECT/DROP/DENY For Telnet

iptables -A INPUT -s -p tcp --dport <23> -j REJECT/DROP/DENY For FTP iptables -A INPUT -s -p tcp --dport <21> -j REJECT/DROP/DENY ------------------------------------* what is the difference between unix and linux graphics is the main difference extra more command are in linux userfriendly then unix the unix is the platform dependent the linux is platform independent. we cann't install unix in all machine we recquired a special machine to install unix, but linux is not like that it support all machines filesystem are different there diff lies in kernel linux is under gpl and unix proprietary Difference Between Linux and Unix 1)Linux default shell is /bin/bash, where Unix default shell is /bin/sh (other shell also supported) 2) Linux Store all their command history,but if the default shell is /bin/sh in Unix, then Unix not store Command history. 3) Linux support Tab key, but unix not support Tab key ------------------------------------Who owns the data dictionary? The Oracle user SYS owns all base tables and useraccessible views of the data dictionary. Therefore, no Oracle user should ever alter (update, delete, or insert) any rows or schema objects contained in the SYS schema, because such activity can compromise data integrity. The security administrator should keep strict control of this central account. ------------------------------------which file contains information about os wether it's 32 bit or 64 bit? ANS: /proc/cpuinfo or $uname -m or /usr/bin/file --------------------------------

what contains information about file and directory creating time or modification time? An inode is a data structure on a Unix / Linux file system. An inode stores basic information about a regular file, directory, or other file system object. You can use following two commands to display an inode: [a] ls command : list directory contents ----------------------------------What are RPM?s, what do they offer? The full form of RPM is Redhat Package Manager. rpm is a powerful Package Manager, which can be used to build,install, query, verify, update, and erase individual software packages. A package consists of an archive of files and meta-data used to install and erase the archive files. [b] stat command : display file or file system status eg : # stat /etc/passwd Output: File: `/etc/group' Size: 566 Blocks: 16 IO Block: 4096 regular file Device: fd00h/64768d Inode: 2443679 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2009-08-12 08:23:31.245032672 +0530 Modify: 2002-01-01 05:54:15.000000000 +0530 Change: 2002-01-01 05:54:15.000000000 +0530 -------------------------------------------------*how to confirm from client end about nfs server sharing? with mount and showmount -e server IP ------------------------------------------------How do i check which nfs version I am using ? rpcinfo -p localhost | grep -i nfs This cmd is used for nfs version rpm -qa | grep nfs rpm -qi nfs nfs-utils yum info nfs nfs-utils -----------------------------------------------Through ssh whole directory structure from / is shared regardless the user we have connected with ....... how do i prevent sharing ??

vi /etc/ssh/sshd_config "in last line enter the folowing entry" AllowUsers "username" And vi /etc/hosts.deny "in last line enter the folowing entry" sshd: ALL EXCEPT "DOMAIN-NAME" its benefitial to use setfacl command for secure your stuff.. ------------------------------------------------------* what restrict telnet for root itself but allow for other user Root can login through telnet session, but by default it is disabled. You can enable by appending /etc/securetty file open /etc/securetty using vi #vi /etc/securetty pts/0 pts/1 don't remove anything from this /etc/securetty , just append your entry vi /etc/pam.d/login auth required pam_securetty.so== 1st line should be placed as required.if we change the option as sufficient instead of required telnet can login as "root". ----------------------------------------------------------How to send automated email to a set of people at fixed time ? 1)just create a alias of people and create a command file and create a crond entry 2)configure sendmail & postfix to configure procmail.. Or configure Q-mail / Squirrel mail & use contab ---------------------------------------------------how do i check which package has installed some command suppose ls , mkdir or whatever ??? rpm -qa | grep "pakage name" rpm -qa | grep yum install it will show already installed or not if not then it will install Pirut same as yum rpm -qa /usr/bin/ls gives you from which rpm the "ls" command is installed.

----------------------------------------------------What is the difference between Telnet and SSH? ssh is a secured shell, where telnet is not a secured one.when you ssh to trasnfer data between a system, the data will be send in the encrypted form, where the hacker cannot encode or decode it. While you telnet,the data send between the system is alphabetical format(ASCII), where every one can understand. More over as per network security, telnet and ftp are prohibited. Always, trust SSL based data transfer. Telnet -> Its just getting (Telenet) a connection to the server. Its not more secure. Anybody can use it. It can be easly hacked.It can be easily read by anybody in that network SSH -> secured shocket shell Its more secure than Telnet . This has an encrption and decrption of the data /usr/pwd None can hack this. It is the good way to transfer the data --------------------------------------------------What is the difference between home directory and working directory? home directory is one over which user have complete control and it is its default working directory when its logs in. while the working directory is the users current directory which may or may not be his home directory. -----------------------------------------How can you see all mounted drives? with df -hT command and with the mount command. #vi /etc/fstab contains perminant mounts --------------------------------------------When you install RedHat what is the kernel mode ? What is kernel compilation / upgrade ? Kernel mode, also referred to as system mode, is one of the two distinct modes of operation of the CPU in Linux. The other is user mode, a non-privileged mode for user programs, that is, for everything other than the kernel. When the CPU is in kernel mode, it is assumed to be executing trusted software, and thus it can execute any instructions and reference any memory addresses. The kernel is trusted software, but all other programs are considered untrusted software. Thus, all user mode software must request use of the kernel by means of a system call in order to perform privileged instructions, such as process creation

or input/output. Kernel compilation is installing a new kernel or adding custom modules to the same kernel. Kernel upgradation is upgrading it to a different version altogether. -----------------------------what is the difference between fork and thread ? and parent and child process in fork system call? fork() system call in UNIX causes creation of a new process the new process (child process) which is an exact copy of the calling process(parent process).return value from fork () is used to distinguish the parent from the child; the parent receives the child's process id, but the child receives zero. A thread is a stream of instructions that can be scheduled as an independent unit. A thread is a stream of instructions that can be scheduled as an independent unit. It is important to understand the difference between a thread and a process. A process contains two kinds of information: resources that are available to the entire process such as program instructions, global data and working directory, and schedulable entities, which include program counters and stacks. A thread is an entity within a process that consists of the schedulable part of the process. A fork() duplicates all the threads of a process. The problem with this is that fork() in a process where threads work with external resources may corrupt those resources (e.g., writing duplicate records to a file) because neither thread may know that the fork() has occurred. When a new perl thread is created, all the data associated with the current thread is copied to the new thread, and is subsequently private to that new thread! This is similar in feel to what happens when a UNIX process forks, except that in this case, the data is just copied to a different part of memory within the same process rather than a real fork taking place. A fork() induces a parent-child relationship between two processes. Thread creation induces a peer relationship between all the threads of a process. -------------------------------------------------------You want to create a compressed backup of the users' home directories. What utility should you use? Tar -czf kk.tar.gz /home/username If we want to extract

the the command is tar -xzf kk.tar.gz -------------------------------------------------------What is the difference between an argument and an option/switch? A linux/unix syntax format is as follows command option arguement example: ls -a /boot here ls command, -a is option,/boot is arguement option specifies the command how to run arguement specifies the command on what to run --------------------------------------------------------How does the boot process[init levels] work on Linux? How is it different from Solaris? When an x86 computer is booted, the processor looks at the end of the system memory for the BIOS (Basic Input/Output System) and runs it. The BIOS program is written into permanent read-only memory and is always available for use. The BIOS provides the lowest level interface to peripheral devices and controls the first step of the boot process. The BIOS tests the system, looks for and checks peripherals, and then looks for a drive to use to boot the system. Usually it checks the floppy drive (or CD-ROM drive on many newer systems) for bootable media, if present, and then it looks to the hard drive. The order of the drives used for booting is usually controlled by a particular BIOS setting on the system. Once Linux is installed on the hard drive of a system, the BIOS looks for a Master Boot Record (MBR) starting at the first sector on the first hard drive, loads its contents into memory, then passes control to it. This MBR contains instructions on how to load the GRUB (or LILO) boot-loader, using a pre-selected operating system. The MBR then loads the boot-loader, which takes over the process (if the boot-loader is installed in the MBR). In the default Red Hat Linux configuration, GRUB uses the settings in the MBR to display boot options in a menu. Once GRUB has received the correct instructions for the operating system to start, either from its command line or configuration file, it finds the necessary boot file and hands off control of the machine to that operating system. 1. The system BIOS checks the system and launches the first stage boot loader on the MBR of the primary hard disk. 2. The Frist stage boot loader loads itself into memory and launches the second stage boot loader from the /boot/ partition.

3. The second stage boot loader loads the kernel into memory, which in turn loads any necessary modules and mounts the root partition read-only. 4. The kernel transfers control of the boot process to the / sbin/init program. 5. The /sbin/init program loads all services and user-space tools, and mounts all partitions listed in /etc/fstab. 6. The user is presented with a login screen for the freshly booted Linux system. ------------------------------------------------------------What are the main differences between RHEL4 & RHEL5? XEN, YUM and improved SELinux all the features updated with better options Better GUI support then RHEL4 YUM over RPM package management IPTables and SELinux for more secure environment ext2 & ext3 file system In RHEL 4 SELinux Block only 13 services, But on RHEL 5 SElinux Block 80 services ------------------------------------------------------What text filter can you use to display a binary file in octal numbers? hexdump file1 > file2 -------------------------------------------------------tell me some of the Linux HotKeys do you know? alt+f1 for application menu ctl+l to clear screen alt+f2 to open run application window alt+f3 for find alt+f4 to close application alt+f9 to minimise window Ctrl-Alt-D Show desktop Crtl-Alt-Backspace Restart XWindows ------------------------------------------------What file should you examine to determine the defined runlevels for your system? /etc/inittab id:X:initdefault where X=runlevel (ex.0 to 6) 0 =system poweroff

1 = single user mode 2 = multiuser mode without network and X window 3 = multiuser mode with network without X window 4 = unused 5 = X11 (multiuser mode with network and X window 6 = reboot -------------------------------------What is the name and path of the main system log? /var/log/messages system log messages can be seen here /var/log/dmesg Kernel boot log messages can view There are Three centralized loggin demons 1)syslogd 2)klogd 3)auditd klogd:- collect log file created by the Kernel syslogd:- Collect log file created by the system auditd:- Collect log file created by the SELinux After collecting the log system store logs on different location /var/log/dmesg:- Created at boot time, by kernel /var/log/messages:- standard system error message, /var/log/secure:- authentication related log /var/log/maillog:- Mail related log /var/log/audit/audit.log:-Selinux related log We can redirect the log by configuring /etc/sysconfig/syslog /etc/syslog.conf ------------------------------------------------what is the difference between semaphore, mutex & spinlock? Kernel Locking Techniques Semaphores in Linux are sleeping locks. Because they cause a task to sleep on contention, instead of spin, they are used in situations where the lock-held time may be long. Conversely, since they have the overhead of putting a task to sleep and subsequently waking it up, they should not be used where the lock-held time is short. Since they sleep, however, they can be used to synchronize user contexts whereas spinlocks cannot. In other words, it is safe to block while holding a semaphore. A "mutex" (or "mutual exclusion lock") is a signal that two or more asynchronous processes can use to reserve a shared resource for exclusive use. The first process that obtains ownership of the "mutex" also obtains ownership of the shared resource. Other processes must wait for for the first process to release it's ownership of the "mutex" before they

may attempt to obtain it. The most common locking primitive in the kernel is the spinlock. The spinlock is a very simple single-holder lock. If a process attempts to acquire a spinlock and it is unavailable, the process will keep trying (spinning) until it can acquire the lock. This simplicity creates a small and fast lock. --------------------------------------------------What are seven fields in the /etc/passwd file. 1. Username: It is used when user logs in. It should be between 1 and 32 characters in length. 2. Password: An x character indicates that encrypted password is stored in /etc/shadow file. 3. User ID (UID): Each user must be assigned a user ID (UID). UID 0 (zero) is reserved for root and UIDs 1-99 are reserved for other predefined accounts. Further UID 100-999 are reserved by system for administrative and system accounts/groups. 4. Group ID (GID): The primary group ID (stored in /etc/group file) 5. User ID Info: The comment field. It allow you to add extra information about the users such as user's full name, phone number etc. This field use by finger command. 6. Home directory: The absolute path to the directory the user will be in when they log in. If this directory does not exists then users directory becomes / 7. Command/shell: The absolute path of a command or shell (/bin/bash). Typically, this is a shell. Please note that it does not have to be a shell. -----------------------------------------------------1. Q. How do you list files in a directory? A. ls - list directory contents ls -l (-l use a long listing format) 2. Q. How do you list all files in a directory, including the hidden files? A. ls -a (-a, do not hide entries starting with .) 3. Q. How do you find out all processes that are currently running? A. ps -f (-f does full-format listing.) 4. Q. How do you find out the processes that are currently running or a particular user? A. ps -au Myname (-u by effective user ID (supports names)) (a - all users) 5. Q. How do you kill a process? A. kill -9 8 (process_id 8) or kill -9 %7 (job number 7) kill -9 -1 (Kill all processes you can kill.) killall - kill processes by name most (useful - killall java) 6. Q. What would you use to view contents of the file? A. less filename cat filename pg filename

pr filename more filename most useful is command: tail file_name - you can see the end of the log file. 7. Q. What would you use to edit contents of the file? A. vi screen editor or jedit, nedit or ex line editor 8. Q. What would you use to view contents of a large error log file? A. tail -10 file_name ( last 10 rows) 9. Q. How do you log in to a remote Unix box? A. Using telnet server_name or ssh -l ( ssh - OpenSSH SSH client (remote login program)) 10.Q. How do you get help on a UNIX terminal? A. man command_name info command_name (more information) 11.Q. How do you list contents of a directory including all of its subdirectories, providing full details and sorted by modification time? A. ls -lac -a all entries -c by time 12.Q. How do you create a symbolic link to a file (give some reasons of doing so)? A. ln /../file1 Link_name Links create pointers to the actual files, without duplicating the contents of the files. That is, a link is a way of providing another name to the same file. There are two types of links to a file:Hard link, Symbolic (or soft) link; 13.Q. What is a filesystem? A. Sum of all directories called file system. A file system is the primary means of file storage in UNIX. File systems are made of inodes and superblocks. 14.Q. How do you get its usage (a filesystem)? A. By storing and manipulate files. 15.Q. How do you check the sizes of all users home directories (one command)? A. du -s df The du command summarizes disk usage by directory. It recurses through all subdirectories and shows disk usage by each subdirectory with a final total at the end.
1)what are the steps for Password-less ssh?

open the ssh configration file /etc/ssh/sshd_conf like this #vi /etc/ssh/sshd_conf

Here you can see "Password Auth = yes" dhange it to no i.e., "Password Auth = no" and save and exit. Now restart the service sshd with "Service sshd restart" cmd and try to connect to another machine using its IP .... now it wont ask u for password...
What is the command to change from /etc/passwd file to /etc/shadow file?

The Quesion was clearly mentioned that hw to change from /etc/passwd to /etc/shadow file. It means that the pwd is /etc/passswd. So, then simply type this command at the prompt cd /etc/shadow #pwconv -> It convert /etc/passwd to /etc/shadow #pwunconv -> It convert /etc/shadow to /etc/shadow you can check both file after running pwconv and pwunconv cmd to get difference.

What are the main diff bwn NFS and Samba Servers?

main difference between samba and nfs is By configuring samba we can access file from linux to window and window to linux but by nfs can't
What are the main diff bwn Yum & rpm?

The Yellowdog Updater, Modified (YUM) is an open-source command-line package-management utility for RPM. Originally standing for "Red Hat Package Manager", RPM now stands for "RPM Package Manager" rpm is packagemanager while yum is a frontend,rpm can be installed with the help of yum yum can also trace the dependency while rpm cant .

we have to track the dependency if we install with the help of rpm .


What is the use of DNS Server? Name other servers works same as like DNS?

Ans 1-Dns server it is use for name resolution. It use to map IP to name and name to ip

Ans 2- WINS server works same as dns but it use for local network
What is the command to find the hardware configuration in Linux? How to root mirror in Linux? How to replace mirrored hdd in case of failure? What is the command to check wwn # in linux? how can i give acl permission in numerical mode on linux Explain linux file types

7 types of files

- regular d directory l symbolic link c character special file (hardware files) b block special file (files to communicate with hardware ) p named pipe (to pass data between process ) s socket ( mechanism for inter-process communication
why LINUX is fast processing software and why it does not get viruses. Which file defines all users on your system?

/etc/passwd file contain all users information /etc/passwd 7 clone seprated field root:x:0:0:root:/root:/bin/bash 1.username 2.password 3.UID 4.GID 5.User comman information 6.User home directory 7.Login shell scp- copying files using ssh(secure copy) of the selected files from the source host to destination host and when finished closes the scp application rsync- you need to setup the key authentication between the
wat is the differnces between scp and rsync in linux?

servers that do the synchronization (to destinatio system to have the source public key in destination host's authorized_keys) and copies the files from source to destination whenever there is a change(addition/deletion) in the sounce directory .. can be pull/push/both
What is the main advantage of creating links to a file instead of copies of the file?

The main advantage of creating links to a file because if there is one file and max user want to work on that file at a time by linking they can work on that. There are two type of linking1-Hard link 2-Soft link Hard link is same as copy but its inode no. is same.when u remove the orginal file which u have link then it will not effect in hard link file. Soft link is copy but disadvantage is that when u remove the orginal file then soft link file will not work.
What is the minimum number of partitions you need to install Linux?

three minimum partition need to install the linux. 1:- / 2:- boot 3:- swap
i have installed linux 4 version in my system. after installation can i increase the size of the folder..

Possible for partition size increase but blow mentioned points are available in your PC: First confirm you have free Space or other HDD? While installation you have created the partition like PV-->VG-->LVM Here your question is "increase the size of the folder"? Folder size is increasing upto partition size completed.

Example: /home partition size 2 GB. Here folder size is increasing upto 2GB
In my server squid is configured,and in my client machine i am using proxy (connection settings... proxy server ip) i configured..in server orkut.com is blocked, is it possible to use orkut even when i am using proxy at client side.....

it is not possible if u want to bypass just add u r machine mac add as acl on proxy server or u can change u r clint ip with the direct internet provider ip... by doing this thing u can by pass the proxy server and get access for orkut
How big should the swap-space partition be?

To give your swap memory value you should know the memory in you system.If iam having 1 Gb RAM ,then you have to give double the size that means 1 GB=1024 1024*2=2048 In swap memory you have fill 2048.
what is difference between nfs server version 2,3 and 4?

NFSv4 support kerberos. try openoffice

can we open microsoft word document,power point etc. on linux suse version and vise versa? if no how can we convert this?

Can anybody tell me the step by step how to install raid-5

Hi for creating Raid5, first u need to create a 3 Partitions. Because 3 partitions is required for implementing Raid5. Step1:- Creating partions, so the command is #fdisk /dev/hda or #fdisk /dev/sda where hda = If HDD is IDE, sda = If HDD is SATA. with the help of above command we create 3 partitions. Step2:- To add above 3 partitions for activate RAID5

#mdadm -C /dev/md0 -n 3 -l 5 /dev/sda{10,11,12} or #mdadm -C /dev/md0 -n 3 -l 5 /dev/hda{10,11,12} Where C= for Create 10,11,12 = Partition ID Step3:- Format the raid or Multiple Devices #mkfs.ext3 /dev/md0 Step4:- After formatting craete a Directory where you want mount to above Multiple partitions #mkdir /storage #mount /dev/md0 /storage
is it possible to break the grub password in linux

Yes, it is possible.

1.Go to rescue mode --> then 2. chmod /mnt/sysimage 3 . vim /boot/grub/grub.conf here remove the line called " password --md5 $1$9sdflksdf/sdf44k " 4. sync 5. reboot
Name key files or directories on a unix system that should always be backed up?

Some Servers are used to serve critical applications. So the back up of /etc and /boot directory may cause beneficial results for some unwanted disasters. since /etc directory contains all the configuration files.

List all the files with .mem extension in reverse alphabetical order in a particular directory?

ls -r *.mem
In /etc/fstab, wat is the meaning of 'defaults' word and 0 0 indicates which options?

(0) is used by dump (a backup utility) to decide if a filesystem should be backed up. If zero then dump will ignore that filesystem. The sixth field (0) is used by fsck

(the filesystem check utility) to determine the order in which filesystems should be checked. If zero then fsck won't check the filesystem.
how is FAT32 file system mounted in linux file system?

#mkdir /d #mount -t vfat /dev/hda1 /d /dev/hda1------>drive name


ntroduction of Linux -

Linux is an operating system. An operating system is the basic set of programs and utilities that make your computer run. Some other common operating systems are Unix (and its variants BSD, AIX, Solaris, HP-UX, and others) DOS, Microsoft Windows, Amiga, Google Chrome and Mac OS. Linux is an ideal operating system for power-users and programmers. Linux is a UNIX-based operating system originally developed as for Intel-compatible PC's. Linux is built and supported by a large international community of developers and users dedicated to free, open-source software. This community sees Linux as an alternative to such proprietary systems as Windows and Solaris, and as a platform for alternatives to such proprietary applications as MS Office, Internet Explorer, and Outlook. History of Linux 1969 Summer 1969 Unix was developed. 1969 Linus Torvalds is born. 1971 First edition of Unix released 11/03/1971. In 1991, Linux is introduced by Linus Torvalds, a student in Finland. In Helsinki, Linus Torvalds began a project that later became the Linux kernel. It was initially a terminal emulator, which Torvalds used to access the large UNIX servers of the university. In 2001 Linus Torvalds releases version 2.4 of the Linux Kernel source code on January 4th. The first release of Ubuntu is released October 20, 2004. Configurability Convenience Stability Community Freedom

Why use Linux?

Programming on Linux Linux supports many programming languages like Ada, C, C++, Java, and Fortran. Linux include the Intel C++ Compiler, Sun Studio, and IBM XL. C/C++ Compiler. Most distributions also include support for PHP, Perl, Ruby, Python and other dynamic languages. While not as common, Linux also supports C# (via Mono), Vala, and Scheme. A number of

Java Virtual Machines and development kits run on Linux, including the original Sun Microsystems JVM (HotSpot), and IBM's J2SE RE, as well as many open-source projects like Kaffe. Architecture of Linux-

Advantages of Linux

Linux is free. Linux is portable to any hardware platform. Linux was made to keep on running. Linux is secure and versatile. Linux is scalable. The Linux OS and most Linux applications have very short debug-times.

Disadvantages of Linux

Linux is not very user friendly and confusing for beginners. More technical ability needed. Not all hardware compatible. Shell Scripting Interview Questions 1) What is shell scripting? Shell scripting is used to program command line of an operating system. Shell Scripting is also used to program the shell which is the base for any operating system. Shell scripts often refer to programming UNIX. Shell scripting is mostly used to program operating systems of windows, UNIX, Apple, etc. Also this script is used by companies to develop their own operating system with their own features. 2) State the advantages of Shell scripting? There are many advantages of shell scripting some of them are, one can develop their own operating system with relevant features best suited to their organization than to rely on costly operating systems. Software applications can be designed according to their platform. 3) What are the disadvantages of shell scripting?

There are many disadvantages of shell scripting they are * Design flaws can destroy the entire process and could prove a costly error. * Typing errors during the creation can delete the entire data as well as partition data. * Initially process is slow but can be improved. * Portbility between different operating system is a prime concern as it is very difficult to port scripts etc. 4) Explain about the slow execution speed of shells? Major disadvantage of using shell scripting is slow execution of the scripts. This is because for every command a new process needs to be started. This slow down can be resolved by using pipeline and filter commands. A complex script takes much longer time than a normal script. 5) Give some situations where typing error can destroy a program? There are many situations where typing errors can prove to be a real costly effort. For example a single extra space can convert the functionality of the program from deleting the sub directories to files deletion. cp, cn, cd all resemble the same but their actual functioning is different. Misdirected > can delete your data. Coding Related Shell Scripting Interview Questions ... 6) Explain about return code? Return code is a common feature in shell programming. These return codes indicate whether a particular program or application has succeeded or failed during its process. && can be used in return code to indicate which application needs to be executed first. 7) What are the different variables present in Linux shell? Variables can be defined by the programmer or developer they specify the location of a particular variable in the memory. There are two types of shells they are System variables and user defined variables. System variables are defined by the system and user defined variables are to be defined by the user (small letters). 8) Explain about GUI scripting? Graphical user interface provided the much needed thrust for controlling a computer and its applications. This form of language simplified repetitive actions. Support for different applications mostly depends upon the operating system. These interact with menus, buttons, etc. 9) Explain about echo command? Echo command is used to display the value of a variable. There are many different options give different outputs such as usage \c suppress a trailing line, \r returns a carriage line, -e enables interpretation, \r returns the carriage. 10) Explain about Stdin, Stdout and Stderr? These are known as standard input, output and error. These are categorized as 0, 1 and 2. Each of these functions has a particular role and should accordingly functions for efficient output. Any mismatch among these three could result in a major failure of the shell. 11) Explain about sourcing commands? Sourcing commands help you to execute the scripts within the scripts. For example sh

command makes your program to run as a separate shell. .command makes your program to run within the shell. This is an important command for beginners and for special purposes. 12) Explain about debugging? Shell can make your debugging process easier because it has lots of commands to perform the function. For example sh ncommand helps you to perform debugging. It helps you to read the shell but not to execute it during the course. Similarly sh x command helps you by displaying the arguments and functions as they are executed. 13) Explain about Login shell? Login shell is very useful as it creates an environment which is very useful to create the default parameters. It consists of two files they are profile files and shell rc files. These files initialize the login and non login files. Environment variables are created by Login shell. 14) Explain about non-login shell files? The non login shell files are initialized at the start and they are made to run to set up variables. Parameters and path can be set etc are some important functions. These files can be changed and also your own environment can be set. These functions are present in the root. It runs the profile each time you start the process. 15) Explain about shebang? Shebang is nothing but a # sign followed by an exclamation. This is visible at the top of the script and it is immediately followed by an exclamation. To avoid repetitive work each time developers use shebang. After assigning the shebang work we pass info to the interpreter. 16) Explain about the Exit command? Every program whether on UNIX or Linux should end at a certain point of time and successful completion of a program is denoted by the output 0. If the program gives an output other than 0 it defines that there has been some problem with the execution or termination of the problem. Whenever you are calling other function, exit command gets displayed. 17) Explore about Environment variables? Environment variables are set at the login time and every shell that starts from this shell gets a copy of the variable. When we export the variable it changes from an shell variable to an environment variable and these variables are initiated at the start of the shell. Read more: http://www.placementpapers.us/unix_linux/169shell_scripting_interview_questions.html#ixzz1UmGwbKAk Under Creative Commons License: Attribution Questions BANK 01 # You attempt to use shadow passwords but are unsuccessful. What characteristic of the /etc/passwd file may cause this? Choose one: a. The login command is missing. b. The username is too long. c. The password field is blank. d. The password field is prefaced by an asterick.

# You create a new user account by adding the following line to your /etc/passwd file. bobm:baddog:501:501:Bob Morris:/home/bobm:/bin/bash Bob calls you and tells you that he cannot logon. You verify that he is using the correct username and password. What is the problem? Choose one: a. The UID and GID cannot be identical. b. You cannot have spaces in the line unless they are surrounded with double quotes. c. You cannot directly enter the password; rather you have to use the passwd command to assign a password to the user. d. The username is too short, it must be at least six characters long. # Which of the following tasks is not necessary when creating a new user by editing the /etc/passwd file? Choose one: a. Create a link from the users home directory to the shell the user will use. b. Create the users home directory c. Use the passwd command to assign a password to the account. d. Add the user to the specified group. # You create a new user by adding the following line to the /etc/passwd file bobm::501:501:Bob Morris:/home/bobm:/bin/bash You then create the users home directory and use the passwd command to set his password. However, the user calls you and says that he cannot log on. What is the problem? Choose one: a. The user did not change his password. b. bobm does not have permission to /home/bobm. c. The user did not type his username in all caps. d. You cannot leave the password field blank when creating a new user. # When using useradd to create a new user account, which of the following tasks is not done automatically. Choose one: a. Assign a UID. b. Assign a default shell. c. Create the users home directory. d. Define the users home directory. # You issue the following command useradd -m bobm But the user cannot logon. What is the problem? Choose one: a. You need to assign a password to bobms account using the passwd command. b. You need to create bobms home directory and set the appropriate permissions. c. You need to edit the /etc/passwd file and assign a shell for bobms account. d. The username must be at least five characters long. # You have created special configuration files that you want copied to each users home directories when creating new user accounts. You copy the files to /etc/skel. Which of the following commands will make this happen? Choose one: a. useradd -m username b. useradd -mk username c. useradd -k username d. useradd -Dk username # Mary has recently gotten married and wants to change her username from mstone to mknight. Which of the following commands should you run to accomplish this? Choose one: a. usermod -l mknight mstone b. usermod -l mstone mknight c. usermod -u mknight mstone d. usermod -u mstone mknight

# After bob leaves the company you issue the command userdel bob. Although his entry in the /etc/passwd file has been deleted, his home directory is still there. What command could you have used to make sure that his home directory was also deleted? Choose one: a. userdel -m bob b. userdel -u bob c. userdel -l bob d. userdel -r bob # All groups are defined in the /etc/group file. Each entry contains four fields in the following order. Choose one: a. groupname, password, GID, member list b. GID, groupname, password, member list c. groupname, GID, password, member list d. GID, member list, groupname, password # You need to create a new group called sales with Bob, Mary and Joe as members. Which of the following would accomplish this? Choose one: a. Add the following line to the /etc/group file: sales:44:bob,mary,joe b. Issue the command groupadd sales. c. Issue the command groupadd -a sales bob,mary,joe d. Add the following line to the /etc/group file: sales::44:bob,mary,joe How Does Linux Kernel Versioning Work? What is difference between AT and CRON? Which file defines all users on your system? What account is created when you install Linux? Where Is the Latest Kernel Version on the Internet? Which field is used to define the users default shell? What is the name and path of the main system log? How can u schedule a job using cron for 20 secs? Which partitioning tool is available in all distributions? What utility can you use to automate rotation of logs? What command can you use to review boot messages? Which daemon is used for scheduling of the commands? Which utility is used to make automate rotation of a log? What is difference between user right and user permission? What are the partitions created on the mail server hard drive? How to change window manager by editing your home directory? What daemon is responsible for tracking events on your system? Which daemon is responsible for tracking events on Linux system? What file defines the levels of messages written to system log files? What is the minimum number of partitions you need to install Linux? What text filter can you use to display a binary file in octal numbers? What command is used to remove the password assigned to a group? What file defines the levels of messages written to system log files? What is the minimum number of partitions you need to install Linux? Which password package is installed for the security of central password? What can you type at a command line to determine which shell you are using? Which commands are used to set a processor-intensive job to use less CPU time? What file should you examine to determine the defined run levels for your system? Please describe the main stages of a booting Linux machine (x86) to the login prompt?

You need to see the last fifteen lines of the files dog, cat and horse. What command should you use? What can you type at a command line to determine which shell you are using? To display a list of all manual pages containing the keyword date, what command would you type? What command should you use to check the number of files and disk space used and each users defined quotas? You have two files in two different directories with the same inode. What type of link is involved? In order to improve your systems security you decide to implement shadow passwords. What command should you use? What is the name and path of the default configuration file used by the syslogd daemon? How environment variable is set so that the file permission can be automatically set to the newly created files? Can Linux computer be made a router so that several machines may share a single Internet connection? How? How environment variable is set so that the file permission can be automatically set to the newly created files? Which command is used to check the number of files and disk space used and the each users defined quota?
What is kernel updation?

kernel updation means we are upgrading a kernel with a latest one you can do this via yum update <kernel rpm file> or rpm -Uvh <kernel rpm file>
How to install 8139 realtek drivers in rhel5.0? Please help me out.

1) Download the tarball from internet. 2)then extract tarball # tar -Zxvf (tarball pakage name) 3)make 4)make install
In Linux How to exclude ip from the given range please help me out

Type system-config-network and configure.

How to exclude ip address in dhcp? my ranges are 192.168.1.2 192.168.1.20 then how do i exclude different ip's like 192.168.1.4 and 7 and 10 from the range please help me out

subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.2 192.168.1.3; range 192.168.1.5 192.168.1.6; range 192.168.1.8 192.168.1.9; }

What command you execute to display the last five commands you have entered? Which partitions might you create on mail server HDDs other than the root, swap and boot partitions? Which partitioning tool is available in all distributions? Which two commands can you use to delete directories? Which file defines all users on your system?

1. history|tail -5 2. /var 3. fdisk, parted 4. rm, rmdir 5. /etc/passwd


What is the minimum number of partitions you need to install Linux? What command can you use to review boot messages?

1. Three Partition. boot partition, swap partition and root partition, these are the minimum partitions to install the linux. 2. dmesg or /var/log/messages
Describe the boot process of your favorite Linux in as much detail as you can.

first go to BIOS(Basic Input Output System), Post (Power on self Text) if all hardware connectivity are ok or not check, bootstrap-where to boot the device selected,Ex,Floppy,Cdrom,PXE, MBR(Master Boot Record) stored temporarly, MBR content 512MB Active Patition 2 Partition Information 64 IPL(Initial Programme Loader) 446, /boot/grub/grub.conf check 1 stage installed IPL 2 Stage installed vmlinuz,initrd, ->/etc/fstab check the root file system, -> initscript check the run levels -> /etc/inittab check the run levels,admin which run level using. ->display the login prompt
To display a list of all manual pages containing the keyword "date", what command would you type?

man -k date
What is the real mean of DHCP?

DHCP (Dynamic Host Configuration Protocol)It is use for provide The obtain IP address automaticaly with the help of DHCP we r Destribute the ip address for Client & DHCP is provide the ip address in the processior for use DORA.
What is difference between user right and user permission?

User right: user right means to login permisson for user. User permission: user permission means to give read, right, executive permisson for file for different users. Software testing - Questions and Answers - Linix / Unix 1. Q. How do you list files in a directory? A. ls - list directory contents ls l (-l use a long listing format) 2. Q. How do you list all files in a directory, including the hidden files? A. ls -a (-a, do not hide entries starting with .) 3. Q. How do you find out all processes that are currently running? A. ps -f (-f does full-format listing.) 4. Q. How do you find out the processes that are currently running or a particular user? A. ps -au Myname (-u by effective user ID (supports names)) (a - all users) 5. Q. How do you kill a process? A. kill -9 8 (process_id 8) or kill -9 %7 (job number 7) kill -9 -1 (Kill all processes you can kill.) killall - kill processes by name most (useful - killall java)

6. Q. What would you use to view contents of the file? A. less filename cat filename pg filename pr filename more filename most useful is command: tail file_name - you can see the end of the log file. 7. Q. What would you use to edit contents of the file? A. vi screen editor or jedit, nedit or ex line editor 8. Q. What would you use to view contents of a large error log file? A. tail -10 file_name ( last 10 rows) 9. Q. How do you log in to a remote Unix box? A. Using telnet server_name or ssh -l ( ssh - OpenSSH SSH client (remote login program)) 10.Q. How do you get help on a UNIX terminal? A. man command_name info command_name (more information) 11.Q. How do you list contents of a directory including all of its subdirectories, providing full details and sorted by modification time? A. ls -lac -a all entries -c by time 12.Q. How do you create a symbolic link to a file (give some reasons of doing so)? A. ln /../file1 Link_name Links create pointers to the actual files, without duplicating the contents of the files. That is, a link is a way of providing another name to the same file. There are two types of links to a file:Hard link, Symbolic (or soft) link; 13.Q. What is a filesystem? A. Sum of all directories called file system. A file system is the primary means of file storage in UNIX. File systems are made of inodes and superblocks. 14.Q. How do you get its usage (a filesystem)? A. By storing and manipulate files. 15.Q. How do you check the sizes of all users home directories (one command)? A. du -s df The du command summarizes disk usage by directory. It recurses through all subdirectories and shows disk usage by each subdirectory with a final total at the end. Q. in current directory A. ls -ps (p- directory; s - size) 16.Q. How do you check for processes started by user 'pat'?

A. ps -fu pat

(-f -full_format u -user_name )

17.Q. How do you start a job on background? A. bg %4 (job 4)

18 Q. What utility would you use to replace a string '2001' for '2002' in a text file? A. Grep, Kde( works on Linux and Unix)

19. Q. What utility would you use to cut off the first column in a text file? A. awk, kde 20. Q. How to copy file into directory? A. cp /tmp/file_name . (dot mean in the current directory) 21. Q. How to remove directory with files? A. rm -rf directory_name 22. Q. What is the difference between internal and external commands? A. Internal commands are stored in the; same level as the operating system while external commands are stored on the hard disk among the other utility programs. 23. Q. List the three main parts of an operating system command: A. The three main parts are the command, options and arguments. 24 Q. What is the difference between an argument and an option (or switch)? A. An argument is what the command should act on: it could be a filename, directory or name. An option is specified when you want to request additional information over and above the basic information each command supplies. 25. Q. What is the purpose of online help? A. Online help provides information on each operating system command, the syntax, the options, the arguments with descriptive information. 26. Q. Name two forms of security. A. Two forms of security are Passwords and File Security with permissions specified. 27. Q. What command do you type to find help about the command who? A. $ man who 28. Q. What is the difference between home directory and working directory? A. Home directory is the directory you begin at when you log into the system. Working directory can be anywhere on the system and it is where you are currently working. 29. Q. Which directory is closer to the top of the file system tree, parent directory or current directory? A. The parent directory is above the current directory, so it is closer to the root or top of the file system.

30. Q. Given the following pathname: $ /business/acctg/payable/supplier/april a) If you were in the directory called acctg, what would be the relative pathname name for the file called april? b) What would be the absolute pathname for april? A. a) $ payable/supplier/april b) $ /business/acctg/payable/supplier/april 31. Q. Suppose your directory had the following files: help. 1 help.2 help.3 help.4 help.O1 help.O2 aid.O1 aid.O2 aid.O3 back. 1 back.2 back.3 a) What is the command to list all files ending in 2? b) What is the command to list all files starting in aid? c) What is the command to list all "help" files with one character extension? A. a) ls *2 b) ls aid.* c) ls help.? 32. Q. What are two subtle differences in using the more and the pg commands? A. With the more command you display another screenful by pressing the spacebar, with pg you press the return key. The more command returns you automatically to the UNIX shell when completed, while pg waits until you press return. 33. Q. When is it better to use the more command rather than cat command? A. It is sometimes better to use the more command when you are viewing a file that will display over one screen. 34. Q. What are two functions the move mv command can carry out? A. The mv command moves files and can also be used to rename a file or directory. 35. Q. Name two methods you could use to rename a file. A. Two methods that could be used: a. use the mv command b. copy the file and give it a new name and then remove the original file if no longer needed. 36. The soccer league consists of boy and girl teams. The boy file names begin with B, the girl teams begin with G. All of these files are in one directory called "soccer", which is your current directory: Bteam.abc Bteam.OOl Bteam.OO2 Bteam.OO4 Gteam.win Gteam.OOl Gteam.OO2 Gteam.OO3 Write the commands to do the following: a) rename the file Bteam.abc to Bteam.OO3. b) erase the file Gteam. win after you have viewed the contents of the file c) make a directory for the boy team files called "boys", and one for the girl team files called" girls" d) move all the boy teams into the "boys" directory e) move all the girl teams into the "girls" directory f) make a new file called Gteam.OO4 that is identical to Gteam.OOl g) make a new file called Gteam.OO5 that is identical to Bteam.OO2 A. a) mv Bteam.abc Bteam.OO3.

b) cat Gteam.win -or- more Gteam.win rm Gteam. win c) mkdir boys mkdir girls d) mv Bteam* boys e) mv Gteam* girls f) cd girls cp Gteam.OO1 Gteam.OO4 g) There are several ways to do this. Remember that we are currently in the directory /soccer/girls. cp ../boys/Bteam.OO2 Gteam.OO5 or cd ../boys cp Bteam.OO2 ../girls/Gteam.OO5 37. Q. Draw a picture of the final directory structure for the "soccer" directory, showing all the files and directories. 38. 1.1 1.2 1.3 1.4 1.5 Q. What metacharacter is used to do the following: Move up one level higher in the directory tree structure Specify all the files ending in .txt Specify one character Redirect input from a file Redirect the output and append it to a file A. 1. 1.1 double-dot or .. 1.2 asterisk or * 1.3 question or ? 1.4 double greater than sign: >> 1.5 the less than sign or < 39. Q. List all the files beginning with A A. To list all the files beginning with A command: ls A* 40. Q. Which of the quoting or escape characters allows the dollar sign ($) to retain its special meaning? A. The double quote (") allows the dollar sign ($) to retain its special meaning. Both the backslash (\) and single quote (') would remove the special meaning of the dollar sign. 41. Q. What is a faster way to do the same command? mv fileO.txt newdir mv filel.txt newdir mv file2.txt newdir mv file3.txt newdir A. A shortcut method would be: mv file?.txt newdir 42. Q. List two ways to create a new file: A. a. Copy a file to make a new file. b. Use the output operator e.g. ls -l > newfile.txt 43. Q. What is the difference between > and >> operators? A. The operator > either overwrites the existing file (WITHOUT WARNING) or creates a new file.

The operator >> either adds the new contents to the end of an existing file or creates a new file. 44. Write the command to do the following: 44.1 Redirect the output from the directory listing to a printer. 44.2 Add the file efg.txt to the end of the file abc.txt. 44.3 The file testdata feeds information into the file called program 44.4 Observe the contents of the file called xyz.txt using MORE. 44.5 Observe a directory listing that is four screens long. A. 44.1 ls > lpr 44.2 cat efg.txt >> abc.txt 44.3 program < testdata 44.4 more < xyz.txt 44.5 ls > dirsave | more

45. Q. How do you estimate file space usage A. Use du command (Summarize disk usage of each FILE, recursively for directories.) Good to use arguments du -hs (-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G) (-s, --summarize display only a total for each argument) 46. Q. How can you see all mounted drives? A. mount -l 47. Q. How can you find a path to the file in the system? A. locate file_name (locate - list files in databases that match a pattern) 48. Q. What Linux HotKeys do you know? A. Ctrl-Alt-F1 Exit to command prompt Ctrl-Alt-F7 or F8 Takes you back to KDE desktop from command prompt Crtl-Alt-Backspace Restart XWindows Ctrl-Alt-D Show desktop 49. Q. What can you tell about the tar Command? A. The tar program is an immensely useful archiving utility. It can combine an entire directory tree into one large file suitable for transferring or compression. 50. Q. What types of files you know? A. Files come in eight flavors: Normal files Directories Hard links Symbolic links Sockets Named pipes Character devices Block devices 51. Q. How to copy files from on PC to another on the same network A. Use the following command:scp yur_file you_login@your_IP example: copy .conf file from your PC to alex computerscp /etc/X11/xorg.conf [email protected]:

52.

Q. Please describe information below: 1 dotpc 9 dotpc 1 dotpc 11 7 12 5 11 1 dotpc dotpc dotpc dotpc dotpc dotpc dotpc dotpc dotpc dotpc dotpc dotpc dotpc dotpc dotpc 102 Jul 18 2003 file.buf 4096 Oct 21 09:34 bin 20 Mar 21 15:00 client -> client4096 4096 4096 4096 4096 644836 Sep Dec Oct Dec Mar Mar 2 14 21 7 21 22 2005 12:13 09:41 14:22 15:54 09:53 client-2.8.9 data docs etc client-2.9.5 client-2.9.5.tar.gz

-rw-rw-r-drwxr-xr-x lrwxrwxrwx 2.9.5 drwxrwxr-x drwxrwxr-x drwxr-xr-x drwxr-xr-x drwxr-xr-x -rw-r--r--

A. This is a result of command $ls -l we have two files, 6 directories and one link to client-2.9.5 directory. There is number of files in every directory, size and data of last change. 53. Q. If you would like to run two commands in sequence what operators you can use? A. ; or && the difference is: if you separate commands with ; second command will be run automatically. if you separate commands with && second command will be run only in the case the first was run successfully. 54. Q. How you will uncompress the file? A. Use tar command (The GNU version of the tar archiving utility): tar -zxvf file_name.tar.gz 55. Q.How do you execute a program or script, my_script in your current directoty? A. ./my_script 56. Q.How to find current time configuration in the file my_new.cfg A. grep time my_new.cfg Grep searches the named input files (or standard input if no files are named, or the file name - is given) for lines containing a match to the given pattern. Q. What does grep() stand for? A. General Regular Expression Parser. 57. Q. What does the top command display? A. Top provides an ongoing look at processor activity in real time. It displays a listing of the most CPU-intensive tasks on the system, and can provide an interactive inter face for manipulating processes. (q is to quit) 58. Q. How can you find configuration on linux? A. by using /sin/ifconfig If no arguments are given, ifconfig displays the status of the currently active interfaces. If a single interface argument is given, it displays the status of the given interface only; if a single -a argument is given, it displays the status of all interfaces, even those that are down. Otherwise, it configures an interface. 59. Q. How to find difference in two configuration files on the same server? A. Use diff command that is compare files line by line

diff -u /usr/home/my_project1/etc/ABC.conf /usr/home/my_project2/etc/ABC.conf 60. Q. What is the best way to see the end of a logfile.log file? A. Use tail command - output the last part of files tail -n file_name ( the last N lines, instead of the last 10 as default) 61. Q. Please write a loop for removing all files in the current directory that contains a word 'log' A. for i in *log*; do rm $i; done 62. Question: How to switch to a previously used directory? Answer: cd -

1.

Q.How many VI editor modes do you know? A.Three modes Command mode: letters or sequence of letters interactively command vi. Insert mode: Text is inserted. Command line mode: enter this mode by typing ":" and entry command line at the foot of the screen. 2. 3. Q. How can you terminate VI session? A. Use command: ZZ that is save changes and quit. Use command line: ":wq" that is write changes and quit. Use command line: ":q!" to ignore changes and quit.

Q. How can you copy lines into the buffer in command mode? A. yy - copy a single line defined by current cursor position 3yy - copy 3 lines. Current line and two lines below it.

1. Explain booting process of linux. 2. Explain the NFS Daemons. 3. What is the difference between soft & hard links 4. If a remote server having a nfs share mounted is not coming up after reboot . What could be the problem? How will you troubleshoot and fix it.
5. Explain the 5th & 6th field in /etc/fstab file

6. After an unclean shutdown of a linux box, kernel initiates file system checks on the file system(s). From where kernel identify that the last system shutdown/reboot was unclean. 7. What is grub. 8. Explain the procedure to install rpm package with all dependency packages using rpm command. 9. How to check where a particular package installed its configuration files 10. How to you check status of nfs server from a client system. 11. What is the Journaling. 12. What are the types of Journaling.

13. Explain difference between moduler & monolytic kernel 14. Explain kernel compilation steps. 15. Which file stores kernel configuration details. 16. How to check the currently configured kernel parameters on a linux server. 17. Explain semaphore settings 18. How to check how much memory is used by a particular process in KBs 19. How to check the shared memory used by any particular application 20. What is shared memory 21. What is the use of shared memory 22. What is the difference between passive & active ftp 23. Explain setuid, setgid & sticky bit. 24. How to check the free inodes in a file system 25. How to troubleshoot if the root file system space is increasing very fast in reach more than 95 % 26. What do you mean by zombie process 27. How will you kill the zombie processes 28. How to check what system calls a particular script or program is executing in the background.
29. 1)Explain Process management and related commands

2 )Explain Memory management and related commands 3 )What is Open Group standards?
30.

4) Secify special usage for each one of the following file /dev/null - Send unwanted output /dev/random - Random number generation /dev/zero - Cache or Destroy data on a partition - dd if=/dev/zero of=/dev/sda98
31.

5) What is SELinux? 6) Write a command to find all of the files which have been accessed within the last 10 days. 7) What is LILO? 8) What is Grub? 9) Explain the difference between LILO and Grub
32.

10) What is NFS? 11) What is NAMED? 12) What is MySQLD?

13) What is mysql? 14) What is CVS? 15) Why You Shouldn't Use the root Login for everyday work? 16) Describe the default partition scheme in Redhat Linux?
33.

17) Describe the default partition scheme in Solaris? What is the slice number? 18) Describe all default mount point? 19) What is boot block? 20) What is logical block? 21) Describe the process for adding a new hard disk to UNIX box?
34.

22) Describe the process for adding a new hard disk to Linux box? 23) Describe the process for adding a new hard disk to Linux LVM to grow /home? 24) Explain one major difference between a regular file system and a journaling file system?
35.

25)Define JFS 26) Define UFS 27) How do you lock and unlock user account / password? 28) Describe RPM and command to install / remove / update Linux system? 29) Explain difference between rpm and up2date command.
36.

30) Explain difference between rpm and apt-get command. 31) Explain difference between rpm and yum command. 32) Describe usage for pkgadd, pkginfo and pkgchk command 33) How do you find files on UNIX or Linux system?
37.

34) Explain /etc/rc3.d 35) Explain ntsysv or chkconfig command 36) How do you get rid of process if kill PID is not working for you? 37) What is the purpose of the command? grep

sed awk 38. ifconfig netstat df du prtvtoc fdisk -l umaks getfacl setfacl sudo fsck probe-scsi vmstat 38) Explain LVM 1) What is a superblock ? 2) What is a parity bit? 3) What is an inod? 39. 4) Explain top command ? 5) How to disable the root login in SSH ? 6) use of sysctl command ? 7) LVM how to ? 8)Different RAID levels ? 39) What are the services required for nfs, apache(http) and NIS?
40.

40) What is the best way to check the status of any service? 41) What do you mean by parity in RAID and which RAID is useful now a days? 42) Explain Linux Boot process especially kernel and initrd. 41. 43) Why we do have two commands useradd and adduser when their functialnality is same? 42. Q. How can we see the boot messages?
43.

Answer: T he boot messages we can use dmesg, a command that prints on the screen the kernel ring buffer messages; the command is to be used just after the boot sequence. The syntax of a ring buffer is like this: dmesg [options]. If dmesg is called with no options the messages from the kernel will be written to the standard output. 44. Q. What are the differences between GRUB and LILO?
45.

Answer : LILO (LInux LOader) LILO stores information about the location of the kernel or other operating system on the Master Boot Record (MBR). GNU GRUB (GRand Unified Boot loader)

GRUB has a more powerful, interactive command line interface RUB will default to its command line interface where the user can boot the system manually. GRUB may have difficulties booting certain hardware. LILO and GRUB do have a number of differences: * LILO has no interactive command interface, whereas GRUB does. * LILO does not support booting from a network, whereas GRUB does. * LILO stores information regarding the location of the operating systems it can to load physically on the MBR. If you change your LILO config file, you have to rewrite the LILO stage one boot loader to the MBR. Compared with GRUB, this is a much more risky option since a misconfigured MBR could leave the system unbootable. With GRUB, if the configuration file is configured incorrectly, it will simply default to the GRUB command-line interface. http://linuxdevcenter.com/pub/a/linux/2008/01/22/lilo-and-grub-boot-loaders-madesimple.html http://blog.webhosting.uk.com/web-hosting/what-is-difference-between-grub-and-lilo 46. Q. What is Kernel? Explain the task it performs.
47.

Answer: Kernel is used in UNIX like systems and is considered to be the heart of the operating system. It is responsible for communication between hardware and software components. It is primarily used for managing the systems resources as well. Kernel Activities: The Kernel task manager allows tasks to run concurrently. Managing the computer resources: Kernel allows the other programs to run and use the resources. Resources include i/o devices, CPU, memory. Kernel is responsible for Process management. It allows multiple processes to run simultaneously allowing user to multitask. Kernel has an access to the systems memory and allows the processes to access the memory when required. Processes may also need to access the devices attached to the system. Kernel assists the processes in doing so. For the processes to access and make use of these services, system calls are used. Ref: http://www.careerride.com/Linux-Kernel.aspx Q. Explain Boot sequence Answer:

a) BIOS Initialization b ) Boot Loader c) Kernel Initialization d) init starts and enters desired run level by executing - /etc/rc.d/rc.sysinit - /etc/rc.d/rc and /etc/rc.d/rcX.d/ ( X is a runlevel 0-6) - /etc/rc.d/rc.local - X Display manager if appropriate

Q. What are the Minimum Specifications for booting a Linux OS? a) Label b) Kernel Location c) OS root File system d) Location of the initial ram disk ( initrd)
48. Linux Tips

************ 49. What command should you use to check your filesystem? 50. Answer: fsck The fsck command is used to check the integrity of the filesystem on your disk. 51. You want to print out a text file called vacations however the lines are of varying length. What text filter could you use to even out the length of the lines? 52. Answer: fmt The fmt text utility attempts to make all the lines the same lenght by joining or splitting lines. 53. You need to locate a file called salesdata that one of your users created in his home directory but you do not know which one. How could you use the find command to locate this file? 54. Answer: find /home -name salesdata When using the find command to locate a file by name you must specify the starting place in the directory heirarchy and the -name option to specify the file to search for. 55. What command would you type to use the cpio to create a backup called backup.cpio of all the users home directories? 56. Answer: find /home | cpio -o > backup.cpio The find command is used to create a list of the files and directories contained in home. This list is then piped to the cpio utility as a list of files to include and the output is saved to a file called backup.cpio. 57. You want to create a compressed backup of the users home directories so you issue the command gzip /home/* backup.gz but it fails. The reason that it failed is that gzip will only compress one _______ at a time.

58. Answer: file

The gzip utility cannot compress multiple files in a single operation. 59. You have three files in the /home/ben/memos directory called letters, tom, betty. How could you determine each files type by issuing only one command? 60. Answer: file letters tom betty The file utility will display the files type for each filename that is passed as an argument. 61. In order to display the last five commands you have entered using the fc command, you would type ___________. 62. Answer: fc -5 The fc command can be used to edit or rerun commands you have previously entered. To specify the number of commands to list, use -n. 63. Each command has two types of output. There are standard output and standard __________. 64. Answer: error By default, each command sends its result as standard output and any error messages as standard error. 65. What can you type at a command line to determine which shell you are using? 66. Answer: echo $SHELL The name and path to the shell you are using is saved to the SHELL environment variable. You can then use the echo command to print out the value of any variable by preceding the variables name with $. Therefore, typing echo $SHELL will display the name of your shell. 67. What type of local file server can you use to provide the distribution installation materials to the new machine during a network installation? 68. A) Inetd B) FSSTND C) DNS D) NNTP E) NFS 69. Answer: E You can use an NFS server to provide the distribution installation materials to the machine on which you are performing the installation. Answers a, b, c, and d are all valid items but none of them are file servers. Inetd is the superdaemon which controls all intermittently used network services. The FSSTND is the Linux File System Standard. DNS provides domain name resolution, and NNTP is the transfer protocol for usenet news. 70. What would you type to send the last 20 lines of a text file to STDIN? 71. A) end -n 20 filename B) last -n 20 filename C) head -20 filename D) end -20 filename E) tail -20 filename 72. Answer: E Use the command tail -20 filename to see the last 20 lines of a file. The answers for a and d both point to an invalid command. The answer for b points to a valid command. Typing this answer in with a valid file name will even give you some output. However, the last command tells you who is logged in, it does not actually list the contents of any file named in the command. The answer for c, the head command, is used to look at the beginning of a file, not the end. 73. Which command works in almost all distributions to create a boot disk? 74. A) mkboot B) make bootdsk C) make boot

D) mkbootdsk E) mkbootdisk 75. Answer: E The mkbootdisk command creates a boot disk. Answers b and c are incorrect. The make package is used to compile software, not create boot disks. Answers a and d point to invalid commands. 76. Which command do you use to change runlevels? 77. A) initlevel B) runlevel C) level D) run E) init 78. Answer: E The command used to change runlevels is init. Answers a, c, and d point to invalid commands. Answer b is a valid command, but does not set the current runlevel. The runlevel command displays the current runlevel, and the one that was used directly before entering this one. 79. You have a new, empty hard drive that you will use for Linux. What is the first step you use. Choose one: 80. a. Create an extended partition to be used for data. b. Format the hard drive to use the ext2 filesystem. c. Create a swap partition of type 82. d. Create a primary partition using fdisk. 81. Answer: d You must always first create a primary partition. Operating systems, including Linux, can only be booted from a primary partition. 82. You have configured logrotate to rotate your logs weekly and keep them for eight weeks. You are running our of disk space. What should you do? Choose one: 83. a. Quit using logrotate and manually save old logs to another location. b. Reconfigure logrotate to only save logs for four weeks. c. Configure logrotate to save old files to another location. d. Use the prerotate command to run a script to move the older logs to another location. 84. Answer: d You can use the prerotate command to run a script before logs are rotated. You could have this script move the older logs to another location before rotation occurs. 85. If you type the command cat dog &> cat what would you see on your display? Choose one: 86. a. Any error messages only. b. The contents of the file dog. c. The contents of the file dog and any error messages. d. Nothing as all output is saved to the file cat. 87. Answer: d When you use &> for redirection, it redirects both the standard output and standard error. The output would be saved to the file cat. 88. You have a directory with the following permissions drw-rww- 1 root admin 7202 Sep 17 9:10 administration and need to give everyone except root read only access to it. Which of the following commands will accomplish this? Choose one: 89. a. chmod uo=r administration b. chmod ug+r administration

c. chmod uo+r administration d. chmod ug=r administration 90. Answer: d When using symbols, the equal sign explicitly sets permissions and revokes any preexisting permissions. 91. You want to know how much space is being occupied by your users home directories. Which of the following will provide you with this information? Choose one: 92. a. du -l /home b. du -b /home c. du -m /home d. du -c /home 93. Answer: d Using the -c option with the du command will show the grand total of used space for the designated directory. 94. You have entered the following cronjob. When will it run? 15 * * * 1,3,5 myscript Choose one: 95. a. at 15 minutes after every hour on the 1st, 3rd and 5th of each month. b. at 1:15 am, 3:15 am, and 5:15 am every day c. at 3:00 pm on the 1st, 3rd, and 5th of each month d. at 15 minutes after every hour every Monday, Wednesday, and Friday 96. Answer: d This would run at 15 minutes after the hour on every Monday, Wednesday, and Friday of every month no matter what the date. 97. You need to see the last fifteen lines of the files dog, cat and horse. What command should you use? 98. Answer: 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. 99. Who owns the data dictionary? 100.Answer: The SYS user owns the data dictionary. The SYS and SYSTEM users are created when the database is created. 101.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. 102.Answer: zcat The zcat utility allows you to examine the contents of a compressed file much the same way that cat displays a file. 103.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? 104.Answer: 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. 105.You locate a command in the /bin directory but do not know what it does. What command can you use to determine its purpose. 106.Answer: whatis The whatis command displays a summary line from the man page for the specified command. 107.You wish to create a link to the /data directory in bobs 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. 108.Answer: Use the -F option In order to create a link to a directory you must use the -F option. 109.When you issue the command ls -l, the first character of the resulting display represents the files ___________. 110.Answer: type The first character of the permission block designates the type of file that is being displayed. 111.What utility can you use to show a dynamic listing of running processes? 112.Answer: top The top utility shows a listing of all running processes that is dynamically updated. 113.Where is standard output usually directed? 114.Answer: to the screen or display By default, your shell directs standard output to your screen or display. 115.You want to create a compressed backup of the users home directories. What utility should you use? 116.Answer: tar You can use the z modifier with tar to compress your archive at the same time as creating it. 117.You wish to restore the file memo.ben which was backed up in the tarfile MyBackup.tar. What command should you type? 118.Answer: 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. 119.You need to view the contents of the tarfile called MyBackup.tar. What command would you use? 120.Answer: tar tf MyBackup.tar The t switch tells tar to display the contents and the f modifier specifies which file to examine. 121.What daemon is responsible for tracking events on your system? 122.Answer: syslogd The syslogd daemon is responsible for tracking system information and saving it to specified log files. 123.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? 124.Answer: split The split text filter will divide files into equally sized pieces. The default length of each piece is 1,000 lines. 125.You would like to temporarily change your command line editor to be vi. What command should you type to change it? 126.Answer: 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. 127.What account is created when you install Linux? 128.Answer: root Whenever you install Linux, only one user account is created. This is the superuser account also known as root.

129.What command should you use to check the number of files and disk

space used and each users defined quotas?


130.Answer: 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. 131.In order to run fsck on the root partition, the root partition must be mounted as ___________. 132.Answer: readonly You cannot run fsck on a partition that is mounted as read-write. 133.In order to improve your systems security you decide to implement shadow passwords. What command should you use? 134.Answer: pwconv The pwconv command creates the file /etc/shadow and changes all passwords to x in the /etc/passwd file. 135.Bob Armstrong, who has a username of boba, calls to tell you he forgot his password. What command should you use to reset his command? 136.Answer: passwd boba The passwd command is used to change your password. If you do not specify a username, your password will be changed. 137.When you look at the /etc/group file you see the group kmem listed. Since it does not own any files and no one is using it as a default group, can you delete this group? 138.Answer: no The kmem group manages direct access to kernel memory and is necessary for your systems health. 139.What text filter can you use to display a multi-page file and place numbers at the beginning of each line. DirContents Using the > will redirect the output of the ls /etc command to the file DirContents. 140.What file defines the levels of messages written to system log files? 141.Answer: kernel.h To determine the various levels of messages that are defined on your system, examine the kernel.h file. 142.You have two files each ten lines long. What text filter could you use to combine the two files so that each line of the output contains the corresponding line from each file? 143.Answer: join The join text filter will display one line for each pair of input lines from two files. 144.You have two files in two different directories with the same inode. What type of link is involved? ,1] ); //> Answer: nl The nl text filter will divide a file into logical pages and number each line. 145.Question The top utility can be used to change the priority of a running process? Another utility that can also be used to change priority is ___________? 146.Answer: nice Both the top and nice utilities provide the capability to change the priority of a running process.

147.In order to apply a filesystem to your new partitions you must

format them. What command would you use to create the ext2 filesystem?
148.Answer: mke2fs

The mke2fs command creates the new filesystem on your partition.


149.What command should you type to see all the files with an

extension of mem listed in reverse alphabetical order in the /home/ben/memos directory. 150.Answer: ls -r /home/ben/memos/*.mem The -c option used with ls results in the files being listed in chronological order. You can use wildcards with the ls command to specify a pattern of filenames. 151.In order to create a file called DirContents containing the contents of the /etc directory you would type ____________. 152.Answer: ls /etc > DirContents Using the > will redirect the output of the ls /etc command to the file DirContents. 153.What file defines the levels of messages written to system log files? 154.Answer: kernel.h To determine the various levels of messages that are defined on your system, examine the kernel.h file. 155.You have two files each ten lines long. What text filter could you use to combine the two files so that each line of the output contains the corresponding line from each file? 156.Answer: join The join text filter will display one line for each pair of input lines from two files. 157.You have two files in two different directories with the same inode. What type of link is involved? /interview-questions/type.asp?iType\u003d83&offset\u003d20 158.,0] ); D(["ma",[1," Linux JOB Interview questions.doc 61K View as HTML Scanning for viruses...
159.","10b484103aee0819"] ] ); D(["ce"]); //>

Answer: hard Hard links all have the same inode number, unlike symbolic links. 160.What command is used to remove the password assigned to a group? 161.Answer: gpasswd -r The gpasswd command is used to change the password assigned to a group. Use the -r option to remove the password from the group. 162.What is the default Window system / Windows manager used in Linux?
163.Code:

164.X.org

165.What command is used to list the contents of directory?


166.Code:

167.ls 168.ls -l

169.What command is used to list the top 10 files / directories size wise?
170.Code:

171.for X in $(du -s * | sort -nr | cut -f 2); do du -hs $X ; done

172.What command is used to display a list of currently running processes?

173.Code:

174.ps 175.top 176.pstree 177.pgrep 178./proc file system

179.What is a login shell?

A program get executed when a user logs into UNIX box. E.g. bash, sh, ksh, csh
180.What is UID?

User identification number which is assigned to each UNIX / Linux user; it may or may not be unique (unique number is recommended to avoid security related issues). UID and user relationship defined in /etc/passswd file.
181.Code:

182.man id 183.man users 184.man groups

185.Explain Unix User security concept

Permissions - chmod and chown User groups - group management - user management Read su, sudo man page 186.What PID? Process identification number; use ps command to see PID. It is a number used by Unix kernels and Windows operating systems to identify a process. 187.Explain process ID zero and process ID 1? All the idle task has process ID zero, and never exits. The init process, with process ID 1, which does nothing but wait around for its child processes to die. Usually started for /etc/inittab 188.Explain wheel group usage along with an example?
189.Code:

190.man su

191.What command is used to check a file system for errors?


192.Code:

193.fsck 194.fsck.ext3 195.fsck.nfs 196.fsck.ext2 197.fsck.vfat 198.fsck.reiserfs 199.fsck.msdos

200.Is Linux / UNIX file system case sensitive? Give one example

Yes, test.txt and TEST.txt are two different files


201.What file contains the list of drives that are mounted at boot?

/etc/fstab - Linux / Other UNIX version /etc/vfstab - Solaris UNIX 202.Explain the usage of the fourth field in /etc/fstab? It is formatted as a comma separated list of options. Read mount command man page for all the option. 203.What is /etc/inittab file? In what file is the default run level defined? System V init examines the '/etc/inittab' file for an 'initdefault' entry, which tells init whether there is a default runlevel. init is the program on Unix that spawns all other processes. It runs as a daemon and typically has PID 1.
204.Code:

205.man init 206.cat /etc/inittab

207.Common runlevle values on RHEL


208.Code:

209. 210. 211. 212. 213.


215.Code:

0. 1. 6. 3. 5.

Halt Single user mode Reboot Default text Default GUI

214.To check the current runlevel:


216.who -r 217.runlevel

218.What command is used to get help about command? What command is used to read manual page for a given command?
219.Code:

220.info command-name 221.man command-name 222.command-name -h 223.command-name --help

224.What command form or symbol used to redirect output to a file?

Use the > symbol


225.Code:

226.command-name > output.txt

227.Use the < symbol to read input from a file 228.What is ssh? Specify ssh command syntax to execute command over a TCP/IP network? SSH is Application layer protocol which allows data to be exchanged over a secure channel between two computers. 229. 230.Explain Raw device and command s to configure Raw device Block device file that allows accessing a storage device such as a hard drive directly. For example /dev/hda. Use commands
231.Code:

232.mknod 233.fdisk 234.mkfs 235.mkfs.ext3

236.Explain UNIX software pipeline concept


237.Code:

See shell or bash man page

238.cat /etc/passwd | grep username 239.mount | grep cdrom

240.Explain XYZ Unix daemons

Where XYZ can be any one of the following:


241.Code:

242.init 243.httpd 244.dhcpd 245.lpd

246.nfsd 247.ntpd 248.syslogd 249.ypbind 250.ftpd 251.telnetd 252.sshd 253.named

254.xplain Process management and related commands 255.Explain Memory management and related commands 256.What is Open Group standards? 257.Secify seciaal usage for each one of the following file /dev/null - Send unwanted output /dev/random - Random number generation /dev/zero - Cache or Destroy data on a partition - dd if=/dev/zero of=/dev/sda98 258.Explain Linux Exec Shield 259. 260.1) Your encyclopedic knowledge of Linux is far more likely to get you a job than your actual problem solving skills. 2) Technical questions asked during phone interviews and even face-to-face interviews tend to be fairly basic. Employers rarely ever go into detailed technical scenarios. 3) You will be asked almost the same technical questions at almost all interviews you attend. 261.This means that even if you feel your knowledge of Linux is limited at the moment, make sure to know detailed answers to the following Top Linux Interview Questions and you double your chances of getting the job. 262.You are virtually guaranteed that at least half of the questions asked will sound very similar to the following (I tried to provide the simplest ways to answer these as well, for full answers please refer to http://www.linuxinterviewquestions.com): 263.1) What is the difference between TCP and UDP? 264.The basic difference is that TCP establishes a connection before sending data and this allows it to control the dataflow and guarantee that all packets get delivered. UDP simply chucks datagrams onto the wire and if some get lost or arrive in bad order theres no way to request a resend. However UDP has low network overhead so some services such as DNS resolution, SNMP, DHCP, RIP and VOIP use UDP for its speed and any errors are usually dealt with on the application layer rather than network layer. 265.2) What is the TCP hand shake? 266.TCP requires three packets to set up a socket connection, before any user data can be sent. This is called the tree way TCP handshake. First the requester sends a SYN packet and expects a SYN-ACK packet, to which the initiator replies with ACK packet plus the first chunk of user data. From there on the TCP connection is established and two sides exchange user data using features such as message acknowledgment, retransmission and timeout. 267.3) How does DNS resolution work? 268.A client application requests an IP address from the name server usually by connecting to UDP port 53. The name server will attempt to resolve the FQDN based on its resolver library, which may contain authoritative information about the host

requested or cached data about that name from an earlier query. If the name server does not already have the answer, it will turn to root name servers to determine the authoritative for the FQDN in question. Then, with that information, it will query the authoritative name servers for that name to determine the IP address. 269.4) What is an MX record? 270.MX record numerically ranks the mail servers you would prefer to receive email for a domain. The MX record with the lowest number is preferred over the others, but you can set multiple email servers with the same value for simple load balancing. 271.5) Describe Linux boot-up sequence 272.BIOS reads the MBR where Boot Loader sits, Boot Loader reads Kernel into memory, Kernel starts Init process, Init reads inittab, executes rc.sysinit, the rc script than starts services to reach the default run level and once this is done the last thing that gets run is the rc.local script. 273.6) What is an INODE? 274.All files have its description stored in a structure called inode. The inode contains info about the file-size, access and modification time, permission and so on. In addition to descriptions about the file, the inode contains pointers to the data blocks of the file. 275.7) How do you search for a pattern and than replace it in an entire file? 276.Using Sed or in Vi editor the search usually involves character s slash the pattern to be searched, slash the pattern to replace it with, slash g which stands for entire file. 277. How do you list and flush all IPtables? 278.Using the iptables command with -L switch first to see all the rules currently present in memory and than -F to flush them. 279.9) How do you list compiled-in Apache modules? 280.Run the httpd daemon as a command with -l parameter. 281.10) What is a zombie? 282.Zombie processes can be identified in the output of ps by the presence of Z in the STAT column. Zombies are child processes whose parent process died 283.without reaping its children. Zombies cant be killed with the usual KILL signal
284.You attempt to use shadow passwords but are unsuccessful. What characteristic of the /etc/passwd file may cause this? Choose one: a. The login command is missing. b. The username is too long. c. The password field is blank. d. The password field is prefaced by an asterick.

285.You create a new user account by adding the following line to your /etc/passwd file.
bobm:baddog:501:501:Bob Morris:/home/bobm:/bin/bash Bob calls you and tells you that he cannot logon. You verify that he is using the correct username and password. What is the problem? Choose one: a. The UID and GID cannot be identical. b. You cannot have spaces in the line unless they are surrounded with double quotes. c. You cannot directly enter the password; rather you have to use the passwd command to assign a password to the user. d. The username is too short, it must be at least six characters long.

286.Which of the following tasks is not necessary when creating a new user by editing the
/etc/passwd file? Choose one: a. Create a link from the users home directory to the shell the user will use. b. Create the users home directory c. Use the passwd command to assign a password to the account. d. Add the user to the specified group. 287.You create a new user by adding the following line to the /etc/passwd file bobm::501:501:Bob Morris:/home/bobm:/bin/bash You then create the users home directory and use the passwd command to set his password. However, the user calls you and says that he cannot log on. What is the problem? Choose one: a. The user did not change his password. b. bobm does not have permission to /home/bobm. c. The user did not type his username in all caps. d. You cannot leave the password field blank when creating a new user. 288.When using useradd to create a new user account, which of the following tasks is not done automatically. Choose one: a. Assign a UID. b. Assign a default shell. c. Create the users home directory. d. Define the users home directory.

289.You issue the following command useradd -m bobm But the user cannot logon. What is the
problem? Choose one: a. You need to assign a password to bobms account using the passwd command. b. You need to create bobms home directory and set the appropriate permissions. c. You need to edit the /etc/passwd file and assign a shell for bobms account. d. The username must be at least five characters long.

290.You have created special configuration files that you want copied to each users home
directories when creating new user accounts. You copy the files to /etc/skel. Which of the following commands will make this happen? Choose one: a. useradd -m username b. useradd -mk username c. useradd -k username d. useradd -Dk username 291.Mary has recently gotten married and wants to change her username from mstone to mknight. Which of the following commands should you run to accomplish this? Choose one: a. usermod -l mknight mstone b. usermod -l mstone mknight c. usermod -u mknight mstone d. usermod -u mstone mknight 292.After bob leaves the company you issue the command userdel bob. Although his entry in the /etc/passwd file has been deleted, his home directory is still there. What command could you have used to make sure that his home directory was also deleted? Choose one: a. userdel -m bob b. userdel -u bob c. userdel -l bob d. userdel -r bob 293.All groups are defined in the /etc/group file. Each entry contains four fields in the following order. Choose one: a. groupname, password, GID, member list b. GID, groupname, password, member list c. groupname, GID, password, member list d. GID, member list, groupname, password 294.You need to create a new group called sales with Bob, Mary and Joe as members. Which of the following would accomplish this? Choose one: a. Add the following line to the /etc/group file: sales:44:bob,mary,joe b. Issue the command groupadd sales. c. Issue the command groupadd -a sales bob,mary,joe d. Add the following line to the /etc/group file: sales::44:bob,mary,joe 295.What command is used to remove the password assigned to a group?

296.You changed the GID of the sales group by editing the /etc/group file. All of the members can change to the group without any problem except for Joe. He cannot even login to the system. What is the problem? Choose one: a. Joe forgot the password for the group. b. You need to add Joe to the group again. c. Joe had the original GID specified as his default group in the /etc/passwd file. d. You need to delete Joes account and recreate it.

297.You need to delete the group dataproject. Which two of the following tasks should you do
first before deleting the group? A. Check the /etc/passwd file to make sure no one has this group as his default group. B. Change the members of the dataproject group to another group besides users. C. Make sure that the members listed in the /etc/group file are given new login names. D. Verify that no file or directory has this group listed as its owner. Choose one: a. A and C b. A and D c. B and C d. B and D 298.When you look at the /etc/group file you see the group kmem listed. Since it does not own any files and no one is using it as a default group, can you delete this group?

299.When looking at the /etc/passwd file, you notice that all the password fields contain x. What
does this mean? Choose one: a. That the password is encrypted. b. That you are using shadow passwords. c. That all passwords are blank. d. That all passwords have expired. 300.In order to improve your systems security you decide to implement shadow passwords. What command should you use? 301.What file contains the default environment variables when using the bash shell? Choose one: a. ~/.profile b. /bash c. /etc/profile d. ~/bash

302.You have created a subdirectory of your home directory containing your scripts. Since you
use the bash shell, what file would you edit to put this directory on your path? Choose one: a. ~/.profile b. /etc/profile c. /etc/bash d. ~/.bash 303.Which of the following interprets your actions when typing at the command line for the operating system? Choose One a. Utility b. Application c. Shell d. Command 304.What can you type at a command line to determine which shell you are using? 305.You want to enter a series of commands from the command-line. What would be the quickest way to do this? Choose One a. Press enter after entering each command and its arguments b. Put them in a script and execute the script c. Separate each command with a semi-colon (;) and press enter after the last command d. Separate each command with a / and press enter after the last command 306.You are entering a long, complex command line and you reach the right side of your screen before you have finished typing. You want to finish typing the necessary commands but have the display wrap around to the left. Which of the following key combinations would achieve this? Choose One a. Esc, /, Enter b. /, Enter c. ctrl-d, enter d. esc, /, ctrl-d

307.After typing in a new command and pressing enter, you receive an error message indicating
incorrect syntax. This error message originated from.. Choose one a. The shell b. The operating system c. The command d. The kernel 308.When typing at the command line, the default editor is the _____________ library.

309.You typed the following at the command line ls -al /home/ hadden. What key strokes would you enter to remove the space between the / and hadden without having to retype the entire line? Choose one a. Ctrl-B, Del b. Esc-b, Del c. Esc-Del, Del d. Ctrl-b, Del 310.You would like to temporarily change your command line editor to be vi. What command should you type to change it? 311.After experimenting with vi as your command line editor, you decide that you want to have vi your default editor every time you log in. What would be the appropriate way to do this? Choose one a. Change the /etc/inputrc file b. Change the /etc/profile file c. Change the ~/.inputrc file d. Change the ~/.profile file 312.You have to type your name and title frequently throughout the day and would like to decrease the number of key strokes you use to type this. Which one of your configuration files would you edit to bind this information to one of the function keys? 313.In your present working directory, you have the files maryletter memo1 MyTelephoneandAddressBook What is the fewest number of keys you can type to open the file MyTelephoneandAddressBook with vi? Choose one a. 6 b. 28 c. 25 d. 4 314.A variable that you can name and assign a value to is called a _____________ variable.

315.You have installed a new application but when you type in the command to start it you get
the error message Command not found. What do you need to do to fix this problem? Choose one a. Add the directory containing the application to your path b. Specify the directorys name whenever you run the application c. Verify that the execute permission has been applied to the command. d. Give everyone read, write and execute permission to the applications directory. 316.You telnet into several of your servers simultaneously. During the day, you sometimes get confused as to which telnet session is connected to which server. Which of the following commands in your .profile file would make it obvious to which server you are attached? Choose one a. PS1=\h: \w> b. PS1=\s: \W> c. PS1=\!: \t> d. PS1=\a: \n> 317.Which of the following environment variables determines your working directory at the completion of a successful login? Choose one a. HOME b. BASH_ENV c. PWD d. BLENDERDIR 318.Every time you attempt to delete a file using the rm utility, the operating system prompts you for confirmation. You know that this is not the customary behavior for the rm command. What is wrong? Choose one a. rm has been aliased as rm -i b. The version of rm installed on your system is incorrect. c. This is the normal behavior of the newest version of rm. d. There is an incorrect link on your system. 319.You are running out of space in your home directory. While looking for files to delete or compress you find a large file called .bash_history and delete it. A few days later, it is back and as large as before. What do you need to do to ensure that its size is smaller? Choose one a. Set the HISTFILESIZE variable to a smaller number. b. Set the HISTSIZE to a smaller number. c. Set the NOHISTFILE variable to true. d. Set the HISTAPPEND variable to true. 320.In order to display the last five commands you have entered using the history command, you would type ___________.

321.In order to display the last five commands you have entered using the fc command, you would type ___________. 322.You previously ran the find command to locate a particular file. You want to run that command again. What would be the quickest way to do this? Choose one a. fc -l find fc n b. history -l find history n c. Retype the command d. fc -n find 323.Using command substitution, how would you display the value of the present working directory? Choose one a. echo $(pwd) b. echo pwd c. $pwd d. pwd | echo

324.You need to search the entire directory structure to locate a specific file. How could you do
this and still be able to run other commands while the find command is still searching for your file? Choose one a. find / -name filename & b. find / -name filename c. bg find / -name filename d. &find / -name filename & 325.In order to create a file called DirContents containing the contents of the /etc directory you would type ____________. 326.What would be displayed as the result of issuing the command ps ef? Choose one a. A listing of the users running processes formatted as a tree. b. A listing of the stopped processes c. A listing of all the running processes formatted as a tree. d. A listing of all system processes formatted as a tree. 327.What utility can you use to show a dynamic listing of running processes? __________ 328.The top utility can be used to change the priority of a running process? Another utility that can also be used to change priority is ___________? 329.What key combination can you press to suspend a running job and place it in the background? 330.You issue the command jobs and receive the following output: [1]- Stopped (tty output) pine [2]+ Stopped (tty output) MyScript How would you bring the MyScript process to the foreground? Choose one: a. fg %2 b. ctrl-c c. fg MyScript d. ctrl-z 331.You enter the command cat MyFile | sort > DirList & and the operating system displays [4] 3499 What does this mean? Choose one a. This is job number 4 and the PID of the sort command is 3499. b. This is job number 4 and the PID of the job is 3499. c. This is job number 3499 and the PID of the cat command is 4. d. This is job number 4 and the PID of the cat command is 3499. 332.You attempt to log out but receive an error message that you cannot. When you issue the jobs command, you see a process that is running in the background. How can you fix this so that you can logout? Choose one a. Issue the kill command with the PID of each running command of the pipeline as an argument. b. Issue the kill command with the job number as an argument. c. Issue the kill command with the PID of the last command as an argument. d. Issue the kill command without any arguments. 333.You have been given the job of administering a new server. It houses a database used by the sales people. This information is changed frequently and is not duplicated anywhere else. What should you do to ensure that this information is not lost? Choose one a. Create a backup strategy that includes backing up this information at least daily. b. Prepare a proposal to purchase a backup server c. Recommend that the server be made part of a cluster. d. Install an additional hard drive in the server.

334.When planning your backup strategy you need to consider how often you will perform a backup, how much time the backup takes and what media you will use. What other factor must you consider when planning your backup strategy? _________ 335.Many factors are taken into account when planning a backup strategy. The one most important one is how often does the file ____________. 336.Which one of the following factors does not play a role in choosing the type of backup media to use? Choose one: a. How frequently a file changes b. How long you need to retain the backup c. How much data needs to be backed up d. How frequently the backed up data needs to be accessed 337.When you only back up one partition, this is called a ______ backup. Choose one a. Differential b. Full c. Partial d. Copy 338.When you back up only the files that have changed since the last backup, this is called a ______ backup. Choose one a. Partial b. Differential c. Full d. Copy 339.The easiest, most basic form of backing up a file is to _____ it to another location. 340.When is the most important time to restore a file from your backup? Choose one a. On a regular scheduled basis to verify that the data is available. b. When the system crashes. c. When a user inadvertently loses a file. d. When your boss asks to see how restoring a file works. 341.As a system administrator, you are instructed to backup all the users home directories. Which of the following commands would accomplish this? Choose one a. tar rf usersbkup home/* b. tar cf usersbkup home/* c. tar cbf usersbkup home/* d. tar rvf usersbkup home/* 342.What is wrong with the following command? tar cvfb / /dev/tape 20 Choose one a. You cannot use the c option with the b option. b. The correct line should be tar -cvfb / /dev/tape20. c. The arguments are not in the same order as the corresponding modifiers. d. The files to be backed up have not been specified. 343.You need to view the contents of the tarfile called MyBackup.tar. What command would you use? __________ 344.After creating a backup of the users home directories called backup.cpio you are asked to restore a file called memo.ben. What command should you type? 345.You want to create a compressed backup of the users home directories so you issue the command gzip /home/* backup.gz but it fails. The reason that it failed is that gzip will only compress one _______ at a time. 346.You want to create a compressed backup of the users home directories. What utility should you use? 347.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. 348.Which two utilities can you use to set up a job to run at a specified time? Choose one: a. at and crond b. atrun and crontab c. at and crontab d. atd and crond 349.You have written a script called usrs to parse the passwd file and create a list of usernames. You want to have this run at 5 am tomorrow so you can see the results when you get to work. Which of the following commands will work? Choose one: a. at 5:00 wed usrs b. at 5:00 wed -b usrs c. at 5:00 wed -l usrs d. at 5:00 wed -d usrs

350.Several of your users have been scheduling large at jobs to run during peak load times. How can you prevent anyone from scheduling an at job? Choose one: a. delete the file /etc/at.deny b. create an empty file called /etc/at.deny c. create two empty files: /etc/at.deny and /etc/at.allow file d. create an empty file called /etc/at.allow 351.How can you determine who has scheduled at jobs? Choose one: a. at -l b. at -q c. at -d d. atwho 352.When defining a cronjob, there are five fields used to specify when the job will run. What are these fields and what is the correct order? Choose one: a. minute, hour, day of week, day of month, month b. minute, hour, month, day of month, day of week c. minute, hour, day of month, month, day of week d. hour, minute, day of month, month, day of week 353.You have entered the following cronjob. When will it run? 15 * * * 1,3,5 myscript Choose one: a. at 15 minutes after every hour on the 1st, 3rd and 5th of each month. b. at 1:15 am, 3:15 am, and 5:15 am every day c. at 3:00 pm on the 1st, 3rd, and 5th of each month d. at 15 minutes after every hour every Monday, Wednesday, and Friday 354.As the system administrator you need to review Bobs cronjobs. What command would you use? Choose one: a. crontab -lu bob b. crontab -u bob c. crontab -l d. cronq -lu bob 355.In order to schedule a cronjob, the first task is to create a text file containing the jobs to be run along with the time they are to run. Which of the following commands will run the script MyScript every day at 11:45 pm? Choose one: a. * 23 45 * * MyScript b. 23 45 * * * MyScript c. 45 23 * * * MyScript d. * * * 23 45 MyScript 356.Which daemon must be running in order to have any scheduled jobs run as scheduled? Choose one: a. crond b. atd c. atrun d. crontab 357.You want to ensure that your system is not overloaded with users running multiple scheduled jobs. A policy has been established that only the system administrators can create any scheduled jobs. It is your job to implement this policy. How are you going to do this? Choose one: a. create an empty file called /etc/cron.deny b. create a file called /etc/cron.allow which contains the names of those allowed to schedule jobs. c. create a file called /etc/cron.deny containing all regular usernames. d. create two empty files called /etc/cron.allow and /etc/cron.deny 358.You notice that your server load is exceptionally high during the hours of 10 am to 2 noon. When investigating the cause, you suspect that it may be a cron job scheduled by one of your users. What command can you use to determine if your suspicions are correct? Choose one: a. crontab -u b. crond -u c. crontab -l d. crond -l 359.One of your users, Bob, has created a script to reindex his database. Now he has it scheduled to run every day at 10:30 am. What command should you use to delete this job. Choose one: a. crontab -ru bob b. crontab -u bob c. crontab -du bob d. crontab -lu bob 360.What daemon is responsible for tracking events on your system? 361.What is the name and path of the default configuration file used by the syslogd daemon? 362.You have made changes to the /etc/syslog.conf file. Which of the following commands will cause these changes to be implemented without having to reboot your computer? Choose one: a. kill SIGHINT `cat /var/run/syslogd.pid` b. kill SIGHUP `cat /var/run/syslogd.pid` c. kill SIGHUP syslogd d. kill SIGHINT syslogd

363.Which of the following lines in your /etc/syslog.conf file will cause all critical messages to be logged to the file /var/log/critmessages? Choose one: a. *.=crit /var/log/critmessages b. *crit /var/log/critmessages c. *=crit /var/log/critmessages d. *.crit /var/log/critmessages 364.You wish to have all mail messages except those of type info to the /var/log/mailmessages file. Which of the following lines in your /etc/syslogd.conf file would accomplish this? Choose one: a. mail.*;mail!=info /var/log/mailmessages b. mail.*;mail.=info /var/log/mailmessages c. mail.*;mail.info /var/log/mailmessages d. mail.*;mail.!=info /var/log/mailmessages 365.What is the name and path of the main system log? 366.Which log contains information on currently logged in users? Choose one: a. /var/log/utmp b. /var/log/wtmp c. /var/log/lastlog d. /var/log/messages 367.You have been assigned the task of determining if there are any user accounts defined on your system that have not been used during the last three months. Which log file should you examine to determine this information? Choose one: a. /var/log/wtmp b. /var/log/lastlog c. /var/log/utmp d. /var/log/messages 368.You have been told to configure a method of rotating log files on your system. Which of the following factors do you not need to consider? Choose one: a. date and time of messages b. log size c. frequency of rotation d. amount of available disk space 369.What utility can you use to automate rotation of logs? 370.You wish to rotate all your logs weekly except for the /var/log/wtmp log which you wish to rotate monthly. How could you accomplish this. Choose one: a. Assign a global option to rotate all logs weekly and a local option to rotate the /var/log/wtmp log monthly. b. Assign a local option to rotate all logs weekly and a global option to rotate the /var/log/wtmp log monthly. c. Move the /var/log/wtmp log to a different directory. Run logrotate against the new location. d. Configure logrotate to not rotate the /var/log/wtmp log. Rotate it manually every month. 371.You have configured logrotate to rotate your logs weekly and keep them for eight weeks. You are running our of disk space. What should you do? Choose one: a. Quit using logrotate and manually save old logs to another location. b. Reconfigure logrotate to only save logs for four weeks. c. Configure logrotate to save old files to another location. d. Use the prerotate command to run a script to move the older logs to another location. 372.What command can you use to review boot messages? 373.What file defines the levels of messages written to system log files? 374.What account is created when you install Linux? 375.While logged on as a regular user, your boss calls up and wants you to create a new user account immediately. How can you do this without first having to close your work, log off and logon as root? Choose one: a. Issue the command rootlog. b. Issue the command su and type exit when finished. c. Issue the command su and type logoff when finished. d. Issue the command logon root and type exit when finished. 376.Which file defines all users on your system? Choose one: a. /etc/passwd b. /etc/users c. /etc/password d. /etc/user.conf 377.There are seven fields in the /etc/passwd file. Which of the following lists all the fields in the correct order? Choose one: a. username, UID, GID, home directory, command, comment b.

username, UID, GID, comment, home directory, command c. UID, username, GID, home directory, comment, command d. username, UID, group name, GID, home directory, comment 378.Which of the following user names is invalid? Choose one: a. Theresa Hadden b. thadden c. TheresaH d. T.H. 379.In order to prevent a user from logging in, you can add a(n) ________at the beginning of the password field. 380.The beginning user identifier is defined in the _________ file. 381.Which field is used to define the users default shell? 382.Bob Armstrong, who has a username of boba, calls to tell you he forgot his password. What command should you use to reset his command? 383.Your company has implemented a policy that users passwords must be reset every ninety days. Since you have over 100 users you created a file with each username and the new password. How are you going to change the old passwords to the new ones? Choose one: a. Use the chpasswd command along with the name of the file containing the new passwords. b. Use the passwd command with the -f option and the name of the file containing the new passwords. c. Open the /etc/passwd file in a text editor and manually change each password. d. Use the passwd command with the -u option.

384.How do you find out whats your shell? - echo $SHELL 385.Whats the command to find out todays date? - date 386.Whats the command to find out users on the system? - who 387.How do you find out the current directory youre in? - pwd 388.How do you remove a file? - rm 389.How do you remove a - rm -rf 390.How do you find out your own username? - whoami 391.How do you send a mail message to somebody? - mail [email protected] -s Your subject -c [email protected] 392.How do you count words, lines and characters in a file? - wc 393.How do you search for a string inside a given file? - grep string filename 394.How do you search for a string inside a directory? - grep string * 395.How do you search for a string in a directory with the subdirectories recursed? - grep -r string * 396.What are PIDs? - They are process IDs given to processes. A PID can vary from 0 to 65535. 397.How do you list currently running process? - ps 398.How do you stop a process? - kill pid 399.How do you find out about all running processes? - ps -ag 400.How do you stop all the processes, except the shell window? - kill 0 401.How do you fire a process in the background? - ./process-name &

402.How do you refer to the arguments passed to a shell script? - $1, $2 and so on. $0 is your script name. 403.Whats the conditional statement in shell scripting? - if {condition} then fi 404.How do you do number comparison in shell scripts? - -eq, -ne, -lt, -le, -gt, -ge 405.How do you test for file properties in shell scripts? - -s filename tells you if the file is not empty, -f filename tells you whether the argument is a file, and not a directory, -d filename tests if the argument is a directory, and not a file, -w filename tests for writeability, -r filename tests for readability, -x filename tests for executability 406.How do you do Boolean logic operators in shell scripting? - ! tests for logical not, -a tests for logical and, and -o tests for logical or. 407.How do you find out the number of arguments passed to the shell script? - $# 408.Whats a way to do multilevel if-elses in shell scripting? - if {condition} then {statement} elif {condition} {statement} fi 409.How do you write a for loop in shell? - for {variable name} in {list} do {statement} done 410.How do you write a while loop in shell? - while {condition} do {statement} done 411.How does a case statement look in shell scripts? - case {variable} in {possible-value-1}) {statement};; {possible-value-2}) {statement};; esac 412.How do you read keyboard input in shell scripts? - read {variablename} 413.How do you define a function in a shell script? - function-name() { #some code here return } 414.How does getopts command work? - The parameters to your script can be passed as -n 15 -x 20. Inside the script, you can iterate through the getopts array as while getopts n:x option, and the variable $option contains the value of the entered option.

415.ind : Is used to find a file in the directory or a file system 416.Usage: 417.1. find . -print //List all file in the current directory recursive 418.2. find . -name *.html -print // Find all file in the current directory with .html recursive 419.3. find . -mtime -7 -name *.html -print // Find all file which has been modified in last 7 days 420.4. find . -mtime 7 -name *.html -print // Find all file which has been exactly 7 days back 421.5. find . -mtime +7 -name *.html -print // Find all file which has not been modified in last 7 days 422.To find files in more than one directory through find command you can specify more than 1 directory at the start

423.for example: 424.6. find /usr /bin -name *\.htm* -print 425.To find file of specific type : 426.7. find . -type d -print //type d stands for directory 427.Below are the other type options in find command 428.d -Directory f File l Link 429.FIND COMMAND INTERVIEW QUESTIONS, FIND COMMAND USAGE, FIND COMMAND OPTIONS, WHY FIND COMMAND IS BEING USED UNIX FIND COMMAND 430.More find command examples : 431.find $HOME -mtime 0 // Find all files which has been modified in last 24 hours in your home directory 432.find $HOME -mtime +365 // Find all files which has not been modifed in last 365 days 433.find $HOME -newer ~joeuser/lastbatch.txt // Find all newer file in home directory which is newer than lastbatch.txt 434.More Linux find command options: 435.name: Finds files with certain naming conventions in the directory structure -ctime time interval Locates files that that were created during the specified time interval -mtime time interval Finds files that have been modified during the specified time interval -atime time interval Locates files that have been accessed during the specified time interval -perm permissions Locates files with certain permission settings -user Locates files that have specified ownership -group Locates files that are owned by specified group -size Locates files with specified size -type Locates a certain type of file 436.Why Shell Scripting? 437.Shell scripts can take input from a user or file and output them to the screen. Whenever you find yourself doing the same task over and over again you should use shell scripting i.e. repetitive task automation 438.* Creating your own power tools/utilities. * Automating command input or entry. * Customizing administrative task. * Creating simple applications. 439.Since scripts are well tested, the chances of errors are reduced while configuring services or system administration task such as adding new users. 440.Practical examples where shell scripting actively use System Administration / Database Administration/ Testing/ Automation /Data centers (SAN) etc.

441.* Monitoring your Linux system. * Data backup and creating snapshots. * Creating email based alert system. * Find out what processes are eating up your system resources. * Find out available and free memory. * Find out all logged in users and what they are doing. * User administration as per your own security policies. * Find out the name of the MP3 file you are listening to. * Monitor your domain expiry date every day. 442.FAQs 443.What is Shell? 444.SHELL is a command line Interpreter, Interface between User and Kernel. 445.# Admin prompt $User prompt 446.What is a command used to monitor the tasks running? #top 447.What is the command to know the current shell? # echo $SHELL $ echo $SHELL 448.What are the commands to see the content of zipped files? #/$ls File.gz sample #/$zcat File.gz to see the contents of File.gz #/$cat sampleto see the contents of file sample 449.Command to know the type of files? 450.#/$file * ->Displays all files and its types #/$file filename -> Displays specified file name
1. How do you find out the current directory you are in?

pwd

2. How do you find out what's your shell?

echo $SHELL ps

3. How do you list currently running process?

4. How do you stop a process?

kill pid kill 0 who

5. How do you stop all the processes, except the shell window?

6. What's the command to find out users on the system?

7. How do you count words, lines and characters in a file?

wc filename

8. What's the command to find out today's date?

date
9. How do you find out your own username?

whoami
10. How do you remove a file?

rm filename
11. How do you search for a string inside a given file?

grep string filename


12. How do you search for a string inside a directory?

grep string *
13. How do you search for a string in a directory with the subdirectories recursed?

grep -r string *

14. What's the conditional statement in shell scripting?

if {condition} then fi

15. How do you do number comparison in shell scripts?

-eq, -ne, -lt, -le, -gt, -ge ./process-name &

16. How do you fire a process in the background?

17. How do you refer to the arguments passed to a shell script?

$1, $2 and so on. $0 is your script name.

18. How do you find out the number of arguments passed to the shell script?

$#
19. How do you capture the return code?

$?
20. How do you know about running processes of a particular user?

ps -u username
2) State the advantages of Shell scripting? There are many advantages of shell scripting some of them are, one can develop their own operating system with relevant features best suited to their organization than to rely on costly operating systems. Software applications can be designed according to their platform. 3) What are the disadvantages of shell scripting? There are many disadvantages of shell scripting they are * Design flaws can destroy the entire process and could prove a costly error. * Typing errors during the creation can delete the entire data as well as partition data. * Initially process is slow but can be improved. * Portbility between different operating system is a prime concern as it is very difficult to port scripts etc. 4) Explain about the slow execution speed of shells? Major disadvantage of using shell scripting is slow execution of the scripts. This is because for every command a new process needs to be started. This slow down can be resolved by

using pipeline and filter commands. A complex script takes much longer time than a normal script. 5) Give some situations where typing error can destroy a program? There are many situations where typing errors can prove to be a real costly effort. For example a single extra space can convert the functionality of the program from deleting the sub directories to files deletion. cp, cn, cd all resemble the same but their actual functioning is different. Misdirected > can delete your data.

Coding Related Shell Scripting Interview Questions ...


6) Explain about return code? Return code is a common feature in shell programming. These return codes indicate whether a particular program or application has succeeded or failed during its process. && can be used in return code to indicate which application needs to be executed first. 7) What are the different variables present in Linux shell? Variables can be defined by the programmer or developer they specify the location of a particular variable in the memory. There are two types of shells they are System variables and user defined variables. System variables are defined by the system and user defined variables are to be defined by the user (small letters). 8) Explain about GUI scripting? Graphical user interface provided the much needed thrust for controlling a computer and its applications. This form of language simplified repetitive actions. Support for different applications mostly depends upon the operating system. These interact with menus, buttons, etc.

Shell Scripting Command Interview Questions ...


9) Explain about echo command? Echo command is used to display the value of a variable. There are many different options give different outputs such as usage \c suppress a trailing line, \r returns a carriage line, -e enables interpretation, \r returns the carriage. 10) Explain about Stdin, Stdout and Stderr? These are known as standard input, output and error. These are categorized as 0, 1 and 2. Each of these functions has a particular role and should accordingly functions for efficient output. Any mismatch among these three could result in a major failure of the shell. 11) Explain about sourcing commands? Sourcing commands help you to execute the scripts within the scripts. For example sh command makes your program to run as a separate shell. .command makes your program to run within the shell. This is an important command for beginners and for special purposes. 12) Explain about debugging? Shell can make your debugging process easier because it has lots of commands to perform the function. For example sh ncommand helps you to perform debugging. It helps you to read the shell but not to execute it during the course. Similarly sh x command helps you by displaying the arguments and functions as they are executed. 13) Explain about Login shell? Login shell is very useful as it creates an environment which is very useful to create the default parameters. It consists of two files they are profile files and shell rc files. These files initialize the login and non login files. Environment variables are created by Login shell. 14) Explain about non-login shell files? The non login shell files are initialized at the start and they are made to run to set up variables. Parameters and path can be set etc are some important functions. These files can be

changed and also your own environment can be set. These functions are present in the root. It runs the profile each time you start the process. 15) Explain about shebang? Shebang is nothing but a # sign followed by an exclamation. This is visible at the top of the script and it is immediately followed by an exclamation. To avoid repetitive work each time developers use shebang. After assigning the shebang work we pass info to the interpreter. 16) Explain about the Exit command? Every program whether on UNIX or Linux should end at a certain point of time and successful completion of a program is denoted by the output 0. If the program gives an output other than 0 it defines that there has been some problem with the execution or termination of the problem. Whenever you are calling other function, exit command gets displayed. 17) Explore about Environment variables? Environment variables are set at the login time and every shell that starts from this shell gets a copy of the variable. When we export the variable it changes from an shell variable to an environment variable and these variables are initiated at the start of the shell.
Shell Scripting Interview Questions Part 1
Top of Form

User Rating:

/4
Rate vote com_content 1072

Poor
http://hotrecruiter

Best

Bottom of Form

Technical Interviews | Unix Q.What is shell scripting? A.Shell scripting is used to program command line of an operating system. Shell Scripting is also used to program the shell which is the base for any operating system. Shell scripts often refer to programming UNIX. Shell scripting is mostly used to program operating systems of windows, UNIX, Apple, etc. Also this script is used by companies to develop their own operating system with their own features. Q.State the advantages of Shell scripting? A.There are many advantages of shell scripting some of them are, one can develop their own operating system with relevant features best suited to their organization than to rely on costly operating systems. Software applications can be designed according to their platform. Q.What are the disadvantages of shell scripting? A.There are many disadvantages of shell scripting they are 1.Design flaws can destroy the entire process and could prove a costly error. 2.Typing errors during the creation can delete the entire data as well as partition data.

3.Initially process is slow but can be improved. 4.Portbility between different operating system is a prime concern as it is very difficult to port scripts etc. Q.Explain about the slow execution speed of shells? A.Major disadvantage of using shell scripting is slow execution of the scripts. This is because for every command a new process needs to be started. This slow down can be resolved by using pipeline and filter commands. A complex script takes much longer time than a normal script. Q.Give some situations where typing error can destroy a program? A.There are many situations where typing errors can prove to be a real costly effort. For example a single extra space can convert the functionality of the program from deleting the sub directories to files deletion. cp, cn, cd all resemble the same but their actual functioning is different. Misdirected > can delete your data. Q.Explain about return code? A.Return code is a common feature in shell programming. These return codes indicate whether a particular program or application has succeeded or failed during its process. && can be used in return code to indicate which application needs to be executed first. Q.What are the different variables present in Linux shell? A.Variables can be defined by the programmer or developer they specify the location of a particular variable in the memory. There are two types of shells they are System variables and user defined variables. System variables are defined by the system and user defined variables are to be defined by the user (small letters). Q.Explain about GUI scripting? A.Graphical user interface provided the much needed thrust for controlling a computer and its applications. This form of language simplified repetitive actions. Support for different applications mostly depends upon the operating system. These interact with menus, buttons, etc. Q.Explain about echo command? A.Echo command is used to display the value of a variable. There are many different options give different outputs such as usage \c suppress a trailing line, \r returns a carriage line, -e enables interpretation, \r returns the carriage.

Q.How do you stop a process? - kill pid Q.How do you find out about all running processes? A.- ps -ag

Q.How do you stop all the processes, except the shell window? A.- kill 0 Q.How do you fire a process in the background? A.- ./process-name & Q.How do you refer to the arguments passed to a shell script? A.- $1, $2 and so on. $0 is your script name. Q.Whats the conditional statement in shell scripting? A.- if {condition} then fi Q.How do you do number comparison in shell scripts? A.- -eq, -ne, -lt, -le, -gt, -ge Q.How do you test for file properties in shell scripts? A.- -s filename tells you if the file is not empty, -f filename tells you whether the argument is a file, and not a directory, -d filename tests if the argument is a directory, and not a file, -w filename tests for writeability, -r filename tests for readability, -x filename tests for executability. Q.How do you do Boolean logic operators in shell scripting? A.- ! tests for logical not, -a tests for logical and, and -o tests for logical or. Q.How do you find out the number of arguments passed to the shell script? A.- $# Q.Whats a way to do multilevel if-elses in shell scripting? A.- if {condition} then {statement} elif {condition} {statement} fi Q.How do you write a for loop in shell? A.- for {variable name} in {list} do {statement} done Q.How do you write a while loop in shell? A.- while {condition} do {statement} done Q.How does a case statement look in shell scripts? A.- case {variable} in {possible-value-1}) {statement};; {possible-value-2}) {statement};; esac Q.How do you read keyboard input in shell scripts? A.- read {variable-name} Q.How do you define a function in a shell script? A.- function-name() { #some code here return }

Q.How does getopts command work? A.- The parameters to your script can be passed as -n 15 -x 20. Inside the script, you can iterate through the getopts array as while getopts n:x option, and the variable $option contains the value of the entered option. Q.What is $*? A.Its mainly used for showing up all params. This show all parameter values passed in shell script Q.What does $# stand for? A.# will return the number of parameters that are passed as the command-line arguments. Q.What does $? Return? A.$? will return exit status of command .0 if command gets successfully executed ,non-zero if command failed. Q.What are Different types of shells? A. 1.sh : the oldest shell 2.csh : C shell 3.ksh : Korn Shell 4.bash : bourne again shell Q.How do you read arguments in a shell program $1, $2? A.Shell script accepts parameters in following format 1.$1 would be the first command line argument, $2 the second, and so on 2.$0 is the name of the script or function If your script has more than 9 params then accept in following way ${12} : 12th param ${18} : 18th param. Q.If you have a string one two three, which shell command would you use to extract the strings? A. 1.echo $string | cut -d -f1 2.echo $string | cut -d -f2 3.echo $string | cut -d -f3

35. What is a Region? Ans: A Region is a continuous area of a processs address space (such as text, data and stack). The kernel in a Region Table that is local to the process maintains region. Regions are sharable among the process. 36. What are the events done by the Kernel after a process is being swapped out from the main memory? Ans: When Kernel swaps the process out of the primary memory, it performs the following:

Kernel decrements the Reference Count of each region of the process. If the reference count becomes zero, swaps the region out of the main memory,Kernel allocates the space for the swapping process in the swap device,Kernel locks the other swapping process while the current swapping operation is going on,The Kernel saves the swap address of the region in the region table. 37. Is the Process before and after the swap are the same? Give reason. Ans: Process before swapping is residing in the primary memory in its original form. The regions (text, data and stack) may not be occupied fully by the process, there may be few empty slots in any of the regions and while swapping Kernel do not bother about the empty slots while swapping the process out. After swapping the process resides in the swap (secondary memory) device. The regions swapped out will be present but only the occupied region slots but not the empty slots that were present before assigning. While swapping the process once again into the main memory, the Kernel referring to the Process Memory Map, it assigns the main memory accordingly taking care of the empty slots in the regions. 38. What do you mean by u-area (user area) or u-block? Ans: This contains the private data that is manipulated only by the Kernel. This is local to the Process, i.e. each process is allocated a u-area. 39. What are the entities that are swapped out of the main memory while swapping the process out of the main memory? Ans: All memory space occupied by the process, processs u-area, and Kernel stack are swapped out, theoretically. Practically, if the processs u-area contains the Address Translation Tables for the process then Kernel implementations do not swap the u-area. 40. What is Fork swap? Ans: fork() is a system call to create a child process. When the parent process calls fork() system call, the child process is created and if there is short of memory then the child process is sent to the read-to-run state in the swap device, and return to the user state without swapping the parent process. When the memory will be available the child process will be swapped into the main memory. 41. What is Expansion swap? Ans: At the time when any process requires more memory than it is currently allocated, the Kernel performs Expansion swap. To do this Kernel reserves enough space in the swap device. Then the address translation mapping is adjusted for the new virtual address space but the physical memory is not allocated. At last Kernel swaps the process into the assigned space in the swap device. Later when the Kernel swaps the process into the main memory this assigns memory according to the new address translation mapping. 42. How the Swapper works? Ans: The swapper is the only process that swaps the processes. The Swapper operates only in the Kernel mode and it does not uses System calls instead it uses internal Kernel functions for swapping. It is the archetype of all kernel process. 43. What are the processes that are not bothered by the swapper? Give Reason. Ans: Zombie process: They do not take any up physical memory.Processes locked in memories that are updating the region of the process.Kernel swaps only the sleeping processes rather than the ready-to-run processes, as they have the higher probability of being scheduled than the Sleeping processes. 44. What are the requirements for a swapper to work? Ans: The swapper works on the highest scheduling priority. Firstly it will look for any sleeping process, if not found then it will look for the ready-to-run process for swapping. But the major requirement for the swapper to work the ready-to-run process must be core-resident for at least 2 seconds before swapping out. And for swapping in the process must have been

resided in the swap device for at least 2 seconds. If the requirement is not satisfied then the swapper will go into the wait state on that event and it is awaken once in a second by the Kernel. 45. What are the criteria for choosing a process for swapping into memory from the swap device? Ans: The resident time of the processes in the swap device, the priority of the processes and the amount of time the processes had been swapped out. 46. What are the criteria for choosing a process for swapping out of the memory to the swap device? Ans: The processs memory resident time,Priority of the process and the nice value. 47. What do you mean by nice value? Ans: Nice value is the value that controls {increments or decrements} the priority of the process. This value that is returned by the nice () system call. The equation for using nice value is: Priority = (recent CPU usage/constant) + (base- priority) + (nice value) Only the administrator can supply the nice value. The nice () system call works for the running process only. Nice value of one process cannot affect the nice value of the other process.
* To display a list of all manual pages containing the keyword "date", what command would you type? * What command will display the first several lines of a file called "junk"? == Users and permissions practicum == * Rig it so everything in the folder gets deleted tonight at 10pm. Every night at 10pm. == Local security == * How do you feel about `sudo`? * What's the difference between `telnet` and `ssh`? What's a good use for each? * How do you ensure your users have hard-to-guess passwords? == Filesystem == * What is the difference between a symbolic and hard link? When would you use each? * I have a file named `-fr`. How do I get rid of it? * Why did I just ask that question? * To partition or not? How? * What are RAID 0, 1, 5, 0+1? What level would you use for a web server and why? A database server? == `/etc` == * `ls -l /etc`. What is all this stuff? * You added a line to `/etc/aliases`, but it doesn't seem to be working. Why? * You've created a `zope` user to run Zope under. How do you secure it so someone doesn't guess its password, log in with it, and mess with stuff? * Bring up `/etc/passwd`. What is all this junk? * What are shadow passwords? == Processes == * How many processes are running on your machine right now? == Shells == * Name as many shells as you can.

* What's your favorite shell? Why? * Write a shell script to append "snork" to the file "test" but only if "test" already exists. * A user performed a `cd; chmod 644 .` before logging out. What problem occurs when he logs in the next time, and what level of privilege is required to correct the problem? == Startup == * Describe the boot process of your favorite Linux in as much detail as you can. * What are runlevels? == Social == * Describe an experience you had with a difficult user. * How do you keep up with current tools and practices? * How did you document your work at your last job so someone else could pick up where you left off? == Totally miscellaneous == * When debugging a core in gdb, what does the command `bt` give: core memory, heap usage, or calling stack? * A user complains the web site is slow. What do you do? == Apache == * How do you rig Apache to start up on boot? * Apache doesn't start up on boot, and the thing above checks out okay. How do you track down the problem? *To display a list of all manual pages containing the keyword "date", what command would you type? Code:
man -k date man -f date

Linux / UNIX: Getting help with man page * What command will display the first several lines of a file called "junk"? Code:
head junk man head

== Users and permissions practicum == * Rig it so everything in the folder gets deleted tonight at 10pm. Every night at 10pm. Set cronjob, see How do I add jobs to cron under Linux or UNIX oses? == Local security == * How do you feel about `sudo`? sudo allows a permitted user to execute a command as the superuser or another user. sudo is much better than su and you don't have to share root password

with other users/admin. Linux sudo Configuration * What's the difference between `telnet` and `ssh`? What's a good use for each? TELNET, by default, does not encrypt any data sent over the connection (including password, and so it is often practical to eavesdrop on the communications and use the password later for malicious purposes; SSH by default encrypt password and traffic. SSH is recommended for all use. * How do you ensure your users have hard-to-guess passwords? Set password policy, see Howto: Protect account against a password cracking attack Linux check passwords against a dictionary attack Linux Password Cracking: Explain unshadow and john commands ( john the ripper tool ) == Filesystem == * What is the difference between a symbolic and hard link? When would you use each? How to: Linux / UNIX create soft link with ln command Understanding UNIX / Linux symbolic (soft) and hard links * I have a file named `-fr`. How do I get rid of it? Code:
rm -- -fr rm \-rf

How to: Linux / UNIX Delete or Remove Files With Inode Number * Why did I just ask that question? For testing UNIX concepts and command line args. * To partition or not? How? Sure. See The importance of Linux partitions * What are RAID 0, 1, 5, 0+1? What level would you use for a web server and why? A database server? See level @ What are the different RAID levels for Linux / UNIX and Windows Server? More about RAID - Can RAID Act As The Reliable BACKUP Solution For Linux / UNIX / Windows Server?

Linux Check The Health of Adaptec RAID array == `/etc` == * `ls -l /etc`. What is all this stuff? See, Linux / UNIX - Display the permissions of a file * You added a line to `/etc/aliases`, but it doesn't seem to be working. Why? Restart sendmail so that file get updated. The program "newaliases" must be run after this file is updated for any changes to show through to sendmail / postfix. Code:
newaliases

* You've created a `zope` user to run Zope under. How do you secure it so someone doesn't guess its password, log in with it, and mess with stuff? Deny login access to zope and set shell to /sbin/nologin. There are other ways too... * Bring up `/etc/passwd`. What is all this junk? See, Understanding /etc/passwd file format * What are shadow passwords? /etc/shadow file stores actual password in encrypted format for user's account with additional properties related to user password Understanding /etc/ shadow file == Processes == * How many processes are running on your machine right now? Code:
top atop ps -e ps aux ps aux | wc -l man ps

== Shells == * Name as many shells as you can. Bourne shell (sh) Almquist shell (ash) Debian Almquist shell (dash) Bourne-Again shell (bash) Friendly interactive shell (fish) Korn shell (ksh) C shell (csh) TENEX C shell (tcsh) Es shell (e

esh (Unix) Easy Shell rc shell (rc) - shell for Plan 9 and Unix runscript The initial shell interpreter used to process startup scripts in Gentoo scsh (Scheme Shell) Stand-alone Shell (sash) Z shell (zsh) * What's your favorite shell? Why? bash - it rocks and feature rich. * Write a shell script to append "snork" to the file "test" but only if "test" already exists. Code:
[ -f test ] && echo "snork" >> test ||:

* A user performed a `cd; chmod 644 .` before logging out. What problem occurs when he logs in the next time, and what level of privilege is required to correct the problem? User will not able to login. A root user can this problem by resting permission cmod perm /home/user . is current directory .. parent directory

== Startup == * Describe the boot process of your favorite Linux in as much detail as you can. See redhat or any other distro doc * What are runlevels? The term runlevel refers to a mode of operation in one of the computer operating systems that implement Unix System V-style initialization. Conventionally, seven runlevels exist, numbered from zero to six, though up to ten, from zero to nine, may be used. Code:
man init man runlevel

== Social == * Describe an experience you had with a difficult user. * How do you keep up with current tools and practices? * How did you document your work at your last job so someone else could pick up where you left off? Use our social skillz == Totally miscellaneous ==

* When debugging a core in gdb, what does the command `bt` give: core memory, heap usage, or calling stack? Code:
man gdb Read gdb page

* A user complains the web site is slow. What do you do? Ask user to upgrade internet connection. If using windows ask to reboot windows .. LOL just kidding, google for slow apache problem. There could be zillions of causes == Apache == * How do you rig Apache to start up on boot? Code:
chkconfig httpd on

* Apache doesn't start up on boot, and the thing above checks out okay. How do you track down the problem? Code:
chkconfig httpd on httpd -t service httpd on netstat -tulpn | grep 80 tail -f /var/log/httpd/access_log tail -f /var/log/httpd/error_log

HTH

UNIX Shell Scripting


The following are the most likely basic interview questions that are asked by the interviewers. If you are going to be a UNIX Administrator, UNIX support personnel, Data Warehouse Developer on UNIX/LINUX platform, Oracle or Sybase Developer, or even a Database Administrator, You must know the answers to the following questions before appearing for an interview. Interview Questions: 1. Which Shells are available or installed on your system 2. Which file gets executed first when a user logs in 3. Display total number of users currently logged on. Do not display the list of users, Display the number only 4. Write a shell script to print "High Load" if more than 100 user are logged on to the system. 5. List the size of all files in /etc directory only of the size is more than 10MB 6. List the owner and the name of all files in /tmp directory and its sub-directories if the file permission is 777

7. Mention at least 2 differences between hard link and soft link 8. How many Oracle databases are currently running on the server 9. Which users have been assigned a bash as a login shell to them 10. List of users who have more that 5 sessions opened. 11. Move all files owned by user john under /home directory to /tmp. Move only those files whose size is more than 100MB 12. Configure your account in such a way that your home directory is automatically backup-ed up to /backup directory every time you logout. 13. Write a shell script to send an email to root if any filesystem is more than 80% full. 14. List out a PID, owner and the name of the process which is taking the highest amount of CPU. 15. List out a PID, owner and the name of the process which is taking the highest amount of RAM 16. How to start a job in background 17. How to bring a background job to foreground 18. How do you assign an output of a command to a variable 19. How to perform mathematical calculations in shell script usning bc 20. How to debug a shell script 21. How to read a file one line at a time 22. How to read a file one word at a time 23. How do you check if a command has been successfully completed or not 24. Write a while loop to print odd numbers. 25. How to automate the file transfer from one machine to another 26. What is the difference between kill -9 and kill commands 27. How to change your login shell 28. How to display line 4 till 10 from a file 29. How to change a word named "Bill" to "Bob" in a file. - vi not allowed 30. How to remove blank lines from a file. 31. Can you create a hard link across filesystems 32. What is the purpose of /dev/null file 33. If I run ls -z > /dev/null Will anything be displayed on the terminal. 34. How to capture stdout and stderr of a command to a same file 35. What is the difference between "wc -l /etc/passwd" and "wc -l < /etc/passwd 36. How to find out the OS kernel you are running 37. How to find out if your hardware supports 64 bit OS or not 38. What command will delete all 0 byte files from your home directory

39. What is the size of the internal hard-diskon your system 40. How to schedule a specific command to run every 5 minutes on 1st day of every month of the first financial quarter of a year. Assume that the financial year starts on 1st of April.

You might also like