Showing posts with label Interview questions. Show all posts
Showing posts with label Interview questions. Show all posts

Thursday, December 10, 2009

Topics for Linux admin Job

 

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 , CONFIGFILES ,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.

And many more depending on your job profile. You should know each topics what you mentioned in your resume . If you are not sure about anything , don’t mention in your resume and your resume should reflect your skills.

Monday, September 21, 2009

Important linux commands used in real time scenarios..

This is a linux command line reference for common operations.

Examples marked with • are valid/safe to paste without modification into a terminal, so

you may want to keep a terminal window open while reading this so you can cut & paste.

All these commands have been tested both on Fedora and Ubuntu.

Command

Description

apropos whatis

Show commands pertinent to string. See also threadsafe

man -t man | ps2pdf - > man.pdf

make a pdf of a manual page

which command

Show full path name of command

time command

See how long a command takes

time cat

Start stopwatch. Ctrl-d to stop. See also sw

nice info

Run a low priority command (The "info" reader in this case)

renice 19 -p $$

Make shell (script) low priority. Use for non interactive tasks

dir navigation

cd -

Go to previous directory

cd

Go to $HOME directory

(cd dir && command)

Go to dir, execute command and return to current dir

pushd .

Put current dir on stack so you can popd back to it

file searching

alias l='ls -l --color=auto'

quick dir listing

ls -lrt

List files by date. See also newest and find_mm_yyyy

ls /usr/bin | pr -T9 -W$COLUMNS

Print in 9 columns to width of terminal

find -name '*.[ch]' | xargs grep -E 'expr'

Search 'expr' in this dir and below. See also findrepo

find -type f -print0 | xargs -r0 grep -F 'example'

Search all regular files for 'example' in this dir and below

find -maxdepth 1 -type f | xargs grep -F 'example'

Search all regular files for 'example' in this dir

find -maxdepth 1 -type d | while read dir; do echo $dir; echo cmd2; done

Process each item with multiple commands (in while loop)

find -type f ! -perm -444

Find files not readable by all (useful for web site)

find -type d ! -perm -111

Find dirs not accessible by all (useful for web site)

locate -r 'file[^/]*\.txt'

Search cached index for names. This re is like glob *file*.txt

look reference

Quickly search (sorted) dictionary for prefix

grep --color reference /usr/share/dict/words

Highlight occurances of regular expression in dictionary

archives and compression

gpg -c file

Encrypt file

gpg file.gpg

Decrypt file

tar -c dir/ | bzip2 > dir.tar.bz2

Make compressed archive of dir/

bzip2 -dc dir.tar.bz2 | tar -x

Extract archive (use gzip instead of bzip2 for tar.gz files)

tar -c dir/ | gzip | gpg -c | ssh user@remote 'dd of=dir.tar.gz.gpg'

Make encrypted archive of dir/ on remote machine

find dir/ -name '*.txt' | tar -c --files-from=- | bzip2 > dir_txt.tar.bz2

Make archive of subset of dir/ and below

find dir/ -name '*.txt' | xargs cp -a --target-directory=dir_txt/ --parents

Make copy of subset of dir/ and below

( tar -c /dir/to/copy ) | ( cd /where/to/ && tar -x -p )

Copy (with permissions) copy/ dir to /where/to/ dir

( cd /dir/to/copy && tar -c . ) | ( cd /where/to/ && tar -x -p )

Copy (with permissions) contents of copy/ dir to /where/to/

( tar -c /dir/to/copy ) | ssh -C user@remote 'cd /where/to/ && tar -x -p'

Copy (with permissions) copy/ dir to remote:/where/to/ dir

dd bs=1M if=/dev/sda | gzip | ssh user@remote 'dd of=sda.gz'

Backup harddisk to remote machine

rsync (Network efficient file copier: Use the --dry-run option for testing)

rsync -P rsync://rsync.server.com/path/to/file file

Only get diffs. Do multiple times for troublesome downloads

rsync --bwlimit=1000 fromfile tofile

Locally copy with rate limit. It's like nice for I/O

rsync -az -e ssh --delete ~/public_html/ remote.com:'~/public_html'

Mirror web site (using compression and encryption)

rsync -auz -e ssh remote:/dir/ . && rsync -auz -e ssh . remote:/dir/

Synchronize current directory with remote one

ssh (Secure SHell)

ssh $USER@$HOST command

Run command on $HOST as $USER (default command=shell)

ssh -f -Y $USER@$HOSTNAME xeyes

Run GUI command on $HOSTNAME as $USER

scp -p -r $USER@$HOST: file dir/

Copy with permissions to $USER's home directory on $HOST

ssh -g -L 8080:localhost:80 root@$HOST

Forward connections to $HOSTNAME:8080 out to $HOST:80

ssh -R 1434:imap:143 root@$HOST

Forward connections from $HOST:1434 in to imap:143

wget (multi purpose download tool)

(cd dir/ && wget -nd -pHEKk http://www.pixelbeat.org/cmdline.html)

Store local browsable version of a page to the current dir

wget -c http://www.example.com/large.file

Continue downloading a partially downloaded file

wget -r -nd -np -l1 -A '*.jpg' http://www.example.com/dir/

Download a set of files to the current directory

wget ftp://remote/file[1-9].iso/

FTP supports globbing directly

wget -q -O- http://www.pixelbeat.org/timeline.html | grep 'a href' | head

Process output directly

echo 'wget url' | at 01:00

Download url at 1AM to current dir

wget --limit-rate=20k url

Do a low priority download (limit to 20KB/s in this case)

wget -nv --spider --force-html -i bookmarks.html

Check links in a file

wget --mirror http://www.example.com/

Efficiently update a local copy of a site (handy from cron)

networking (Note ifconfig, route, mii-tool, nslookup commands are obsolete)

ethtool eth0

Show status of ethernet interface eth0

ethtool --change eth0 autoneg off speed 100 duplex full

Manually set ethernet interface speed

iwconfig eth1

Show status of wireless interface eth1

iwconfig eth1 rate 1Mb/s fixed

Manually set wireless interface speed

iwlist scan

List wireless networks in range

ip link show

List network interfaces

ip link set dev eth0 name wan

Rename interface eth0 to wan

ip link set dev eth0 up

Bring interface eth0 up (or down)

ip addr show

List addresses for interfaces

ip addr add 1.2.3.4/24 brd + dev eth0

Add (or del) ip and mask (255.255.255.0)

ip route show

List routing table

ip route add default via 1.2.3.254

Set default gateway to 1.2.3.254

tc qdisc add dev lo root handle 1:0 netem delay 20msec

Add 20ms latency to loopback device (for testing)

tc qdisc del dev lo root

Remove latency added above

host pixelbeat.org

Lookup DNS ip address for name or vice versa

hostname -i

Lookup local ip address (equivalent to host `hostname`)

whois pixelbeat.org

Lookup whois info for hostname or ip address

netstat -tupl

List internet services on a system

netstat -tup

List active connections to/from system

windows networking (Note samba is the package that provides all this windows specific networking support)

smbtree

Find windows machines. See also findsmb

nmblookup -A 1.2.3.4

Find the windows (netbios) name associated with ip address

smbclient -L windows_box

List shares on windows machine or samba server

mount -t smbfs -o fmask=666,guest //windows_box/share /mnt/share

Mount a windows share

echo 'message' | smbclient -M windows_box

Send popup to windows machine (off by default in XP sp2)

text manipulation (Note sed uses stdin and stdout. Newer versions support inplace editing with the -i option)

sed 's/string1/string2/g'

Replace string1 with string2

sed 's/\(.*\)1/\12/g'

Modify anystring1 to anystring2

sed '/ *#/d; /^ *$/d'

Remove comments and blank lines

sed ':a; /\\$/N; s/\\\n//; ta'

Concatenate lines with trailing \

sed 's/[ \t]*$//'

Remove trailing spaces from lines

sed 's/\([`"$\]\)/\\\1/g'

Escape shell metacharacters active within double quotes

seq 10 | sed "s/^/ /; s/ *\(.\{7,\}\)/\1/"

Right align numbers

sed -n '1000p;1000q'

Print 1000th line

sed -n '10,20p;20q'

Print lines 10 to 20

sed -n 's/.*<\/title>.*/\1/ip;T;q'

Extract title from HTML web page

sed -i 42d ~/.ssh/known_hosts

Delete a particular line

sort -t. -k1,1n -k2,2n -k3,3n -k4,4n

Sort IPV4 ip addresses

echo 'Test' | tr '[:lower:]' '[:upper:]'

Case conversion

tr -dc '[:print:]' < /dev/urandom

Filter non printable characters

history | wc -l

Count lines

set operations (Note you can export LANG=C for speed. Also these assume no duplicate lines within a file)

sort file1 file2 | uniq

Union of unsorted files

sort file1 file2 | uniq -d

Intersection of unsorted files

sort file1 file1 file2 | uniq -u

Difference of unsorted files

sort file1 file2 | uniq -u

Symmetric Difference of unsorted files

join -t'\0' -a1 -a2 file1 file2

Union of sorted files

join -t'\0' file1 file2

Intersection of sorted files

join -t'\0' -v2 file1 file2

Difference of sorted files

join -t'\0' -v1 -v2 file1 file2

Symmetric Difference of sorted files

math

echo '(1 + sqrt(5))/2' | bc -l

Quick math (Calculate φ). See also bc

echo 'pad=20; min=64; (100*10^6)/((pad+min)*8)' | bc

More complex (int) e.g. This shows max FastE packet rate

echo 'pad=20; min=64; print (100E6)/((pad+min)*8)' | python

Python handles scientific notation

echo 'pad=20; plot [64:1518] (100*10**6)/((pad+x)*8)' | gnuplot -persist

Plot FastE packet rate vs packet size

echo 'obase=16; ibase=10; 64206' | bc

Base conversion (decimal to hexadecimal)

echo $((0x2dec))

Base conversion (hex to dec) ((shell arithmetic expansion))

units -t '100m/9.58s' 'miles/hour'

Unit conversion (metric to imperial)

units -t '500GB' 'GiB'

Unit conversion (SI to IEC prefixes)

units -t '1 googol'

Definition lookup

seq 100 | (tr '\n' +; echo 0) | bc

Add a column of numbers. See also add and funcpy

calendar

cal -3

Display a calendar

cal 9 1752

Display a calendar for a particular month year

date -d fri

What date is it this friday. See also day

[ $(date -d "tomorrow" +%d) = "01" ] || exit

exit a script unless it's the last day of the month

date --date='25 Dec' +%A

What day does xmas fall on, this year

date --date='@2147483647'

Convert seconds since the epoch (1970-01-01 UTC) to date

TZ=':America/Los_Angeles' date

What time is it on West coast of US (use tzselect to find TZ)

echo "mail -s 'get the train' P@draigBrady.com < /dev/null" | at 17:45

Email reminder

echo "DISPLAY=$DISPLAY xmessage cooker" | at "NOW + 30 minutes"

Popup reminder

locales

printf "%'d\n" 1234

Print number with thousands grouping appropriate to locale

BLOCK_SIZE=\'1 ls -l

get ls to do thousands grouping appropriate to locale

echo "I live in `locale territory`"

Extract info from locale database

LANG=en_IE.utf8 locale int_prefix

Lookup locale info for specific country. See also ccodes

locale | cut -d= -f1 | xargs locale -kc | less

List fields available in locale database

recode (Obsoletes iconv, dos2unix, unix2dos)

recode -l | less

Show available conversions (aliases on each line)

recode windows-1252.. file_to_change.txt

Windows "ansi" to local charset (auto does CRLF conversion)

recode utf-8/CRLF.. file_to_change.txt

Windows utf8 to local charset

recode iso-8859-15..utf8 file_to_change.txt

Latin9 (western europe) to utf8

recode ../b64 <> file.b64

Base64 encode

recode /qp.. <> file.qp

Quoted printable decode

recode ..HTML <> file.html

Text to HTML

recode -lf windows-1252 | grep euro

Lookup table of characters

echo -n 0x80 | recode latin-9/x1..dump

Show what a code represents in latin-9 charmap

echo -n 0x20AC | recode ucs-2/x2..latin-9/x

Show latin-9 encoding

echo -n 0x20AC | recode ucs-2/x2..utf-8/x

Show utf-8 encoding

CDs

gzip < /dev/cdrom > cdrom.iso.gz

Save copy of data cdrom

mkisofs -V LABEL -r dir | gzip > cdrom.iso.gz

Create cdrom image from contents of dir

mount -o loop cdrom.iso /mnt/dir

Mount the cdrom image at /mnt/dir (read only)

cdrecord -v dev=/dev/cdrom blank=fast

Clear a CDRW

gzip -dc cdrom.iso.gz | cdrecord -v dev=/dev/cdrom -

Burn cdrom image (use dev=ATAPI -scanbus to confirm dev)

cdparanoia -B

Rip audio tracks from CD to wav files in current dir

cdrecord -v dev=/dev/cdrom -audio *.wav

Make audio CD from all wavs in current dir (see also cdrdao)

oggenc --tracknum='track' track.cdda.wav -o 'track.ogg'

Make ogg file from wav file

disk space (See also FSlint)

ls -lSr

Show files by size, biggest last

du -s * | sort -k1,1rn | head

Show top disk users in current dir. See also dutop

df -h

Show free space on mounted filesystems

df -i

Show free inodes on mounted filesystems

fdisk -l

Show disks partitions sizes and types (run as root)

rpm -q -a --qf '%10{SIZE}\t%{NAME}\n' | sort -k1,1n

List all packages by installed size (Bytes) on rpm distros

dpkg-query -W -f='${Installed-Size;10}\t${Package}\n' | sort -k1,1n

List all packages by installed size (KBytes) on deb distros

dd bs=1 seek=2TB if=/dev/null of=ext3.test

Create a large test file (taking no space). See also truncate

> file

truncate data of file or create an empty file

monitoring/debugging

tail -f /var/log/messages

Monitor messages in a log file

strace -c ls >/dev/null

Summarise/profile system calls made by command

strace -f -e open ls >/dev/null

List system calls made by command

ltrace -f -e getenv ls >/dev/null

List library calls made by command

lsof -p $$

List paths that process id has open

lsof ~

List processes that have specified path open

tcpdump not port 22

Show network traffic except ssh. See also tcpdump_not_me

ps -e -o pid,args --forest

List processes in a hierarchy

ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d'

List processes by % cpu usage

ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS

List processes by mem usage. See also ps_mem.py

ps -C firefox-bin -L -o pid,tid,pcpu,state

List all threads for a particular process

ps -p 1,2

List info for particular process IDs

last reboot

Show system reboot history

free -m

Show amount of (remaining) RAM (-m displays in MB)

watch -n.1 'cat /proc/interrupts'

Watch changeable data continuously

system information (see also sysinfo) ('#' means root access is required)

uname -a

Show kernel version and system architecture

head -n1 /etc/issue

Show name and version of distribution

cat /proc/partitions

Show all partitions registered on the system

grep MemTotal /proc/meminfo

Show RAM total seen by the system

grep "model name" /proc/cpuinfo

Show CPU(s) info

lspci -tv

Show PCI info

lsusb -tv

Show USB info

mount | column -t

List mounted filesystems on the system (and align output)

grep -F capacity: /proc/acpi/battery/BAT0/info

Show state of cells in laptop battery

#

dmidecode -q | less

Display SMBIOS/DMI information

#

smartctl -A /dev/sda | grep Power_On_Hours

How long has this disk (system) been powered on in total

#

hdparm -i /dev/sda

Show info about disk sda

#

hdparm -tT /dev/sda

Do a read speed test on disk sda

#

badblocks -s /dev/sda

Test for unreadable blocks on disk sda

interactive (see also linux keyboard shortcuts)

readline

Line editor used by bash, python, bc, gnuplot, ...

screen

Virtual terminals with detach capability, ...

mc

Powerful file manager that can browse rpm, tar, ftp, ssh, ...

gnuplot

Interactive/scriptable graphing

links

Web browser

xdg-open http://www.pixelbeat.org/

open a file or url with the registered desktop application

miscellaneous

alias hd='od -Ax -tx1z -v'

Handy hexdump. (usage e.g.: • hd /proc/self/cmdline | less)

alias realpath='readlink -f'

Canonicalize path. (usage e.g.: • realpath ~/../$USER)

set | grep $USER

Search current environment

touch -c -t 0304050607 file

Set file timestamp (YYMMDDhhmm)

python -m SimpleHTTPServer

Serve current directory tree at http://$HOSTNAME:8000/

source :http://www.pixelbeat.org/cmdline.html

Tuesday, September 15, 2009

Unix & Linux admin questions

1. How do you list the files in an UNIX directory while also showing hidden files?
2. How do you execute a UNIX command in the background?
3. What UNIX command will control the default file permissions when files are created?
4. Explain the read, write, and execute permissions on a UNIX directory.
5. What is the difference between a soft link and a hard link?
6. Give the command to display space usage on the UNIX file system.
7. Explain iostat, vmstat and netstat.
8. How would you change all occurrences of a value using VI?
9. Give two UNIX kernel parameters that effect an Oracle install
10. Briefly, how do you install Oracle software on UNIX.
11. What are the main differences between Apache 1.x and 2.x?
12. What does the “route” command do?
13. What are the read/write/execute bits on a directory mean?
14. What does iostat do?
15. what does vmstat do?
16. What does netstat do?
17. What is the most graceful way to bring a system into single user mode?
18. How do you determine disk usage?
19. What is AWK?
20. What is SED?
21. What is the difference between binaries in /bin, and /usr/bin?
22. What is a dynamically linked file?
23. What is a statically linked file?
24. How do you list the files in an UNIX directory while also showing hidden files? ls -ltra
25. How do you execute a UNIX command in the background? Use the “&”.
26. What UNIX command will control the default file permissions when files are created? umask
27. Explain the read, write, and execute permissions on a UNIX directory. Read allows you to see and list the directory contents. Write allows you to create, edit and delete files and subdirectories in the directory. Execute gives you the permissions to run programs or shells from the directory.
28. What is the difference between a soft link and a hard link? A symbolic (soft) linked file and the targeted file can be located on the same or different file system while for a hard link they must be located on the same file system.
29. Give the command to display space usage on the UNIX file system. df -lk
30. Explain iostat, vmstat and netstat. iostat reports on terminal, disk and tape I/O activity. vmstat reports on virtual memory statistics for processes, disk, tape and CPU activity. netstat reports on the contents of network data structures.
31. How would you change all occurrences of a value using VI? %s/(old value)/(new value)/g
32. Give two UNIX kernel parameters that effect an Oracle install. SHMMAX & SHMMNI
33. Briefly, how do you install Oracle software on UNIX? Basically, set up disks, kernel parameters, and run orainst.
34. Job Scheduling; mainly crontab, at, batch command
35. Backup stetegy; incremental, full system back up; diff between tar & ufsdump
36. diff between hard link & softlink
37. How to list only the directories inside a directory (Ans. ls -l|grep “^d”)
38. RAID levels; pros & cons of diffrent levels; what is RAID 1+0
39. How to recover a system whose root password has lost?
40. What is a daemon?
41. How to put a job in background & bring it to foreground?
42. What is default permissions for others in a file?
43. Questions on shell initialization scripts?
44. Questions on restricted shell
45. What is diff betwn grep & find?
46. What is egrep?
47. Questions on shell programming
48. What is a pipe?
49. Questions on Solaris patch management like pkgadd etc
50. Questions on file system creation; actually what happens when we create a file system?
51. Questions on RBAC? what is a role accound & what is a profile?
52. From command line how will you add a user account? the full command will all arguments.
53. Fs it advisable to put a swap partion in RAID1 (mirroring?) pros & cons?

Monday, September 14, 2009

Linux Interview Questions For software QA Engineers

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. Q. What metacharacter is used to do the following:
1.1 Move up one level higher in the directory tree structure
1.2 Specify all the files ending in .txt
1.3 Specify one character
1.4 Redirect input from a file
1.5 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 computer-
scp /etc/X11/xorg.conf alex@10.0.10.169:
52. Q. Please describe information below:
-rw-rw-r-- 1 dotpc dotpc 102 Jul 18 2003 file.buf
drwxr-xr-x 9 dotpc dotpc 4096 Oct 21 09:34 bin
lrwxrwxrwx 1 dotpc dotpc 20 Mar 21 15:00 client -> client-2.9.5
drwxrwxr-x 11 dotpc dotpc 4096 Sep 2 2005 client-2.8.9
drwxrwxr-x 7 dotpc dotpc 4096 Dec 14 12:13 data
drwxr-xr-x 12 dotpc dotpc 4096 Oct 21 09:41 docs
drwxr-xr-x 5 dotpc dotpc 4096 Dec 7 14:22 etc
drwxr-xr-x 11 dotpc dotpc 4096 Mar 21 15:54 client-2.9.5
-rw-r--r-- 1 dotpc dotpc 644836 Mar 22 09:53 client-2.9.5.tar.gz
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 cur-
rently active interfaces. If a single interface argument is given, it displays the status of the given interface only; if a single -a argu-
ment 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. 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. 3. 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.

Sunday, September 13, 2009

Linux admin interview questions

1. How do you take a single line of input from the user in a shell script?
2. Write a script to convert all DOS style backslashes to UNIX style slashes in a list of files.
3. Write a regular expression (or sed script) to replace all occurrences of the letter ‘f’, followed by any number of characters, followed by the letter ‘a’, followed by one or more numeric characters, followed by the letter ‘n’, and replace what’s found with the string “UNIX”.
4. Write a script to list all the differences between two directories.
5. Write a program in any language you choose, to reverse a file.
6. What are the fields of the password file?
7. What does a plus at the beginning of a line in the password file signify?
8. Using the man pages, find the correct ioctl to send console output to an arbitrary pty.
9. What is an MX record?
10. What is the prom command on a Sun that shows the SCSI devices?
11. What is the factory default SCSI target for /dev/sd0?
12. Where is that value controlled?
13. What happens to a child process that dies and has no parent process to wait for it and what’s bad about this?
14. What’s wrong with sendmail? What would you fix?
15. What command do you run to check file system consistency?
16. What’s wrong with running shutdown on a network?
17. What can be wrong with setuid scripts?
18. What value does spawn return?
19. Write a script to send mail from three other machines on the network to root at the machine you’re on. Use a ‘here doc’, but include in the mail message the name of the machine the mail is sent from and the disk utilization statistics on each machine?
20. Why can’t root just cd to someone’s home directory and run a program called a.out sitting there by typing “a.out”, and why is this good?
21. What is the difference between UDP and TCP?
22. What is DNS?
23. What does nslookup do?
24. How do you create a swapfile?
25. How would you check the route table on a workstation/server?
26. How do you find which ypmaster you are bound to?
27. How do you fix a problem where a printer will cutoff anything over 1MB?
28. What is the largest file system size in solaris? SunOS?
29. What are the different RAID levels?
30. Advantages/disadvantages of script vs compiled program.
31. Name a replacement for PHP/Perl/MySQL/Linux/Apache and show main differences.
32. Why have you choosen such a combination of products?
33. Differences between two last MySQL versions. Which one would you choose and when/why?
34. Main differences between Apache 1.x and 2.x. Why is 2.x not so popular? Which one would you choose and when/why?
35. Which Linux distros do you have experience with?
36. Which distro you prefer? Why?
37. Which tool would you use to update Debian / Slackware / RedHat / Mandrake / SuSE ?
38. You’re asked to write an Apache module. What would you do?
39. Which tool do you prefer for Apache log reports?
40. Your portfolio. (even a PHP guest book may work well)
41. What does ‘route’ command do?
42. Differences between ipchains and iptables.
43. What’s eth0, ppp0, wlan0, ttyS0, etc.
44. What are different directories in / for?
45. Partitioning scheme for new webserver. Why?
Unix/Linux administration interview questions
What is LILO?
LILO stands for Linux boot loader. It will load the MBR, master boot record, into the memory, and tell the system which partition and hard drive to boot from.
What is the main advantage of creating links to a file instead of copies of the file?
A: The main advantage is not really that it saves disk space (though it does that too) but, rather, that a change of permissions on the file is applied to all the link access points. The link will show permissions of lrwxrwxrwx but that is for the link itself and not the access to the file to which the link points. Thus if you want to change the permissions for a command, such as su, you only have to do it on the original. With copies you have to find all of the copies and change permission on each of the copies.
Write a command to find all of the files which have been accessed within the last 30 days.
find / -type f -atime -30 > December.files
This command will find all the files under root, which is ‘/’, with file type is file. ‘-atime -30′ will give all the files accessed less than 30 days ago. And the output will put into a file call December.files.
What is the most graceful way to get to run level single user mode?
A: The most graceful way is to use the command init s.
If you want to shut everything down before going to single user mode then do init 0 first and from the ok prompt do a boot -s.
What does the following command line produce? Explain each aspect of this line.
$ (date ; ps -ef | awk ‘{print $1}’ | sort | uniq | wc -l ) >> Activity.log
A: First let’s dissect the line: The date gives the date and time as the first command of the line, this is followed by the a list of all running processes in long form with UIDs listed first, this is the ps -ef. These are fed into the awk which filters out all but the UIDs; these UIDs are piped into sort for no discernible reason and then onto uniq (now we see the reason for the sort - uniq only works on sorted data - if the list is A, B, A, then A, B, A will be the output of uniq, but if it’s A, A, B then A, B is the output) which produces only one copy of each UID.
These UIDs are fed into wc -l which counts the lines - in this case the number of distinct UIDs running processes on the system. Finally the results of these two commands, the date and the wc -l, are appended to the file “Activity.log”. Now to answer the question as to what this command line produces. This writes the date and time into the file Activity.log together with the number of distinct users who have processes running on the system at that time. If the file already exists, then these items are appended to the file, otherwise the file is created.

 
Things You Should Know About Linux !!!