Unix Programming Questions & Answers

Explore model answers categorized by subjects like Java, HTML, DBMS, and more.

Unix Programming Questions & Answers

What is UNIX ?

Answer:
UNIX is an operating system that support multi-user and multi-tasking in a time sharing environment. Unix OS is used for both server and workstation.

What is the kernel in UNIX?

Answer:
Kernel is the name of Operating System in UNIX. It is the kernel Job to keep each process and user separate and to regulate to access the system hardware

What is the use of \'mkdir\' command?

Answer:
\"mkdir\" command is use to create directory.

Syntax- mkdir [option] <directory name>
Common option
-p    create parent directory
-m     access permission
Ex- % mkdir /home/frank/data
Or if your present working directory is /home/frank then
% mkdir data

What are directory navigation tools and their controls?

Answer:
Directory navigation controls are those, which are performed on directories. 

For ex-
 ls- It show the list of directories
cd- It is used to change directory
mkdir- It is used to create new directory
rmdir- It is used to remove directory
pwd- it is used to show the path of current directory, where the user is exists.

What is system calls? Or How does user program interact with Kernel?

Answer:
User programs interact with kernel through set of standard system calls. These system calls provide requested service by kernel. Services like open, close, read, write or execute file and changing accessibilityof file and enable access of hardware devices.

Who developed UNIX and When?

Answer:
UNIX was developed by a group of AT&T employee at Bell Labs, including Ken Thompson, Dennis Ritchie, Douglas Macllroy, Rudd Canaday and Tom Blakeley in 1969.

What is inode?

Answer:
An inode is special file designed to be read by kernel to learn the information about each file. It specifies the permissions on file, ownership, date of creation and of last access, and change and the physical location of data block on the disk containing the file.

What is command and syntax of command line?

Answer:
Command is a program that tells the UNIX system to do something. It has the form:
command [options][arguments]

Where an argument indicates on what command is to perform actions, usually a file or set of files. An option modifies the command and changing the way it perform.

Option are generally precede by hyphen (-), and for most commands,more than one option can be stung together, in the form :

command -[option][option][option]

What is difference between external command and internal command in UNIX?

Answer:
In UNIX system, external commands resides in computer disks.
For example
 /bin/ls
is an external command.

On other hand, internal command are built into the shell program.
For example
exit is an internal command.

How does the user know where he is in file system?

Answer:
At any time user can determine where he is in file system hierarchy with pwd command, (present working directory). 
For ex- % pwd
Output- /home/frank/src

What is use of \'cd\' command?

Answer:
\'cd\' command is basically used for change directory.

The various use of \"cd\" command are:
cd (also chdir in some shells) --> change directory
cd/ -->changes directory to the system\'s root
cd.. -->goes up one directory level
cd../.. -->goes up two directory levels
cd /full/path/name/from/root --> changes directory to absolute path named (note the leading slash)
cd path/from/current/location --> changes directory to path relative to current location (no leading slash)
cd ~username/directory --> changes directory to the named username\'s indicated directory

What is the use of rmdir command?

Answer:
rmdir command is use to remove directory. It is compulsory that the directory needs to be empty before remove it and if it is also not present working directory,then you must first change of it.

Syntax
:
rmdir <directory>

Example- To remove the empty directory /home/frank/data while in /home/frank use:
% rmdir data
Or
% rmdir /home/frank/data

what is the use of ls command?

Answer:
ls command is used to list all directories and files. With option it can provide information about size, type of file, permissions, date of file creation and change and access.

Syntax :ls [options][arguments]

Option

-a     list all files including directories those beginning with dot(.)
-d     list only name of directory not the files in directory
-al     long listing

What is difference between UNIX & DOS navigation & directory control commands?

Answer:
UNIX vs DOS Navigation & Directory Control Commands

Commands                      UNIX         DOS
List directory                      ls           dir
Make directory                   mkdir      md &mkdir
Change directory                cd        cd & chdir
Remove directory               rmdir         rd & rmdir
Return to user\'s home directory        cd        cd/
location in path                  pwd        cd

(present working directory)

What are the file maintenance commands?

Answer:
File maintenance commands are to create copy, remove & change permission on files. 

You can use the following commands


 Commands/syntax       working of it.
chgrp [options] group file  change the group of file
chmod [options] file         change the access mode of file
chown [options] owner file change the ownership of file(only super user can do it)
cp [options] file1 file2      copy the content of file1 into file 2
mv [options] file1 file2     move file1 into file2
rm [options] file              remove file or directory

What is difference between UNIX & DOS file maintenance commands?

Answer:
Commands            UNIX        DOS
copy file                    cp        copy
move file                    mv        move
rename file                mv        rename & ren
delete file                   rm        erase & del

display file to screen
                   entire file        cat        type
   one page at a time        more.less.pg    type/p

How do you copy file in UNIX system?

Answer:
You can copy content of a file into another file by using \'cp\' command.

Syntax- cp [options] <old file name> <new file name>
Common option
     -i    prompt and wait for confirmation before proceeding
     -r    recursively copy a file

Example- % cp <old file name>  <new file name>
 Now you have two copies of the file. They are completely independent of each other.
They each have their own inode, data blocks, and directory table entries.

How do you rename or move a file in UNIX system

Answer:
You can rename or move file with mv command.

Syntax-

mv [options] [old filename] [new filename]

Common Options

-i        interactive (prompt and wait for confirmation before proceeding)
 -f        don\'t prompt, even when copying over an existing target file (overrides -i)

Examples

% mv <old filename> <new filename>
Now you have a file called <new filename> and the file <old filename> is gone or deleted.
The contents of the file remain where they were

How do you remove a file in UNIX system?

Answer:
You can remove a file with the rm command.

Syntax
rm [options] filename

Common Options
-i     interactive (prompt and wait for confirmation before proceeding)
-r     recursively remove a directory, first removing the files and subdirectories beneath it
-f     don\'t prompt for confirmation (overrides -i)

Examples
% rm <filename>

How do you set permission in UNIX system?

Answer:
Each file, directory, and executable has permissions set for who can read, write, and/or execute it.

To find the permissions assigned to a file, the ls command with the -l option should be used.
.
For examples
-
-rwxr-x--- allows the user (owner) of the file to read, write, and execute it; those in the unixgroup of the file can read and execute it; others cannot access it at all.

How do you change file permissions in UNIX system?

Answer:
To change permissions on file or directory is chmod (change mode). The syntax involves using the command with three digits (representing the user (owner, u) permissions, the group (g) permissions, and other (o) user\'s permissions)Or by using symbolic representation.

Each of the permission types is represented by either a numeric equivalent:
read=4, write=2, execute=1

or a single letter:
read=r, write=w, execute=x

A permission of 4 or r would specify read permissions. If the permissions desired are read and write,the 4 (read) and the 2 (write) are added together to make a permission of 6.Therefore, a permission setting of 6 would allow read and write permissions.

Alternatively, you could use symbolic notation which uses the one letter representation for who and for the permissions and an operator, where the

operator can be:
+     add permissions
-     remove permissions
=     set permissions

So to set read and write for the owner we could use \"u=rw\" in symbolic notation.
Syntax
chmod nnn [argument list]     numeric mode
chmod [who]op[perm] [argument list]    symbolic mode
where nnn are the three numbers representing user, group, and other permissions, who is any of u, g,
o, or a (all) and perm is any of r, w, x.


Common Options
-f     force (no error message is generated if the change is unsuccessful)
-R     recursively descend through the directory structure and change the modes

Examples

If the permission desired for file1 is user: read, write, execute, group: read, execute, other: read,execute, the command to use would be
chmod 755 file1 or chmod u=rwx,go=rx file1

How do you change file ownership in UNIX system?

Answer:
Ownership of a file can be changed with the chown command.It can only be done by the super-user

Syntax

     chown [options] user[:group] file
     chown [options] user[.group] file

Common Options

     -R recursively descend through the directory structure
     -f force, and don\'t report any errors

Examples

# chown new_owner file
# represents the shell prompt for the super-user

How do you change file group in UNIX system?

Answer:
Anyone can change the group of files they own, to another group they belong to, with the chgrp command.

Syntax
:
chgrp [options] group file

Common Options
-R recursively descend through the directory structure
-f force, and don\'t report any errors

Examples

% chgrp new group file

What are display command in UNIX system?

Answer:
Display command are used to display or view content of file. Some display commands are as follows:
     Commands                     What it will do
     cat [options] file                concatenate (list) a file
     echo [text string]              echo the text string to standard output(monitor)
     head [number] file              display the first 10 (or number of) lines of a file
     more (or less or pg) [options] file     page through a text file
     tail [options] file              display the last few lines (or parts) of a file

What does the cat command do in UNIX system?

Answer:
The cat command is use to display the content of a file
Syntax--
     cat [options] [file]

Common Options
     -n    precede each line with a line number
     -v    display non-printing characters, except tabs, new-lines, and form-feeds
     -e    display $ at the end of each line

Examples

     % cat filename
You can list a series of files on the command line, and cat will concatenate them, starting each in turn,
immediately after completing the previous one, e.g.:
     % cat file1 file2 file3

What does the echo command do in UNIX system?

Answer:
The echo command is used to repeat the argument you give it back to the standard output device. It normally ends with a line-feed, but you can specify an option to prevent this.

Syntax
echo [option] [string]

Examples
% echo Hello Class or echo \"Hello Class\"

What is the use of more, less and pg command in UNIX system?

Answer:
more, less, and pg command let you page through the contents of a file one screen at a time.
These may not all available on your UNIX system.
Syntax
     more [options] [+/pattern] [filename]
     less [options] [+/pattern] [filename]
     pg [options] [+/pattern] [filename]

Internal Controls

         more displays (one screen at a time) the file requested
         <space bar> to view next screen
         <return> or <CR> to view one more line
         q to quit viewing the file
         h help
         b go back up one screen
         /word search for word in the remainder of the file

less similar to more
pg equivalent of more

What is the use of head command in UNIX system?

Answer:
Head command displays the head or start of the file.

Syntax:
     head [options] file

Common Options
     -n number    number of lines to display, counting from the top of the file
     -number     same as above

Examples

By default head displays the first 10 lines.

You can display more with the \"-n number\", or \"-number\" options, e.g., to display the first 40 lines: % head -40 filename or head -n 40 filename

What is the use of tail command in UNIX system?

Answer:
Tail command displays the tail or end of the file.
Syntax
     tail [options] file

Common Options
-number     number of lines to display, counting from the bottom of the file

Example

The default is to display the last 10 lines, but you can specify different line or byte numbers, or a different starting point within the file.

To display the last 30 lines of a file use the -number style:% tail -30 filename

What are system resource commands?

Answer:
The commands that report or manage system resources are known as system resource commands. Some are as follows:
Command/Syntax                What it will do
chsh (passwd -e/-s)            change the user\\s login shell (only by the super user)
date [options]                report the current date and time
df [options] [resource]            report the summary of disk blocks and inode free and in use
du [options] [directory or file]         report amount of disk space in use+
Hostname/uname            display or set (super-user only) the name of the current machine
kill [options] [-SIGNAL] [pid#] [%job]     send a signal to the process with the process id number (pid#)

Or job control number (%n).

The default signal is to kill the process.
man [options]                 command show the manual (man) page for a command
passwd [options]            set or change your password
ps [options]                show status of active processes
script file                saves everything that appears on the screen to file until exit is executed
stty [options]                set or display terminal control options
which                     command reports the path to the command or the shell alias in use
who or w                 report who is logged in and what processes are running

How do you display current date & time in UNIX system?

Answer:
Date command displays the current data and time. A super user can set the date and time.

Syntax

     date [options] [+format]

Common Options
     -u        Universal Time (or Greenwich Mean Time)
     +format    specify the output format
     %a        weekday, Sun to Sat
     %h        month abbreviation, Jan to Dec
     %j        day of year, 001 to 366
     %n        <new-line>
     %t        <TAB>
     %y        last 2 digits of year, 00 to 99
     %D        MM/DD/YY date
     %H        hour, 00 to 23
     %M        minute, 00 to 59
     %S        second, 00 to 59
     %T        HH:MM:SS time


Example
     date
     Mon Jun 10 09:01:05 EDT 1996
     date -u
     Mon Jun 10 13:01:33 GMT 1996
     date +%a%t%D
     Mon 06/10/96
     date \'+%y:%j\'
     96:162

How do you come to know the name of machine?

Answer:
Hostname reports the host name of the machine the user is logged into.

Example:
brigadier: condron [91]> hostname
outpu--> brigadier
uname has additional options to print information about system hardware type and software version.

How do you summarize the disk block and file usage in UNIX system?

Answer:
df command is used to report the number of disk blocks and indexes used and free for each file system.

Syntax
     df [options] [resource]

Common Options
     -l    local file systems only
     -k    report in kilobytes

How do you know that how much disk space is use in UNIX system?

Answer:
du command reports the amount of disk space in use for the files or directories.

Syntax:

     du [options] [directory or file]

Common Options
     -a    display disk usage for each file
     -s    display a summary (total only)
     -k    report in kilobytes

What is the use of ps command in UNIX system?

Answer:
ps command is used to show status of all processes currently running on the system. 


Syntax
     ps [options]

How do you terminate a process in UNIX system?

Answer:
kill command is use to terminate a process.

Syntax
     kill [-signal] process-id
Common Options
     -l    displays the available kill signals:
Example
 
     (UNIX prompt) kill -9 15599

What should be done by who command in UNIX system?

Answer:
who command reports who is logged in that present time.

Syntax:who

What is the use of which command in UNIX system?

Answer:
which command will report the name of the file that is be executed when the command is invoked. This will be the full path name or the alias that\'s found first in your path.

Syntax:
which command(s)

Example:
UNIX prompt> which MailOutput-- /usr/ucb/Mail

What is the use of whereis command in UNIX system?

Answer:
whereis command reports the filenames of source, binary, and manual page files associated with command.

Syntax:
     whereis [options] command(s)

Common Options
:
     -b    report binary files only
     -m    report manual sections only
     -s    report source files only

What should be done by script command in UNIX system?

Answer:
script command creates a script of your session input and output. By using the script command, 
you can capture all the data transmission from and to your terminal screen until you exit the script program.
Syntax
     script [-a] [file] <. . .> exit

Common Options
     -a    append the output to file typescript is the name of the default file used by script.

You must remember to type exit to end your script session and close your typescript file.

How does user set or change his password in UNIX system?

Answer:
passwd command is use to set or change password. When you enter a password, the string is encrypted by the system.
This encryption stored in a file named shadow in the /etc directory.

Syntax
     <prompt>passwd
     (current) UNIX password : ******
     New UNIX password : ******
     Retype UNIX password : ******

How should user know his terminal in UNIX system?

Answer:
User should know his terminal name by using tty (teletype) command. This command is simple and needs no argument.

Syntax
     (Unix Prompt) tty

Output
     /div/term/2

 The terminal file name is 2 that resident in the term directory and term directory is under the div directory.

How should user lock his terminal in UNIX system?

Answer:
Sometimes user have to be away from his terminal, but don\'t want to logout because  a job is running in the background.
This is done by lock  command. It requires you to enter a password when you decide to lock it.

Syntax

     <prompt> lock

Output
     Password : ******
     Re-enter password : ******
     Terminal locked by Ram 0 minutes ago

How should user clear his screen in UNIX system?

Answer:
There are two command in UNIX system to clear your screen clear and tput
Clear is used to clear the screen and cursor is positioned at the top left corner of the screen
tput is used with clear argument to clear the screen and with cup argument to position cursor  at desired location.

Syntax:
     <prompt>clear
 <prompt>tput clear
 <prompt>tput cup 10 10

What is the use of cal command in UNIX system?

Answer:
cal command is used to see the calendar of specific month or a complete year. 

To see the calendar of specific month of  current year.
<prompt> cal mar

To see the calendar of specific year.
<prompt> cal 2006

How should be user use calculator in UNIX system?

Answer:
bc command is used for calculator. When user invoke bc command without argument, the cursor keep on blinking 
and nothing to seem to happen.

 bc belongs to family of commands that accept input from keyboard.


Syntax <prompt> bc

What is the use of bc command in UNIX system?

Answer:
bc command is used for calculator. When user invoke bc command without argument, the cursor keep on blinking 
and nothing to seem to happen. bc belongs to family of commands that accept input from keyboard.


Syntax <prompt> bc

What is use of wc command in UNIX system?

Answer:
wc command is use to count lines, word and characters depending on theoption used. wc displays a four-columnar output.

Syntax wc

How should be two files compared in UNIX system? Or What is the use of cmp command in UNIX system?

Answer:
cmp command is used to compare two file that they are identical or not. The two files are compared by byte and the location. If two files are  identical, cmp display no message, but simply  return the prompt.
 
Syntax:
     <prompt> cmp file1 file2

How should be one file converting into another files> Or What is the use of difference command in UNIX system?

Answer:
The difference  command is used to displaying file differences. It tell which linein one file have to be changed to make two files identical.

Syntax cmp file1 file2

What is use of comm command in UNIX system?

Answer:
comm Command finds the text that is common to both the files and the text that is unique to both the files.

Syntax
     <prompt> comm file1 file 2

What are print commands in UNIX system?

Answer:
The print commands allow us to print files to standard output (pr) or to a line printer (lp/lpr) while filtering the output.


Printing Commands
Command/Syntax        What it will do
lpq (lpstat) [options]        show the status of print jobs
lpr (lp) [options] file        print to defined printer
lprm (cancel) [options]        remove a print job from the print queue

How does a user submit a print job in UNIX system?

Answer:
lp and lpr command are used specified file or standard input to send to the printer to print. Each job is given a unique request-id that can be used to follow or cancel the job while it\'s in the queue.

Syntax:
     lp [options] filename
     lpr [options] filename

Common Options
     lp         lpr         function
     -n number     -#number     number of copies
      -t title         -Ttitle         title for job
     -d destination     -Pprinter     printer name
     -c         (default)     copy file to queue before printing
     (default)    -s         don�t copy file to queue before printing
     -o option             additional options

Examples
To print the file ssh.ps:
     <prompt>lp ssh.ps
     request id is lp-153 (1 file(s))

This submits the job to the queue for the default printer, lp, with the request-id lp-153.

How does a user check the status of print job in UNIX system?

Answer:
User can check the status of your print job with lpstat or lpq.

Syntax:

     lpstat [options]
     lpq [options] [job#] [username]

Common Options

     lpstat         lpq         function
     -d         (defaults to lp)     list system default destination
     -s                 summarize print status
     -t                 print all status information
     -u [login-ID-list]             user list
     -v                 list printers known to the system
     -p          -P         list status of printer

Examples

     <prompt> lpstat
     lp-153 frank 208068 Apr 29 15:14 on lp

How does a user cancel a print job in UNIX system?

Answer:
User can cancel only their own print jobs.

Syntax
     cancel [request-ID] [printer]
     lprm [options] [job#] [username]

Common Options
     cancel        lprm         function
    
   -Pprinter     specify printer

all jobs for user
     -u [login-ID-list]             user list

How does a user prepare files for printing in UNIX system?

Answer:
User prepares files for printing in UNIX by using pr command. pr prints header and trailer information surrounding the formatted file. user can specify the number of pages, lines per page, columns, line spacing, page width, etc. to print, along with header and trailer information and how to treat <tab> characters.


Syntax

     pr [options] file

Common Options
     +page_number         start printing with page page_number of the formatted input file
     -column             number of columns
     -a             modify -column option to fill columns in round-robin order
     -d             double spacing
     -e[char][gap]         tab spacing
     -h header_string         header for each page
     -l lines             lines per page
     -t             doesn\'t print the header and trailer on each page
     -w width         width of page

What is shell in UNIX system?

Answer:
The shell sits between user and the operating system, acting as a command interpreter. The shell is same as command.com in DOS. 

What is the working of shell in UNIX system?

Answer:
It reads user terminal input and translates the commands into actions taken by the system. When user log into the system user given a default shell.

When the shell starts up it reads its startup files and may set environment
variables, command search paths and executes any commands specified in these files.Shell is generally sleeping. It wakes up when input is typed at the prompt.

What activities are done by shell in UNIX system?

Answer:
The following activities are typically performed by the shell.It issues the prompt and sleeps till user enter a command.

After a command has been entered, the shell scans the command line for special character that has special meaning for it.

It then creates a simplified command line and passes it on to the kernel for execution.The shell cannot do any work while the command is being executed and has to wait for its completion.After the job is complete, the prompt reappears and the shell return to sleeping.

How many shells available in UNIX system?

Answer:
There are following shell available in UNIX system

Shell Name                  Prompt
1)    Bourne shell            sh
2)    C shell                    csh
3)    Korn shell                ksh
4)    Bourne Again shell   bash
5)    T-C shell                  tcsh
6)    Extended C-shell     cshe

What is the prompt for Bourne shell?

Answer:
$ is the prompt for Bourne shell.

What is the prompt for C-shell?

Answer:
% is the prompt for c-shell.

What are the built-in commands in Bourne Shell?

Answer:
The shells have a number of built-in, or native commands. These commands are executed directly in the shell and don\'t have to call another program to be run. 

These built-in commands are different for the different shells.

For the Borne shell some of the more commonly used built-in commands are:
     :         null         command
     .         source (read and execute) commands from a file
     case         case conditional loop
     cd         change the working directory (default is $HOME)
     echo         write a string to standard output
     eval         evaluate the given arguments and feed the result back to the shell
     exec         execute the given command, replacing the current shell
     exit         exit the current shell
     export         share the specified environment variable with subsequent shells
     for         for conditional loop
     if         if conditional loop
     pwd         print the current working directory
     read         read a line of input from stdin
     set         set variables for the shell
     test         evaluate an expression as true or false
     trap         trap for a typed signal and execute commands
     umask         set a default file permission mask for new files
     unset         unset shell variables
     wait         wait for a specified process to terminate
     while         while conditional loop

What are built-in commands in c shell?

Answer:
For the C shell the more commonly used built-in functions are:

     alias         assign a name to a function
     bg         put a job into the background
     cd         change the current working directory
     echo         write a string to stdout
     eval         evaluate the given arguments and feed the result back to the shell
     exec         execute the given command, replacing the current shell
     exit         exit the current shell
     fg         bring a job to the foreground
     foreach         for conditional loop
     glob         do filename expansion on the list, but no \"\" escapes are honored
      history         print the command history of the shell
     if         if conditional loop
     jobs         list or control active jobs
     kill         kill the specified process
     limit         set limits on system resources
     logout         terminate the login shell
     nice command     lower the scheduling priority of the process, command
     nohup command     do not terminate command when the shell exits
     popd         pop the directory stack and return to that directory
     pushd         change to the new directory specified and add the current one to the directory
     rehash         recreate the hash table of paths to executable files
     repeat         repeat a command the specified number of times
     set         set a shell variable
     setenv         set an environment variable for this and subsequent shells
     source         source (read and execute) commands from a file
     stop         stop the specified background job
     switch         switch conditional loop
     umask         set a default file permission mask for new files
     unalias         remove the specified alias name
     unset         unset shell variables
     unsetenv     unset shell environment variables
     wait         wait for all background processes to terminate
     while         while conditional loop

What are environment variables in UNIX system?

Answer:
Environmental variables are used to provide information to the programs you use. User can have both global environment and local shell variables. Global environment variables are set by user login shell and new programs and shells inherit the environment of their parent shell. 

Local shell variables are used only by that shell and are not passed on to other processes. A child process cannot pass a variable back to its parent process.

The current environment variables are displayed with the \"env\" or \"printenv\" commands.


Some common ones are:
    

DISPLAY     The graphical display to use
EDITOR     The path to your default editor
GROUP     Your login group
HOME         Path to your home directory
HOST         The hostname of your system
IFS         Internal field separators, usually any white space
LOGNAME     The name you login with, e.g. frank
PATH         Paths to be searched for commands
PS1         The primary prompt string, Bourne shell only
PS2         The secondary prompt string, Bourne shell only
SHELL         The login shell you\'re using
TERM         Your terminal type
USER         Your username

What is the function of \'noclobber\' command?

Answer:
\'Noclobber\' command indicates that output will not be redirected to existing files.

What is the function of \'ignoreeof\' command?

Answer:
ignoreeof command specifies that EOF (^D) will not cause the login shell to exit and log you off the system.

What is the function of \'history\' command?

Answer:
With the history command user can recall previously executed commandsand re-execute them, with changes if desired.

What is the function of \'alias\' command?

Answer:
An alias allows you to use the specified alias name instead of the full command. 

In the \"ls\" example above, typing \"ls\" will result in \"/usr/bin/ls -sbF\" being executed.

How do we put a job in background in UNIX system?

Answer:
User can put jobs into the background at anytime by appending \"&\" to the command.

After submitting a command you can also do this by typing ^Z (Control-Z) to suspend the job and then \"bg\" to put it into the background.

How do we put a job in foreground in UNIX system?

Answer:
To bring background job to the foreground type \"fg\". Your keyboard is connected  only to the current foreground job. With the %n notation you can reference the nth background job bring to fore ground. For Ex- To bring the third background job to the foreground with \"fg %3\".

How the history is maintained in C-Shell in UNIX system?

Answer:
User can use the history and savehist variables to set the number of previously executed commands to keep track of in this shell and how many to retain between logins, respectively. You could put a line such as the following in .cshrc to save the last 100 commands in this shell and the last 50 throughthe next login.
set history=100 savehist=50

 Command     Substitution Function
     !!         repeat last command
     !n         repeat command number n
     !-n         repeat command n from last
     !str         repeat command that started with string str
     !?str?         repeat command with str anywhere on the line
     !?str?%         select the first argument that had str in it
     !:         repeat the last command, generally used with a modifier
     !:n         select the nth argument from the last command (n=0 is the command name)
     !:n-m         select the nth through mth arguments from the last command
     !^         select the first argument from the last command (same as !:1)
     !$         select the last argument from the last command
     !*         select all arguments to the previous command
     !:n*         select the nth through last arguments from the previous command
     !:n-         select the nth through next to last arguments from the previous command
     ^str1^str2^     replace str1 with str2 in its first occurrence in the previous command
     !n:s/str1/str2/     substitute str1 with str2 in its first occurrence in the nth command.

What is output redirection?

Answer:
With output redirection, the output of a command is redirected to a file rather than to the terminal screen.

What is input redirection?

Answer:
With input redirection, the input to a command is given via a file rather than the keyboard.

What are special UNIX features that are used to handling data support in UNIX system?

Answer:
The standardized handling of data supports, there are two important features of UNIX utilities: I/O redirection and piping.

 With output redirection, the output of a command is redirected to a file rather than to the terminal screen.

 With input redirection, the input to a command is given via a file rather than the keyboard.

With piping, the output of a command can be used as input (piped) to a subsequent command.

What do you understand by file descriptor in UNIX system?

Answer:
There are 3 standard file descriptors:

     stdin 0 Standard input to the program
     stdout 1 Standard output from the program
     stderr 2 Standard error output from the program

What are file redirection in UNIX system?

Answer:
Output redirection takes the output of a command and places it into a named file. Input redirection reads the file as input to the command. The following table summarizes the redirection options.

File Redirection

    Symbol         Redirection
     >                 output redirect
     >!                same as above, but overrides noclobber
     >>               append output
     >>!               same as above, but overrides
     |                   pipe output to another command
     <                  input redirection
     <<String        read from standard input until \"String\" is encountered as the only thing on the line.
     <<String        same as above, but don\'t allow shell substitutions

What are the other special command symbol used in UNIX system?

Answer:
There are a number of other special symbols you can use on a command line.

 These include:
     ;         command separator
     &         run the command in the background
     &&         run the command following this only if the previous command completes successfully
     ||         run the command following only if the previous command did not complete successfully
     ( )         the commands within the parentheses are executed in a subshell.
     .         literal quotation marks. Don\'t allow any special meaning to any characters within these quotations.
              escape the following character (take it literally)
     \" \"         regular quotation marks. Allow variable and command substitution with theses quotations
     command     take the output of this command and substitute it as an argument(s) on the command line

What are wild card and how it is used in UNIX system?

Answer:
The shell and some text processing programs will allow meta-characters or wild cards  and replace them with pattern matches. 

For filenames these meta-characters and their uses are:

     ?         match any single character at the indicated position
     *         match any string of zero or more characters
     [abc...]         match any of the enclosed characters
     [a-e]         match any characters in the range a,b,c,d,e
     [!def]         match any characters not one of the enclosed characters
     {abc,bcd,cde}     match any set of characters separated by comma (,) (no spaces)
     ~         home directory of the current user

What is regular expression in UNIX system?

Answer:
Some text processing programs let you search on patterns instead of fixed strings. These text patterns are known as regular expressions. You form a regular expression by combining normal characters and special characters, also known as meta-characters, with the rules below. With these regular expressions you can do pattern matching on text data.Regular expressions come in three different forms:

  1.  Anchors which tie the pattern to a location on the line
  2. Character sets which match a character at a single position
  3.  Modifiers which specify how many times to repeat the previous expression

Give some example that are more commonly used regular expression?

Answer:
Some examples of the more commonly used regular expressions are:

     Regular expression     matches
     cat             the string cat
     .at             any occurrence of a letter, followed by at, such as cat, rat, mat, bat, fat, hat
     xy*z             any occurrence of an x, followed by zero or more y\'s, followed by a z.
     ^cat             cat at the beginning of the line
     cat$             cat at the end of the line
     *             any occurrence of an asterisk
     [cC]at             cat or Cat
     [^a-zA-Z]         any occurrence of a non-alphabetic character
     [0-9]$             any line ending with a number
     [A-Z][A-Z]*         one or more upper case letters
     [A-Z]*             zero or more upper case letters (In other words, anything.)

What are text processing command?

Answer:
Text Processing Commands
     Command/Syntax                  What it will do
     awk/nawk [options]                file scan for patterns in a file and process the results
     grep/egrep/fgrep [options] \'      search string\' file    search the argument for all occurrences of the search string, and list them.
     sed [options] file                  stream editor for editing files from a script or from the command line.

What is the use of grep, egrep, fgrep command?

Answer:
The grep utility is used to search for generalized regular expressions occurring in Unix files. Regular expressions are best specified in apostrophes (or single quotes) when specified in the grep utility.

 The egrep utility provides searching capability using an extended set of meta-characters.
 
Syntax
grep [options] regexp [file[s]]
Common Options
      -i     ignore case
     -c     report only a count of the number of lines containing matches, not the matches themselves
     -v     invert the search, displaying only lines that do not match
     -n     display the line number along with the line on which a match was found
     -s     work silently, reporting only the final status:
      0,     for match(es) found
      1,     for no matches
      2,     for errors
     -l     list filenames, but not lines, in which matches were found.

List out the command that work on file?

Answer:
Command/Syntax         What it will do
     cmp [options] file1 file2         compare two files and list where differences occur (text or binary files)
     cut [options] [file(s)]             cut specified field(s)/character(s) from lines in file(s)
     diff [options] file1 file2           compare the two files and display the differences (text files only)
     file [options] file                    classify the file type
     find directory [options] [actions]   find files matching a type or pattern
     ln [options] source_file target  link the source_file to the target
     paste [options] file                 paste field(s) onto the lines in file
     sort [options] file                    sort the lines of the file according to the options chosen
     strings [options] file                report any sequence of 4 or more printable characters ending in <NL> / <NULL>.
     tee [options] file                      copy stdout to one or more files
     touch [options] [date] file         create an empty file, or update the access time of an existing file
     tr [options] string1 string2        translate the characters in string1 from stdin into those in string2 in stdout
     uniq [options] file                     remove repeated lines in a file
     wc [options] [file(s)]                 display word (or character or line) count for file(s)