You are on page 1of 13

http://www.scribd.

com/doc/40556164/Linux-Interview-Questions-and-Answers

If you are preparing for interviews for linux admin jobs you should be familiar with below concepts.. 1) Port number of different servers {cat /etc/services} 2) Linux Installation(through FTP,HTTP,NFS) 3) Boot process 4) Diff b/w ext3 and ext2 5) RAID LEVELS and Selection of raid 6) backup methods 7) Package management such as Yum server 8) Kernel Tuning 9) IPTABLES 10) TCP WRAPPERS 11) DIFFERENT RUN LEVELS 12) USER AND GROUP MANAGEMENT 13) QUOTA SETTING(user and group) 14) DIFF B/W CRON AND AT 15) BASIC SHELL SCRIPTING 16) Troubleshooting different issues. 17) Tell me why we should hire you? 18) DAILY ACTIVITES IN YOUR CURRENT COMPANY 19) RECENTLY SOLVED CRITICAL ISSUE 20) LVM (Very Imp) 21) vertias Volume manager 22) cluster basic like HAD , GAB , LLT , HEARTBEAT , CONFIG FILES , RESOURSE , SERVICE GROUPS etc 23 ) kernel panic troubleshooting 24) Process management 25)Configuration part of NFS , NIS , Samba , DHCP , DNS,Apache, Sendmail etc. 26)Remote administration experience

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. Linux Interview Questions and Answers 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.

/etc/inittab 17) you want /dev/hda10 mounted whenever your system boots what you will do put the entry in fstab with proper drivers and mount point(/dev/hda10mount point ext2/3 defaults 0 0). 18) you want bind to be run at boot time ,which command you will use chkconfig. 19)which utility will give you information about running process at run time top command and ps -el. 20) you want to know if nfs package is installed on your system rpm -qa nfs and you can check export file in /etc. 21) what is the difference between rpm , yum and RHEN rpm required dependency software and yum can install automatically with dependancy 22) what is a proc directory /proc directory are not real files--they are hooks to look at information available to the kernel. 23) what is the difference between current directory and home directory home directory is one over which user have complete controland it is its default working directory when its logs in.while the current directory is the users current directorywhich may or may not be his home directory. 24)what is exit status in linux You can use $? to find out the exit status of command($ echo $?). 25)you have a dual boot system with windows XP and

Fedora Linux , you want to access windows partition which is on fat32 file system , what you will do ?? 1. Differences between TCP and UDP TCP

1)TCP -Transmission control protocol 2)TCP is a connection oriented protocol. 3)Three way handshake happens between client and server. 4)TCP is a reliable data transfer 5)slow transmission of data compare to UDP. 6)TCP is used to send file like database,where reliability play the first role UDP 1)UDP -User Datagram protocol 2)UDP is connectionless protocol 3)NO 3 way handshake 4)NOt a reliable data transer 5)Faster than TCP 6)used to send data like video,audio 1.DNS (Domian name server ) DNS resolves hostname to IP address (forward lookup), resolves IP address to hostname (reverse lookup), it allows machines to logically grouped by name domain, provides email routing. DNS port: 53 dameon: named Whatutility can you use toa uto m a te rotation of logs? Logrotate Any user who is listed in the /etc/shutdown.allow file will be able to run the shutdown command without being root. As the systema dministra tor you have created a directory containing some scripts that you have written. You want to have all your users to be able to run this scripts. Which file should you edit to ensure that the scripts will run without your users having to type the complete path to the script? Choose one: a. ~/.profile b. /etc/profile c. /etc/bash d. ~/.bash b. /etc/profile What are the files to be used in the network installation of linux os? /etc/sysconfig/network,/etc/resolv.conf,/etc/hosts : What is the command to see the installed rpm's in the linux system. you can view the installed rpm in your linux box by : rpm -qa | grep rpm name Please explain the file structure of linux? root - The home directory for the root user home - Contains the user's home directories along with directories for services ftp HTTP samba george bin - Commands needed during bootup that might be needed by normal users sbin - Like bin but commands are not intended for normal users. Commands run by LINUX. proc - This filesystem is not on a disk. It is a virtual filesystem that exists in the kernels imagination which is

memory. 1 - A directory with info about process number 1. Each process has a directory below proc. usr - Contains all commands, libraries, man pages, games and static files for normal operation. bin - Almost all user commands. some commands are in /bin or /usr/local/bin. sbin - System admin commands not needed on the root filesystem. e.g., most server programs. include - Header files for the C programming language. Should be below /user/lib for consistency. lib - Unchanging data files for programs and subsystems local - The place for locally installed software and other files. man - Manual pages info - Info documents doc - Documentation tmp X11R6 - The X windows system files. There is a directory

- enforce standards (no forged headers, etc.) - enforce filtering (SpamAssassin, etc.) - may modify messages (section 8 of RFC) http://en.wikipedia.org/wiki/List_of_mail_servers#Mail_filtering Q: Briefly describe the function of a mail system MSA. MTA - Mail Transfer Agent (mail server, mail exchange server) "A process which conforms to [SMTP-MTA], which acts as an SMTP server to accept messages from an MSA or another MTA, and either delivers them or acts as an SMTP client to relay them to another MTA." http://en.wikipedia.org/wiki/Mail_transfer_agent "It receives messages from another MTA (relaying), a mail submission agent (MSA) that itself got the mail from a mail user agent (MUA), or directly from an MUA, thus acting as an MSA itself. The MTA works behind the scenes, while the user usually interacts with the MUA.The delivery of e-mail to a user's mailbox typically takes place via a mail delivery agent (MDA); many MTAs have basic MDA functionality built in, but a dedicated MDA like procmail can provide more sophistication." - transfers email between machines (other MTAs) via SMTP - Internet-facing, open ports: security issues - sendmail, postfix, qmail, exim - may have MDA ability to transfer email to user's mailbox http://en.wikipedia.org/wiki/List_of_mail_servers#SMTP Q: Briefly describe the function of a mail system MTA. MDA - Mail Delivery Agent http://en.wikipedia.org/wiki/Mail_delivery_agent "A Mail Delivery Agent (MDA) is software that accepts incoming email messages and distributes them to recipients' individual mailboxes (if the destination account is on the local machine), or forwards back to an SMTP server (if the destination is on a remote server). A mail delivery agent is not necessarily a mail transfer agent (MTA),

although on many systems the two functions are implemented by the same program." - Unix/Linux: /bin/mail, procmail Q: Briefly describe the function of a mail system MDA. MRA/MAA - Mail Retrieval Agent / Mail Access Agent http://tools.ietf.org/html/rfc1939- POP3 port 110 http://tools.ietf.org/html/rfc3501- IMAP-V4-R1 port 143 - often built-in to mail clients (MUAs) - can be stand-alone - e.g. fetchmail gets the mail; MUA reads mail from file system Q: Briefly describe the function of a mail system MRA/MAA. Mail server comparison ---------------------http://en.wikipedia.org/wiki/List_of_mail_servers - see comparison near bottom - PUSH protocols - sending email: MTA - SMTP - PULL protocols - reading email: MRA/MAA - POP3, IMAP MDAs write local mailboxes; they may not implement Internet protocols (unless they have to forward off-machine without benfit of an MTA). Single-user PCs often don't run separate MTA or MRA/MAA programs. Your chose of mail reader (e.g. Pine, Elm, Outlook) itself PULLs your incoming email from a remote server (acting as an MRA/MAA) and then PUSHes your outgoing email to the remote server (acting as an MTA). Q: What is the difference between a PUSH protocol and a PULL protocol? Q: T/F, SMTP is a PUSH protocol. Q: T/F, POP3 is a PUSH protocol. Q: T/F, HTTP is a PUSH protocol. A History of MTAs ----------------I. Incoming - delivering your incoming email via SMTP: * Sending email into Unix/Linux machines: Unix/Linux was traditionally multi-user and ran its own MTA (e.g. sendmail) that accepted incoming SMTP connections.Remote systems could use SMTP to drop off your email with your local MTA (sendmail), and the MTA would hand the email to an MDA (/bin/mail, procmail) to put it in your mailbox in the local file system.Your MUA (e.g. /usr/ucb/Mail) would read the mail from your inbox (no need for POP3 or IMAP in any MUA).There are a few different conventions for inbox formats so that many different MUAs can read your email, all without knowing POP or IMAP. - sendmail (running as root!) has had many security patches - the first Morris Internet worm (Nov 1988) used sendmail security holes - http://en.wikipedia.org/wiki/Morris_worm Q: Why don't many Unix MUAs need to know how to run POP or IMAP? Current single-user Unix/Linux PCs often have a local-only MTA that handles the sending and delivery of local on-machine email but doesn't accept SMTP from off-site.(Best to keep ports closed on Internet-facing machines!) On recent single-user Unix/Linux workstations, the MUAs mimic their

Windows counterparts and include MRA/MAA features.Your chosen MUA (e.g. Elm, Pine, Mutt) is responsible for fetching your email via POP3 or IMAP (this is an MRA/MAA function); or, you use an intermediate MRA/MAA program such as "fetchmail" and your MUA reads the mail out of the local file system after the MRA/MAA has put it there. - no Internet-facing MTA means fewer open ports and fewer attacks - don't run an Internet-facing MTA if you don't need it * Sending email into MS Windows machines (or not): Windows had (has?) no MTA - you can't send an email to a Windows PC using SMTP.Your personal Windows MUA has to fetch the email itself via POP3 or IMAP and keep a copy in the local file system. - no open ports for incoming email; no open mail port security issues * Note that MUAs that implement POP/IMAP typically store the email in the local file system in a format that only that MUA can handle. (Thunderbird can't use an Outlook mail folder, and vice-versa.) The concept of a common inbox format usable by different MUAs was lost. Q: T/F, the standards for inbox formats developed under Unix were adopted by MUAs on PCs, so that different MUAs can read the same inbox. II. Outgoing - sending your outgoing email via SMTP: * Unix/Linux machines have traditionally each had their own MTA (sendmail) that could directly deliver email on the Internet using MX record lookup. Every local Unix MUA would put email into a directory where the MTA (sendmail) would eventually pick it up and transfer it, retrying as necessary.No MUA needed to know how to do SMTP; only the MTA did that. You could optionally tell your machine's MTA not to send mail directly to its destination via SMTP over the Internet, but to use a remote "smart" MTA that could accept your outgoing email and figure out how to deliver it.(You have to use such a "smart" host here at Algonquin; since, you cannot connect to any off-campus SMTP servers.) The MTA on your machine would use SMTP to drop off the queued mail at the smart host, and the smart host would do the MX record lookup and final SMTP delivery. Since the local Unix MTAs were separately scheduled programs, you could queue email from a MUA into the file system even when your machine was not connected to the Internet.The MUA or local MTA would queue up your email in the file system until your MTA was finally able to make a connection to deliver it off-machine.(In the days of modems, the Internet connection was often made late at night when rates were lower.) Q: Why don't most Unix MUAs need to know SMTP?

1.) vi /etc/sysctl.conf # Controls IP packet forwarding net.ipv4.ip_forward = 1 save (:wq!) You should have a Two physical LAN card, if You have't two Lan cat. You have to creat virtual Lan card 2.) cp -arvf /etc/sysconfig/network-scripts/ifcfgeth0 /etc/sysconfig/network-scripts/ifcfg-eth0:1 3.) Set a diffrent Class IP in virtual Lan card 4.) start network service /etc/init.d/network restart what is the UID and GID of root user? Can a normal user can change the ownership of a file? what is the command to change ownership of a file? the root UID/GID is 0 (zero). which is why he can able to intervene in allnormal users files even though he don't had permission. A normal user will don't have the permission to change ownership of file. The command to change ownership is< chown user.user file > What u know abt tar Command? tar command is file archiving cmd and extracting cmd in linux. create tar -cvf /tmp/ram.tar /etc/passwd this command makes compress the /etc/passwd datas and stored in /tmp/ram.tar Extract tar -xvf /tmp/ram.tar extract the data in existing file is /tmp/ram.tar How do you read ext2/3 file system in windows? Using Software Winscp ,we can access Linux machine from Windows.it is an windows software. through SAMBA, we can share the linux partition or directory, for windows. How to monitor ports in a linux machine, with single command? netstat -anpc a:all listening ports and established connections n:numeric host:port values p:programs c:continuous monitor What is the status code 403,404 represented in apache server 403 represent forbidden error, means if files misses some selinux security context is missing. 404 represent that their is a cgi script missing or web pages missing. Difference between swap partition and swap file? Swap partition maintained seperate partition. same swap partition can be used in two OS within single machine. If system crashes their is a chance to recover itor may not be corrupt the partition. Less fragmented. where as swap file takes very less space. we can increase the space very easily, compared to swap partition. SWap file system fragmented.

If system crashes their is a huge chance to lost the swap file system. what is nis server? Network Information Services is well known as NIS server which is based on Linux and Unix environment network. NIS Server create the user name and password to share across the network for centralize authentication. The best thing is that passwords can change be changed on NIS server not on client desktop systems. How can I only see the first 14 lines of a file? head -n14 filename Compare between SYS V launched processes and Xinetd processes in Linux. Answer is based on RHEL SYS V processes xinetd processes 1) daemons (run in background) processes started on request 2) Managed by "service" Managed by "xinetd" daemon wrapper command 3) Script files in "/etc/rc.d" script files in /etc/xinetd.d directory directory what is the command to make a process to run in the foreground from background? Fg How to FTP user access other directory except his own home directory ? specify the user in /etc/vsftpd/user_list. then in /etc/vsftpd/vsftpd.conf,add userlist_deny=NO,,,, then restart d service......... set d selinux for the accessing home directory.......... what are the Linux-based security tools? . Clam AntiVirus It is an open source (GPL) anti-virus toolkit for UNIX, designed especially for e-mail scanning on mail gateways. 2. SpamAssassin It is a computer program released under the Apache License 2.0 used for e-mail spam filtering based on content-matching rules. 3. Chkrootkit is a powerful tool to scan your Linux server for trojans 4. rkhunter (Rootkit Hunter) is a Unix-based tool that scans for rootkits, backdoors and possible local exploits what is a command to display top 10 users who are using Huge Space? du -s /home/* | sort -nr |head -10 In which File is Static IP address given so that it becomes Permanent ? just go to system-config-network and type ip address or go vi /etc/sysconfig/network-scripts/ifcfg-eth0 edit in this file it will become permanent.

what are the features of Linux? The following feature of linux:Some of its features include: 1)Virtual memory, allowing the system to use disk room the same as RAM memory. 2)Networking with TCP/IP and other protocols. 3)Multiple user capability. 4)Protected mode so programs or user's can't access 5)unauthorized areas. 6)Shared libraries 7)True multitasking 8)X - A graphical user interface similar to windows, but supports remote sessions over a network. 9)Advanced server functionality:FTP server Telnet server BOOTP server DHCP server Samba server DNS server SNMP services Mail services Network file sharing much, much more... Support of filesystems that other operating systems use such as DOS (FAT), Windows95,98 (FAT32), Windows NT, 2000 (NTFS), Apple, minix, and others some one is asking my machine is slow what is your steps? The increase in the size of SWAP partition may show you the little effect in increasing the system speed and better run in Single user mode rather than GUI mode use top command, then check which process use the most resource and find the problem. Re-read all process #killall HUP use ps aux command and check which process is using much space and check is there any partition is going to be full disk check by df -HT command

You might also like