Desired Profile for Linux Admins keep your self Updated

Installation, Configuration, Maintenance of OS ( Linux : RedHat, Suse )
Handling CVS and SVN for repository on Linux Platform.
Installation and troubleshooting of Oracle Database, Application Server ( Weblogic),

Apache, Tomcat etc. and Web servers
Shell sciprting skills to automate the backups.
Good Knowledge of NFS,NIS and File Systems.
Configuration of Services like FTP,Telnet, SSH, etc
Sound knowledge of Solaris .
Preferably RHCE Certified Engineer.
Installation, Configuration, Maintenance of OS ( Linux : RedHat,

Suse )
Handling CVS and SVN for repository on Linux Platform.
Installation and troubleshooting of Oracle Database, Application Server ( Weblogic),

Apache, Tomcat etc. and Web servers
Shell sciprting skills to automate the backups.
Good Knowledge of NFS,NIS and File Systems.
Configuration of Services like FTP,Telnet, SSH, etc
Sound knowledge of Solaris .
Preferably RHCE Certified Engineer.

DBA interview Questions

Here are some commonly asked DBA Interview Questions

1. How many memory layers are in the shared pool?

2. How do you find out from the RMAN catalog if a particular archive
log has been backed-up?

3. How can you tell how much space is left on a given file system and
how much space each of the file system’s subdirectories take-up?

4. Define the SGA and:
• How you would configure SGA for a mid-sized OLTP environment?
• What is involved in tuning the SGA?

5. What is the cache hit ratio, what impact does it have on
performance of an Oracle database and what is involved in tuning it?

6. Other than making use of the statspack utility, what would you
check when you are monitoring or running a health check on an Oracle
8i or 9i database?

7. How do you tell what your machine name is and what is its IP address?

8. How would you go about verifying the network name that the
local_listener is currently using?

9. You have 4 instances running on the same UNIX box. How can you
determine which shared memory and semaphores are associated with which
instance?

10. What view(s) do you use to associate a user’s SQLPLUS session with
his o/s process?

11. What is the recommended interval at which to run statspack
snapshots, and why?

12. What spfile/init. ora file parameter exists to force the CBO to
make the execution path of a given statement use an index, even if the
index scan may appear to be calculated as more costly?

13. Assuming today is Monday, how would you use the DBMS_JOB package
to schedule the execution of a given procedure owned by SCOTT to start
Wednesday at 9AM and to run subsequently every other day at
2AM.

14. How would you edit your CRONTAB to schedule the running of
/test/test.sh to run every other day at 2PM?

15. What do the 9i dbms_standard. sql_txt() and
dbms_standard. sql_text( ) procedures do?

16. In which dictionary table or view would you look to determine at
which time a snapshot or MVIEW last successfully refreshed?

17. How would you best determine why your MVIEW couldn’t FAST REFRESH?

18. How does propagation differ between Advanced Replication and
Snapshot Replication (read-only)?

19. Which dictionary view(s) would you first look at to
understand or get a high-level idea of a given Advanced Replication
environment?

20. How would you begin to troubleshoot an ORA-3113 error?

21. Which dictionary tables and/or views would you look at to diagnose
a locking issue?

22. An automatic job running via DBMS_JOB has failed. Knowing only
that “it’s failed”, how do you approach troubleshooting this issue?

23. How would you extract DDL of a table without using a GUI tool?

24. You’re getting high “busy buffer waits” - how can you find what’s
causing it?

25. What query tells you how much space a tablespace named “test” is
taking up, and how much space is remaining?

26. Database is hung. Old and new user connections alike hang on
impact. What do you do? Your SYS SQLPLUS session IS able to connect.

27. Database crashes. Corruption is found scattered among the file
system neither of your doing nor of Oracle’s. What database recovery
options are available? Database is in archive log mode.

28. Illustrate how to determine the amount of physical CPUs a Unix Box
possesses (LINUX and/or Solaris).

29. How do you increase the OS limitation for open files (LINUX and/or
Solaris)?

30. Provide an example of a shell script which logs into SQLPLUS as
SYS, determines the current date, changes the date format to include
minutes & seconds, issues a drop table command, displays the date
again, and finally exits.

31. Explain how you would restore a database using RMAN to Point in Time?

32. How does Oracle guarantee data integrity of data changes?

33. Which environment variables are absolutely critical in order to
run the OUI?

34. What SQL query from v$session can you run to show how many
sessions are logged in as a particular user account?

35. Why does Oracle not permit the use of PCTUSED with indexes?

36. What would you use to improve performance on an insert statement
that places millions of rows into that table?

37. What would you do with an “in-doubt” distributed transaction?

38. What are the commands you’d issue to show the explain plan for
“select * from dual”?

39. In what script is “snap$” created? In what script is
the “scott/tiger” schema created?

40. If you’re unsure in which script a sys or system-owned object is
created, but you know it’s in a script from a specific directory, what
UNIX command from that directory structure can you run to find your
answer?

41. How would you configure your networking files to connect to a
database by the name of DSS which resides in domain icallinc.com?

42. You create a private database link and upon
connection, fails with: ORA-2085: connects to . What is the problem?
How would you go about resolving this error?

43. I have my backup RMAN script called “backup_rman. sh”. I am on the
target database. My catalog username/password is rman/rman. My catalog
db is called rman. How would you run this shell script from the O/S
such that it would run as a background process?

44. Explain the concept of the DUAL table.

45. What are the ways tablespaces can be managed and how do they differ?

46. From the database level, how can you tell under which time zone a
database is operating?

47. What’s the benefit of “dbms_stats” over “analyze”?

48. Typically, where is the conventional directory structure chosen
for Oracle binaries to reside?

49. You have found corruption in a tablespace that contains static
tables that are part of a database that is in NOARCHIVE log mode. How
would you restore the tablespace without losing new data in the other
tablespaces?

50. How do you recover a datafile that has not been physically been
backed up since its creation and has been deleted. Provide syntax example.

Installing Oracle 9iR2 on RHEL4

> Version of Oracle certified for RHEL4 : 9.2.0.4
>
> Requirements for Installing Oracle 9iR2 on RHEL4
>
> Minimum Software Requirement:
>
> * Required OS Components
> - compat-db-4. 1.25-9
> - compat-gcc-32- 3.2.3-47. 3
> - compat-gcc-32- c++-3.2.3- 47.3
> - compat-oracle- rhel4-1.0- 3
> - compat-libcwait- 2.0-1
> - compat-libgcc- 296-2.96- 132.7.2
> - compat-libstdc+ +-296-2.96- 132.7.2
> - compat-libstdc+ +-33-3.2. 3-47.3
> - gnome-libs-1. 4.1.2.90- 44
> - gnome-libs-devel- 1.4.1.2.90- 44
> - libaio-devel- 0.3.102-1
> - libaio-0.3.102- 1
> - make-3.80-5
> - openmotif21- 2.1.30-11
> - xorg-x11-deprecated -libs-devel- 6.8.1-23. EL
> - xorg-x11-deprecated -libs-6.8. 1-23.EL
>
>
> The compat-oracle- rhel4-1.0- 3 and compat-libcwait- 2.0-1 packages are
available from Metalink Patch 4198954.
>
> Setting Oracle Environments
> As the oracle user execute the following commands:
>
> # Set the LD_ASSUME_KERNEL environment variable only for Red Hat 9,
> # RHEL AS 3, and RHEL AS 4 !!
> # Use the "Linuxthreads with floating stacks" implementation
instead of NPTL:
> export LD_ASSUME_KERNEL= 2.4.19 # for RHEL AS 4
>
> # Oracle Environment
> export ORACLE_BASE= /u01/app/ oracle
> export ORACLE_HOME= $ORACLE_BASE/ product/9. 2.0
> export ORACLE_SID=test
> export ORACLE_TERM= xterm
> # export TNS_ADMIN= Set if sqlnet.ora, tnsnames.ora, etc. are not
in $ORACLE_HOME/ network/admin
> export NLS_LANG=AMERICAN;
> export ORA_NLS33=$ORACLE_ HOME/ocommon/ nls/admin/ data
> LD_LIBRARY_PATH= $ORACLE_HOME/ lib:/lib: /usr/lib
> LD_LIBRARY_PATH= $LD_LIBRARY_ PATH:/usr/ local/lib
> export LD_LIBRARY_PATH
>
> # Set shell search paths
> export PATH=$PATH:$ ORACLE_HOME/ bin
> Starting runInstaller
> su - oracle
>
> $ echo $LD_ASSUME_KERNEL
>
> 2.4.19
>
> $ ./runInstaller
>
> - Welcome Screen: Click Next
>
> - Inventory Location: Click OK
>
> - Unix Group Name: Use "oinstall" and click Next
>
>
>
> When asked to run /tmp/orainstRoot. sh, run it before you click Continue
>
>
>
> - File Locations: Use default values
>
> - Available Products: Select "Oracle9i Database 9.2.0.4.0"
>
> - Installation Types: Select Custom since we only want to install
the software for now
>
> - Available Products: Click Next or add some more components.
>
> - Components Locations: Accept default values and click Next
>
> - Privileged Operating System Groups:
>
> I used the default values: OSDBA Group =
dba, OSOPER Group = dba
>
> - Create database: Select NO since we first need to patch
Oracle database software!
>
> - Summary: Start the Install
>
>
>
>
>
> ** IF THE FOLLOWING ERROR IS ENCOUNTERED AFTER RUNNING RUNINSTALLER:
> [oracle@localhost Disk1]$ ./runInstaller -paramFile
'/tmp/oraparam. ini'
> [oracle@localhost Disk1]$ Initializing Java Virtual Machine from
/tmp/OraInstall2008 -03-25_11- 33-36AM/jre/ bin/java. Please wait...
> Error occurred during initialization of VM
> Unable to load native library:
/tmp/OraInstall2008 -03-25_11- 33-36AM/jre/ lib/i386/ libjava.so: symbol
__libc_wait, version GLIBC_2.0 not defined in file libc.so.6 with link
time reference · Refer to Metalink Note:264178. 1to download
the Patch 3006854 . - unzip p3006854_9204_ LINUX.zip
> - login as the root user
> - set your current directory to the directory where the patch is
located.
> - sh rhel3_pre_install. sh You do need root privileges to run the
last command line. After the Installation has completed: Patching
Oracle9i R2 (9.2.0.4) on RH AS 4 Download the patch 3948480 (Oracle9i
Patch Set Release 2 (9.2.0.6) Patch Set 5) from
http://metalink. oracle.com and execute the following commands:
>
> su - oracle
>
> $ cp p3948480_9206_ LINUX.zip /tmp
>
> $ cd /tmp
>
> $ unzip p3948480_9206_ LINUX.zip
>
> Archive: p3948480_9206_ LINUX.zip
>
> creating: Disk1/
>
> creating: Disk1/stage/
>
> creating: Disk1/stage/ Patches/
>
> ...
>
>
> Now download the patch 4188455 from http://metalink. oracle.com.
> This patch is needed for launching the runInstaller that came with
the patch 3948480 we just downloaded above.
>
> su - oracle
>
> $ cp p4188455_10103_ LINUX.zip /tmp
>
> $ cd /tmp
>
> $ unzip p4188455_10103_ LINUX.zip
>
> Archive: p4188455_10103_ LINUX.zip
>
> inflating: oraparam.ini
>
> inflating: README.txt
>
> $
> The /tmp/oraparam. ini file will now be used for launching the
runInstaller that came with the patch 3948480.
>
> To patch the runInstaller itself, run:
>
> su - oracle
>
> $ echo $LD_ASSUME_KERNEL
>
> 2.4.19
>
> $ /tmp/Disk1/install/ runInstaller -paramFile /tmp/oraparam. ini
>
>
>
> - Welcome Screen: Click Next
>
> - File Locations: Use default values (in my example:
/tmp/Disk1/stage/ products. xml)
>
> - Available Products: Select "Oracle Universial Installer
10.1.0.3.0 !"
>
> - Summary: Click Install
>
> - At the end of the installation, you must exit runInstaller!
>
>
> Ensure that no Oracle processes are running:
>
> ps -ef | grep ora
>
>
> Now to patch Oracle9iR2, run:
>
> su - oracle
>
> $ echo $LD_ASSUME_KERNEL # it is important that this variable is set!
>
> 2.4.19
>
> $ /tmp/Disk1/install/ runInstaller -paramFile /tmp/oraparam. ini
>
>
>
> - Welcome Screen: Click Next
>
> - File Locations: Use default values (in my example:
/tmp/Disk1/stage/ products. xml)
>
> - Available Products: Select "Oracle 9iR2 Patchset 9.2.0.6.0"
>
> - Summary: Click Install
>
> When are asked to run root.sh, run it
before you click Continue
>
> - At the end of the installation, exit runInstaller.
>
>
>
>
> After the 9.2.0.6 patchset has been applied, download the patch
4190568 from http://metalink. oracle.com. Also, download the opatch
utility for release 10.1.0.2 (patch 2617419) from
http://metalink. oracle.com.
>
> To install opatch, run:
> su - oracle$ cp p2617419_10102_ GENERIC.zip /tmp$ cd /tmp$ unzip
p2617419_10102_ GENERIC.zip$ cp -a /tmp/OPatch/ $ORACLE_HOME
>
> To apply the 4190568 patch, run
> su - oracle$ unzip p4190568_9206_ LINUX.zip$ cd 4193454$ export
PATH=$PATH:$ ORACLE_HOME/ OPatch$ opatch apply
>
>
> Now you should be able to create a database with dbca:
>
> su - oracle
>
> dbca
> Let me know in case of any concerns.

What are the difference between Daemons in Unix and service processes in Windows?

both are same. daemons are the background processes in unix. similarly background processes in windows are called as service agents or service processes.

What are Shell Variables

shell variables are system environment variables.they include TERM,SHELL, MAIL the output of the shell variable we can see by typing the command $>echo $TERM ansi at the prompt.

Unix command to concatenate (attach) two strings?

echo $var1 $var2

Show the working directory of a process ?

pwdx Example: pwdx 1267

Set the Display automatically for the current new user ?

export DISPLAY=`eval ?who am i | cut -d"(" -f2 | cut -d")" -f1'`Here in above command, see single quote, double quote, grave ascent is used. Observe carefully.

Search for a sample string in particular files ?

grep .Debug. *.confHere grep uses the string .Debug. to search in all files with extension..conf. under current directory.

List the hidden files in current directory ?

ls -a1 | grep "^\."

List the files in current directory sorted by size ?

ls -l | grep ^- | sort -nr

List some Hot Keys for bash shell ?

Ctrl+l . Clears the Screen. Ctrl+r . Does a search in previously given commands in shell. Ctrl+u - Clears the typing before the hotkey. Ctrl+a . Places cursor at the beginning of the command at shell. Ctrl+e . Places cursor at the end of the command at shell. Ctrl+d . Kills the shell. Ctrl+z . Places the currently running process into background.

Is it possible to restrict incoming message?

yes its by using mesgbut the command is mesg n(to restrict incomming messge)mesg y(to allow messge)

Is it possible to count number char, line in a file; if so, How?

Yes,It is possible to count the words,lines,characters in a file.. In Unix,i used.. $wc -c filename -> for characters $wc -l filename ->for lines $wc -w filename ->for words

Is 'du' a command? If so, what is its use?

Yes, it stands for ?disk usage?. With the help of this command you can find the disk capacity and free space of the disk.du -k : returns the disk usage in KBs du -k : gives the d

. In Unix OS, what is the file server? (Asked by Silicon Magic Corp. people)

The file server is a machine that shares its disk storage and files with other machines on the network.

In Unix OS, what is the file server?

The file server is a machine that shares its disk storage and files with other machines on the network.

. If you have a string "one two three", which shell command would you use to extract the strings

echo $string | cut -d" " -f1 echo $string | cut -d" " -f2 echo $string | cut -d" " -f3 echo "one two three" | cut -d" " -f 1,2,3 or echo "one two three" | awk '{print $1 $2 $3}'

How would you remove a semaphore / shared memory whose owner processes have died?

ipcrm -sem id ; for semaphores ipcrm -shm id ; for shared mem

How would you create shared and dynamic libraries

Well shared libraries have 2 types 1) Static 2) Dynamic. u can create library by ar cr -o sharedobj.a file1.o file2.o while file1 and file2 are headfiles (obj) now put this sharedobj.a into /usr/lib directory

. How to terminate a process which is running and the specialty on command kill 0?

With the help of kill command we can terminate the process. Syntax: kill pid Kill 0 - kills all processes in your system except the login shell.

. How to switch to a super user status to gain privileges?

Use ?su? command. The system asks for password and when valid entry is made the user gains super user (admin) privileges.

How to sfind free space in unix/linux

on linuxfree -m will display free memory in MB 'df' and 'du' commands give the information about space.df -k df -h or df -Humanreadable gives human readable format of free space

How to see your server name

hostname

How to save man pages to a file ?

man | col .b > Example : man top | col .b > top_help.txt

How to know the date & time for . when script is executed ?

Add the following script line in shell script.eval echo "Script is executed at `date`" >> timeinfo.infHere, .timeinfo.inf. contains date & time details ie., when script is executed and history related to execution.

how to find free space in unix/linux

df -h on linuxfree -m will display free memory in MB 'df' and 'du' commands give the information about space.df -k the better command is df -h

How to create null file ?

cat /dev/null > filename1

How to create a blank file in unix

touch

How much space is used for users in kilobytes ?

quot -af

How many prompts are available in Unix / Linux

Unix/ Linux Supports four Prompts PS1, PS2, PS3, PS4 and you can also set them in .profile

. How many prompts are available in a UNIX system?

Two prompts, PS1 (Primary Prompt), PS2 (Secondary Prompt). Unix/ Linux Supports four Prompts PS1, PS2, PS3, PS4

. How is the command ?$cat file2 ? different from ?$cat >file2

The Commond $cat file in unix is used to display the content of the file and where as commond $cat >> file is to append the text to the end of the file without overwritting the information of the file. Incase if the file does not exist in the directory the commond will create a newfile in file system.

. How does the kernel differentiate device files and ordinary files?

Kernel checks 'type' field in the file's inode structure. device filles are of 2 types --- charcater device file and block device file type field in the file's inode structure b--- block device file c--- character device file

How do you see the number of processes running in the system

ps -ef

How do you know that how many commands can be stored in the buffer in one session?

type "env" command on the prompt and check HISTORY or BUFFER or HISTSIZE value

How do you kill the process

kill -9

How do you find out drive statistics ?

iostat -E

How do you debug a core dump

dbx-core-'exename' If you want to migrate a 32 bit application to a 64 bit os, what all would you check I am assuming the question is - port 32 bit appl to 64 bit os. This can a simple checklist of things one can check for - 1. Int, long will be 64 bits so care should be taken to see if there are any comparisons or allocations that assume a certain fixed amount of Memory 2. short is 32 bit and long long are 128 bit - conversion and assignment issues around mixing ints with longlongs / shorts and ints 3. ptr* is 64 bit, make sure things are properly aligned (in some OSes where alignment is a concern) 4. if the 32 appl has to run as is in a 64 bit machine then care should be taken to do so(coexistence of 32 and 64 bit application) 5. compilers and makefile issues should be handled

How do u determine disk usage?

The disk usage can be determined by using the command,du.THis command outputs the number of kilobytes used by each sub-directory.

. How Connect to a Database in Shell Programming?Please tell me Step by Step

To Connect to Oracle Database and Collect the data in to text file from the table.echo "Enter User Name "read nameecho "Enter passwd "stty -echoread passstty echoecho "Enter Detp no"read dnosqlplus -S $name@oracle/$pass< Suppose you are using db2 and ksh #!/usr/bin/ksh connect to :@ user using ----------------------------------- If u have profile and catalog then ---------------------------------- #!/usr/bin/ksh db2 connect to ----------------------------------- To run a sample proc .. use the below db2 ""

Give examples of how memory leaks can occur with c programs

A memory leak occurs when mem is allocated but never freed . leakes can b caused by using malloc() without using any free(). but leaks can also be caused if a pointer to dynamically allocated memory is delleted overwritten , it can be caused when allocated mem is overwritten accidentally

Explain the working of Virtual Memory.

Virtual memory like as a temparary storage areAnswer:It consists of page table.In this pages are divided into frames.It is a contingous memroy allocation.It is also called logical memory. Memory contents that appear to be in contiguous addresses, but are actually mapped to different physical memory locations by hardware action of the translation lookaside buffer (TLB) and page tables.

Explain the unix file system.

Basically there are 4 diiferent types of file systems in unix ,they are as follows 1.Device file 2.Directory fil. 3.FIFO 4.Regular file Unix:-There are two file system t.e exe1,exe2 Solaris:-Three types file system a)Disk base file system ufs(unix file system),HSFS(High sierra file system),PCFS,UFS(Universal file system) b)NFS(Network file system) c)Pseduo or vartual file system

Explain the steps that a shell follows while processing a command.

After the command line is terminated by the key, the shel goes ahead with processing the command line in one or more passes. The sequence is well defined and assumes the following order. Parsing: The shell first breaks up the command line into words, using spaces and the delimiters, unless quoted. All consecutive occurrences of a space or tab are replaced here with a single space. Variable evaluation: All words preceded by a $ are avaluated as variables, unless quoted or escaped. Command substitution: Any command surrounded by backquotes is executed by the shell which then replaces the standard output of the command into the command line. Wild-card interpretation: The shell finally scans the command line for wild-cards (the characters *, ?, [, ]). Any word containing a wild-card is replaced by a sorted list of filenames that match the pattern. The list of these filenames then forms the arguments to the command. PATH evaluation: It finally looks for the PATH variable to determine the sequence of directories it has to search in order to hunt for the command.

Explain the layered aspect of a UNIX system. What are the layers? What does it mean to say they are layers?

A UNIX system has essentially three main layers: ? The hardware ? The operating system kernel ? The user-level programs The kernel hides the system?s hardware underneath an abstract, high-level programming interface. It is responsible for implementing many of the facilities that users and user-level programs take for granted. The kernel assembles all of the following UNIX concepts from lower-level hardware features: ? Processes (time-sharing, protected address space) ? Signals and semaphores ? Virtual Memory (swapping, paging, and mapping) ? The filesystem (files, directories, namespace) ? Pipes and network connections (inter-process communication)

Explain difference between IPC mechanisms

ipc mechanisms are mianly 5 types
1.pipes:it is related data only send from one pipe output is giving to another pipe input to share resouses pipe are used drawback:itis only related process only communicated
2.message queues:message queues are un related process are also communicate with message queues drawback:user dont know which process curently works share memory:memory shared in distributed systems some memory wants to share some files that time it is use full semaphores semaphore is integer type and in semaphore resourses give coding like negetive value means process are wants to use perticular resource waiting only and 0 means no process is waiting and 1 means one resource is free and sockets:sockets also ipc it is comunicate clients and server with socket system calls connection oriented and connection less also PIPE: Only two related (eg: parent & child) processess can be communicated. Data reading would be first in first out manner. Named PIPE or FIFO : Only two processes (can be related or unrelated) can communicate. Data read from FIFO is first in first out manner. Message Queues: Any number of processes can read/write from/to the queue. Data can be read selectively. (need not be in FIFO manner) Shared Memory: Part of process's memory is shared to other processes. other processes can read or write into this shared memory area based on the permissions. Accessing Shared memory is faster than any other IPC mechanism as this does not involve any kernel level switching(Shared memory resides on user memory area). Semaphore: Semaphores are used for process synchronisation. This can't be used for bulk data transfer between processes.

Some small interview Questions

Q: How do you display your running kernel version? (Solaris, AIX, Linux)
A: Linux # uname –r , Solaris # showrev

Q: Which command do you use to display a table of running processes? (Solaris, AIX, Linux)
A: Linux # ps –ef and top , Solaris # prstat

Q: Which file do you modify to configure a domain name resolver? (Solaris, AIX, Linux)
A: Linux # /etc/resolv.conf , Solaris # /etc/resolv.conf

Q: Which file contains a list of locally defined hostnames and corresponding IP addresses? (Solaris, AIX, Linux)
A: Linux # /etc/hosts , Solaris # /etc/hosts and linked file /etc/inet/hosts

Q: How do you display a routing table? (Solaris, AIX, Linux)
A: Linux # ip route show or #netstat –nr or #route –n and Solaris # netstat –nr and #route -n

Q: Which command would you use to view partitions and their sizes on Solaris?
A: # df -kh

Q: Which OpenBoot command would you use to print/view OpenBoot environment variables on a SUN server?
A: #printenv

Q: What does ”ypwhich” command do? (Solaris, AIX, Linux)
A: # Will display NIS server to which client is connected to and which NIS Server is master for particular map specified with this command

Q: which command would you use to create an OS user on Solaris and Linux?
A: Linux # useradd and Solaris #useradd

Q: Which file contains passwords for local users on Solaris, Linux and on AIX?
A: Linux #/etc/shadow and Solaris # /etc/shadow

Q: Which command would you use to list partitions on Linux?
A: Linux # mount –l or # df -kh

Q: Which command/commands would you use to manage installed packages on RedHat Linux?
A: Linux # rpm

Q: What is the default port for SSH server?
A: 22

Q: Which command/commands would you use to manage installed packages on Solaris?
A: #pkginfo #pkgrm # pkgadd #pkgchk

Q: What command would you use to install an OS patch on Solaris?
A: #showrev –p and #patchadd -p

Q: Which Veritas command would you use to display a list of Veritas volumes?
A: # vxprint

Q: Which Veritas command would you use to display a list of disks on a system?
A: # vxdx list

Q: What is the main system configuration utility in AIX?
A:

Q: Which file has a list of filesystems to be mounted at boot time on Solaris, Linux and AIX?
A: Linux # /etc/fstab and Solaris #/etc/vfstab

Q: Which Veritas Cluster Server command would you use to display the status of a cluster and it’s resources?
A:

Q: Which command would you use to rename a disk for VMware Guest virtual machine on ESX server 3 storage volume?
A:

Q: Which command would use on VMware ESX 3 server to display virtual switch configuration?
A:



Q: Which Veritas Cluster Server command would you use to display the status of a cluster and it’s resources?
A: clustat and to manage the cluster configruation use clusvcadm

Q: Which command would you use to rename a disk for VMware Guest virtual machine on ESX server 3 storage volume?
A: the best way is clone vm to different datastore or in the same datastore with different name
vmkfstools -i \\vmfs\old_vm.vmdk \\vmfs\new_vm.vmdk
this will take care of it all

Q: Which command would use on VMware ESX 3 server to display virtual switch configuration?
A: esxcfg-vswitch -l or user esxcfg-vswitch -help to see all options

Access common commands quicker ?ps -ef | grep -i $@
Alternative for top command ?prstat –a
Change to a directory, which is having very long name ?
cd CDMA_3X_GEN*Here original directory name is . .CDMA_3X_GENERATION_DATAnswer:.
Delete blank lines in a file ?
cat sample.txt | grep -v ?^$? > new_sample.txt
Display disk usage in Kilobytes ?
du -k
Display Ethernet Address arp table ?
arp -a
Display the all files recursively with path under current directory ?
find . -depth -print
Display the Disk Usage of file sizes under each directory in currentDirectory ?
du -k * | sort .nr (or) du .k . | sort -nr
Display the files in the directory by file size ?
ls .ltr | sort .nr .k 5
Display the inter-process communication facility status ?
Ipcs

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

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)

How many processes are running on your machine right now?

Code:
top
atop
ps -e
ps aux
ps aux | wc -l
man ps

Please answer these questions

Comment your answers and win a  Linux Interview Kit  ( anonymous users have less chance of winning )

Explain Process management and related commands

Explain Memory management and related commands

What is Open Group standards?

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

What is SELinux?

Write a command to find all of the files which have been accessed within the last 10 days.

What is LILO?

What is Grub?

Explain the difference between LILO and Grub

What is NFS?

What is NAMED?

What is MySQLD?

What is mysql?

What is CVS?

Why You Shouldn't Use the root Login for everyday work?

Describe the default partition scheme in Redhat Linux?

Describe the default partition scheme in Solaris? What is the slice number?

Describe all default mount point?

What is boot block?

What is logical block?

Describe the process for adding a new hard disk to UNIX box?

Describe the process for adding a new hard disk to Linux box?

Describe the process for adding a new hard disk to Linux LVM to grow /home?

Explain one major difference between a regular file system and a journaling file system?

Define JFS

Define UFS

How do you lock and unlock user account / password?

Describe RPM and command to install / remove / update Linux system?

Explain difference between rpm and up2date command.

Explain difference between rpm and apt-get command.

Explain difference between rpm and yum command.

Describe usage for pkgadd, pkginfo and pkgchk command

How do you find files on UNIX or Linux system?

Explain /etc/rc3.d

Explain ntsysv or chkconfig command

How do you get rid of process if kill PID is not working for you?

What is the purpose of the command?
grep
sed
awk
ifconfig
netstat
df
du
prtvtoc
fdisk -l
umaks
getfacl
setfacl
sudo
fsck
probe-scsi
vmstat

Explain LVM
1) What is a superblock ?
2) What is a parity bit?
3) What is an inod?
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 ?

What are the services required for nfs, apache(http) and NIS?

What is the best way to check the status of any service?

What do you mean by parity in RAID and which RAID is useful now a days?

Explain Linux Boot process especially kernel and initrd.

Why we do have two commands useradd and adduser when their functialnality is same?

Comment your answers and win a  Linux Interview Kit  ( anonymous users have less chance of winning )

How do I add jobs to cron under Linux or UNIX os's?

Basic Interview Questions (Beginners) (62)

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 -

How Linux boots

As it turns out, there isn't much to the boot process:
1. A boot loader finds the kernel image on the disk, loads it into memory, and starts it.
2. The kernel initializes the devices and its drivers.
3. The kernel mounts the root filesystem.
4. The kernel starts a program called init.
5. init sets the rest of the processes in motion.
6. The last processes that init starts as part of the boot sequence allow you to log in.
Identifying each stage of the boot process is invaluable in fixing boot problems and understanding the system as a whole. To start, zero in on the boot loader, which is the initial screen or prompt you get after the computer does its power-on self-test, asking which operating system to run. After you make a choice, the boot loader runs the Linux kernel, handing control of the system to the kernel.
There is a detailed discussion of the kernel elsewhere in this book from which this article is excerpted. This article covers the kernel initialization stage, the stage when the kernel prints a bunch of messages about the hardware present on the system. The kernel starts init just after it displays a message proclaiming that the kernel has mounted the root filesystem:
VFS: Mounted root (ext2 filesystem) readonly.
Soon after, you will see a message about init starting, followed by system service startup messages, and finally you get a login prompt of some sort.
NOTE On Red Hat Linux, the init note is especially obvious, because it "welcomes" you to "Red Hat Linux." All messages thereafter show success or failure in brackets at the right-hand side of the screen.
Most of this chapter deals with init, because it is the part of the boot sequence where you have the most control.
init
There is nothing special about init. It is a program just like any other on the Linux system, and you'll find it in /sbin along with other system binaries. The main purpose of init is to start and stop other programs in a particular sequence. All you have to know is how this sequence works.
There are a few different variations, but most Linux distributions use the System V style discussed here. Some distributions use a simpler version that resembles the BSD init, but you are unlikely to encounter this.
Runlevels
At any given time on a Linux system, a certain base set of processes is running. This state of the machine is called its runlevel, and it is denoted with a number from 0 through 6. The system spends most of its time in a single runlevel. However, when you shut the machine down, init switches to a different runlevel in order to terminate the system services in an orderly fashion and to tell the kernel to stop. Yet another runlevel is for single-user mode, discussed later.
The easiest way to get a handle on runlevels is to examine the init configuration file, /etc/inittab. Look for a line like the following:
id:5:initdefault:

This line means that the default runlevel on the system is 5. All lines in the inittab file take this form, with four fields separated by colons occurring in the following order:
• # A unique identifier (a short string, such as id in the preceding example)
• The applicable runlevel number(s)
• The action that init should take (in the preceding example, the action is to set the default runlevel to 5)
• A command to execute (optional)
There is no command to execute in the preceding initdefault example because a command doesn't make sense in the context of setting the default runlevel. Look a little further down in inittab, until you see a line like this:
l5:5:wait:/etc/rc.d/rc 5
This line triggers most of the system configuration and services through the rc*.d and init.d directories. You can see that init is set to execute a command called /etc/rc.d/rc 5 when in runlevel 5. The wait action tells when and how init runs the command: run rc 5 once when entering runlevel 5, and then wait for this command to finish before doing anything else.
There are several different actions in addition to initdefault and wait, especially pertaining to power management, and the inittab(5) manual page tells you all about them. The ones that you're most likely to encounter are explained in the following sections.
respawn
The respawn action causes init to run the command that follows, and if the command finishes executing, to run it again. You're likely to see something similar to this line in your inittab file:
1:2345:respawn:/sbin/mingetty tty1

The getty programs provide login prompts. The preceding line is for the first virtual console (/dev/tty1), the one you see when you press ALT-F1 or CONTROL-ALT-F1. The respawn action brings the login prompt back after you log out.
ctrlaltdel
The ctrlaltdel action controls what the system does when you press CONTROL-ALT-DELETE on a virtual console. On most systems, this is some sort of reboot command using the shutdown command.
sysinit
The sysinit action is the very first thing that init should run when it starts up, before entering any runlevels.
How processes in runlevels start
You are now ready to learn how init starts the system services, just before it lets you log in. Recall this inittab line from earlier:
l5:5:wait:/etc/rc.d/rc 5
This small line triggers many other programs. rc stands for run commands, and you will hear people refer to the commands as scripts, programs, or services. So, where are these commands, anyway?
For runlevel 5, in this example, the commands are probably either in /etc/rc.d/rc5.d or /etc/rc5.d. Runlevel 1 uses rc1.d, runlevel 2 uses rc2.d, and so on. You might find the following items in the rc5.d directory:
S10sysklogd S20ppp S99gpm
S12kerneld S25netstd_nfs S99httpd
S15netstd_init S30netstd_misc S99rmnologin
S18netbase S45pcmcia S99sshd
S20acct S89atd
S20logoutd S89cron

The rc 5 command starts programs in this runlevel directory by running the following commands:
S10sysklogd start
S12kerneld start
S15netstd_init start
S18netbase start
...
S99sshd start

Notice the start argument in each command. The S in a command name means that the command should run in start mode, and the number (00 through 99) determines where in the sequence rc starts the command.
The rc*.d commands are usually shell scripts that start programs in /sbin or /usr/sbin. Normally, you can figure out what one of the commands actually does by looking at the script with less or another pager program.
You can start one of these services by hand. For example, if you want to start the httpd Web server program manually, run S99httpd start. Similarly, if you ever need to kill one of the services when the machine is on, you can run the command in the rc*.d directory with the stop argument (S99httpd stop, for instance).
Some rc*.d directories contain commands that start with K (for "kill," or stop mode). In this case, rc runs the command with the stop argument instead of start. You are most likely to encounter K commands in runlevels that shut the system down.
Adding and removing services
If you want to add, delete, or modify services in the rc*.d directories, you need to take a closer look at the files inside. A long listing reveals a structure like this:
lrwxrwxrwx . . . S10sysklogd -> ../init.d/sysklogd
lrwxrwxrwx . . . S12kerneld -> ../init.d/kerneld
lrwxrwxrwx . . . S15netstd_init -> ../init.d/netstd_init
lrwxrwxrwx . . . S18netbase -> ../init.d/netbase
...

The commands in an rc*.d directory are actually symbolic links to files in an init.d directory, usually in /etc or /etc/rc.d. Linux distributions contain these links so that they can use the same startup scripts for all runlevels. This convention is by no means a requirement, but it often makes organization a little easier.
To prevent one of the commands in the init.d directory from running in a particular runlevel, you might think of removing the symbolic link in the appropriate rc*.d directory. This does work, but if you make a mistake and ever need to put the link back in place, you might have trouble remembering the exact name of the link. Therefore, you shouldn't remove links in the rc*.d directories, but rather, add an underscore (_) to the beginning of the link name like this:
mv S99httpd _S99httpd

At boot time, rc ignores _S99httpd because it doesn't start with S or K. Furthermore, the original name is still obvious, and you have quick access to the command if you're in a pinch and need to start it by hand.
To add a service, you must create a script like the others in the init.d directory and then make a symbolic link in the correct rc*.d directory. The easiest way to write a script is to examine the scripts already in init.d, make a copy of one that you understand, and modify the copy.
When adding a service, make sure that you choose an appropriate place in the boot sequence to start the service. If the service starts too soon, it may not work, due to a dependency on some other service. For non-essential services, most systems administrators prefer numbers in the 90s, after most of the services that came with the system.
Linux distributions usually come with a command to enable and disable services in the rc*.d directories. For example, in Debian, the command is update-rc.d, and in Red Hat Linux, the command is chkconfig. Graphical user interfaces are also available. Using these programs helps keep the startup directories consistent and helps with upgrades.
HINT: One of the most common Linux installation problems is an improperly configured XFree86 server that flicks on and off, making the system unusable on console. To stop this behavior, boot into single-user mode and alter your runlevel or runlevel services. Look for something containing xdm, gdm, or kdm in your rc*.d directories, or your /etc/inittab.
Controlling init
Occasionally, you need to give init a little kick to tell it to switch runlevels, to re-read the inittab file, or just to shut down the system. Because init is always the first process on a system, its process ID is always 1.
You can control init with telinit. For example, if you want to switch to runlevel 3, use this command:
telinit 3
When switching runlevels, init tries to kill off any processes that aren't in the inittab file for the new runlevel. Therefore, you should be careful about changing runlevels.
When you need to add or remove respawning jobs or make any other change to the inittab file, you must tell init about the change and cause it to re-read the file. Some people use kill -HUP 1 to tell init to do this. This traditional method works on most versions of Unix, as long as you type it correctly. However, you can also run this telinit command:
telinit q
You can also use telinit s to switch to single-user mode.
Shutting down
init also controls how the system shuts down and reboots. The proper way to shut down a Linux machine is to use the shutdown command.
There are two basic ways to use shutdown. If you halt the system, it shuts the machine down and keeps it down. To make the machine halt immediately, use this command:
shutdown -h now
On most modern machines with reasonably recent versions of Linux, a halt cuts the power to the machine. You can also reboot the machine. For a reboot, use -r instead of -h.
The shutdown process takes several seconds. You should never reset or power off a machine during this stage.
In the preceding example, now is the time to shut down. This argument is mandatory, but there are many ways of specifying it. If you want the machine to go down sometime in the future, one way is to use +n, where n is the number of minutes shutdown should wait before doing its work. For other options, look at the shutdown(8) manual page.
To make the system reboot in 10 minutes, run this command:
shutdown -r +10
On Linux, shutdown notifies anyone logged on that the machine is going down, but it does little real work. If you specify a time other than now, shutdown creates a file called /etc/nologin. When this file is present, the system prohibits logins by anyone except the superuser.
When system shutdown time finally arrives, shutdown tells init to switch to runlevel 0 for a halt and runlevel 6 for a reboot. When init enters runlevel 0 or 6, all of the following takes place, which you can verify by looking at the scripts inside rc0.d and rc6.d:
1. init kills every process that it can (as it would when switching to any other runlevel).
• The initial rc0.d/rc6.d commands run, locking system files into place and making other preparations for shutdown.
• The next rc0.d/rc6.d commands unmount all filesystems other than the root.
• Further rc0.d/rc6.d commands remount the root filesystem read-only.
• Still more rc0.d/rc6.d commands write all buffered data out to the filesystem with the sync program.
• The final rc0.d/rc6.d commands tell the kernel to reboot or stop with the reboot, halt, or poweroff program.
The reboot and halt programs behave differently for each runlevel, potentially causing confusion. By default, these programs call shutdown with the -r or -h options, but if the system is already at the halt or reboot runlevel, the programs tell the kernel to shut itself off immediately. If you really want to shut your machine down in a hurry (disregarding any possible damage from a disorderly shutdown), use the -f option.

What are the process states in Unix?

As a process executes it changes state according to its circumstances. Unix processes have the following states:
Running : The process is either running or it is ready to run .
Waiting : The process is waiting for an event or for a resource.
Stopped : The process has been stopped, usually by receiving a signal.
Zombie : The process is dead but have not been removed from the process table.

What is a zombie?

When a program forks and the child finishes before the parent, the kernel still keeps some of its information about the child in case the parent might need it - for example, the parent may need to check the child's exit status. To be able to get this information, the parent calls `wait()'; In the interval between the child terminating and the parent calling `wait()', the child is said to be a `zombie' (If you do `ps', the child will have a `Z' in its status field to indicate this.)

How can a parent and child process communicate?

A parent and child can communicate through any of the normal inter-process communication schemes (pipes, sockets, message queues, shared memory), but also have some special ways to communicate that take advantage of their relationship as a parent and child. One of the most obvious is that the parent can get the exit status of the child.

How can you get/set an environment variable from a program?

Getting the value of an environment variable is done by using `getenv()'. Setting the value of an environment variable is done by using `putenv()'.

List the system calls used for process management

System calls Description
• fork() To create a new process
• exec() To execute a new program in a process
• wait() To wait until a created process completes its execution
• exit() To exit from a process execution
• getpid() To get a process identifier of the current process
• getppid() To get parent process identifier
• nice() To bias the existing priority of a process
• brk() To increase/decrease the data segment size of a process.

Explain fork() system call.

The `fork()' used to create a new process from an existing process. The new process is called the child process, and the existing process is called the parent. We can tell which is which by checking the return value from `fork()'. The parent gets the child's pid returned to him, but the child gets 0 returned to him.

What are various IDs associated with a process?

Unix identifies each process with a unique integer called ProcessID. The process that executes the request for creation of a process is called the 'parent process' whose PID is 'Parent Process ID'. Every process is associated with a particular user called the 'owner' who has privileges over the process. The identification for the user is 'UserID'. Owner is the user who executes the process. Process also has 'Effective User ID' which determines the access privileges for accessing resources like files.
• getpid() -process id
• getppid() -parent process id
• getuid() -user id
• geteuid() -effective user id

Brief about the initial process sequence while the system boots up.

While booting, special process called the 'swapper' or 'scheduler' is created with Process-ID 0. The swapper manages memory allocation for processes and influences CPU allocation. The swapper inturn creates 3 children:
• the process dispatcher,
• vhand and
• dbflush
with IDs 1,2 and 3 respectively.
This is done by executing the file /etc/init. Process dispatcher gives birth to the shell. Unix keeps track of all the processes in an internal data structure called the Process Table (listing command is ps -el).

What is a shell?

A shell is an interactive user interface to an operating system services that allows an user to enter commands as character strings or through a graphical user interface. The shell converts them to system calls to the OS or forks off a process to execute the command. System call results and other information from the OS are presented to the user through an interactive interface. Commonly used shells are sh,csh,ks etc.

How does the inode map to data block of a file?

Inode has 13 block addresses. The first 10 are direct block addresses of the first 10 data blocks in the file. The 11th address points to a one-level index block. The 12th address points to a two-level (double in-direction) index block. The 13th address points to a three-level(triple in-direction)index block. This provides a very large maximum file size with efficient access to large files, but also small files are accessed directly in one disk read.

Discuss the mount and unmount system calls

The privileged mount system call is used to attach a file system to a directory of another file system; the unmount system call detaches a file system. When you mount another file system on to your directory, you are essentially splicing one directory tree onto a branch in another directory tree. The first argument to mount call is the mount point, that is , a directory in the current file naming system. The second argument is the file system to mount to that point. When you insert a cdrom to your unix system's drive, the file system in the cdrom automatically mounts to /dev/cdrom in your system.

How do you create special files like named pipes and device files?

The system call mknod creates special files in the following sequence.
1. kernel assigns new inode,
2. sets the file type to indicate that the file is a pipe, directory or special file,
3. If it is a device file, it makes the other entries like major, minor device numbers.
For example:
If the device is a disk, major device number refers to the disk controller and minor device number is the disk.

What is a FIFO?

FIFO are otherwise called as 'named pipes'. FIFO (first-in-first-out) is a special file which is said to be data transient. Once data is read from named pipe, it cannot be read again. Also, data can be read only in the order written. It is used in interprocess communication where a process writes to one end of the pipe (producer) and the other reads from the other end (consumer).

What are links and symbolic links in UNIX file system?

A link is a second name (not a file) for a file. Links can be used to assign more than one name to a file, but cannot be used to assign a directory more than one name or link filenames on different computers.
Symbolic link 'is' a file that only contains the name of another file.Operation on the symbolic link is directed to the file pointed by the it.Both the limitations of links are eliminated in symbolic links.
Commands for linking files are:
Link ln filename1 filename2
Symbolic link ln -s filename1 filename2

How do you change File Access Permissions?

Every file has following attributes:
owner's user ID ( 16 bit integer )
owner's group ID ( 16 bit integer )
File access mode word
'r w x -r w x- r w x'

(user permission-group permission-others permission)
r-read, w-write, x-execute
To change the access mode, we use chmod(filename,mode).
Example 1:
To change mode of myfile to 'rw-rw-r–' (ie. read, write permission for user - read,write permission for group - only read permission for others) we give the args as:
chmod(myfile,0664) .
Each operation is represented by discrete values
'r' is 4
'w' is 2
'x' is 1

Therefore, for 'rw' the value is 6(4+2).
Example 2:
To change mode of myfile to 'rwxr–r–' we give the args as:
chmod(myfile,0744).

What are the Unix system calls for I/O?

• open(pathname,flag,mode) - open file
• creat(pathname,mode) - create file
• close(filedes) - close an open file
• read(filedes,buffer,bytes) - read data from an open file
• write(filedes,buffer,bytes) - write data to an open file
• lseek(filedes,offset,from) - position an open file
• dup(filedes) - duplicate an existing file descriptor
• dup2(oldfd,newfd) - duplicate to a desired file descriptor
• fcntl(filedes,cmd,arg) - change properties of an open file
• ioctl(filedes,request,arg) - change the behaviour of an open file
The difference between fcntl anf ioctl is that the former is intended for any open file, while the latter is for device-specific operations.

Brief about the directory representation in UNIX

A Unix directory is a file containing a correspondence between filenames and inodes. A directory is a special file that the kernel maintains. Only kernel modifies directories, but processes can read directories. The contents of a directory are a list of filename and inode number pairs. When new directories are created, kernel makes two entries named '.' (refers to the directory itself) and '..' (refers to parent directory).
System call for creating directory is mkdir (pathname, mode).

What is 'inode'?

All UNIX files have its description stored in a structure called 'inode'. The inode contains info about the file-size, its location, time of last access, time of last modification, permission and so on. Directories are also represented as files and have an associated inode. In addition to descriptions about the file, the inode contains pointers to the data blocks of the file. If the file is large, inode has indirect pointer to a block of pointers to additional data blocks (this further aggregates for larger files). A block is typically 8k.
Inode consists of the following fields:
• File owner identifier
• File type
• File access permissions
• File access times
• Number of links
• File size
• Location of the file data

How are devices represented in UNIX?

All devices are represented by files called special files that are located in/dev directory. Thus, device files and other files are named and accessed in the same way. A 'regular file' is just an ordinary data file in the disk. A 'block special file' represents a device with characteristics similar to a disk (data transfer in terms of blocks). A 'character special file' represents a device with characteristics similar to a keyboard (data transfer is by stream of bits in sequential order)