Sunteți pe pagina 1din 33

UNIX Bids

Que:- What is $* and $@?


Ans:-
It both prints the command line arguments. During run any shell script via giving some arguments.
$@:- “f1” “f2” “f3” “f4”
$*:- “f1 f2 f3 f4”

Que:- What does $? return ?


Ans:-
It gives the status of the last command execute. if "echo $?" return 0 means right and 1 or greater then
1 means wrong.

Que:- How do u open a read only file in Unix?


Ans:-
Just we have to use the “cat”, “view” and "more" command to view the content of the file.

Que:- What is the difference between a shell variable that is exported and the one that is not
exported?
Ans:-
If we export a variable in shell then we access a variable in the child shell, if not export we can use
that variable only in current shell.

Que: - If you have a string "one two three", which shell command would you use to extract the
strings?
Ans:-
To do this we can use: "cut", "awk", "gawk", "sed" or "shell script".

Que:- How do you schedule a command to run at 4:00 every morning?


Ans:-
00 04 * * * sh /path1/path2/script.sh >> /path1/script.log.

Que:- How will you list only the empty lines in a file?
Ans:-
1. cat file|sed –n ‘/^$/p’|wc –l
2. sed –n ‘/^$/p’ file |wc –l
3. sed ‘/^$/!d’ file |wc –l
4. awk ‘/^$/’ file|wc –l
5. grep –nv ^$ file
6. grep -nv "." file

Que:- When you login to c shell, which script would be run first?
Ans:-
.profile and .tchrc will be executing first.

Que:- How would you get the character positions 10-20 from a text file?
Ans:-
cut –c10-20 file.txt

Que:- How would you print just the 25th line in a file?
Ans:-
Awk ‘NR==25 {print $0}’ file_name
sed –n ‘25p’ file.txt
cat file_name|tail -25|head -1

Que:- Different types of shells?


Ans:-
bash, ksh, tcsh, ssh etc.

Que:- How do you read arguments in a shell program?


Ans:-
echo $#

Que:- What are the different kinds of loops available in shell script ?
Ans:-
for, while, until, select loops.

Que:- What does $# stand for?


Ans:-
It read number of arguments those are pass on the command prompt.

Que:- How would you replace the “n” character in a file with some “xyz”?
Ans:-
sed ‘s/n/xyz/’ file.txt or ‘s/n/xyz/g’ file.txt 'g' --global.
In vi –
1,$s /n/xyz/g

Que:- How do you take a single line of input from the user in a shell script?
Ans:-
we have to “read” command keyword from user input.

Que:- Write a script to convert all DOS style backslashes to UNIX style slashes in a list of files?
Ans:-
1.we can use "dostounix" and "unixtodos" command.
2.we can do this for sed ‘|\|/|g’ filename.
3.cat hello|while read line
do
b=`echo $line|tr -cd ',' |wc -c`
i=1
while [ $i -le $b ]
do
cc=`echo $line|cut -d "," -f$i`
ee=`echo -e $cc\/`
echo -e "$ee\c"
i=`expr $i + 1`
done
done

Que:- Write a regular expression (or sed script) to replace all occurrences of the letter ‘f’,
followed by any number of characters, followed by the letter ‘a’, followed by one or more numeric
characters, followed by the letter ‘n’, and replace what’s found with the string “UNIX”.
Ans:-
sed –e ‘s/f/rr/g’ –e ‘s/a/1234/g’ –e ‘s/n/UNIX/g’ file.txt
Que:- Using the man pages, find the correct ioctl to send console output to an arbitrary tty?
Ans:-
ioctl > /dev/pts/3 via this you Can send the command output to another terminal.

Que:- What happens to a child process that parent process dies. what’s bad about this?
Ans:-
Nothing going bad, Because the child process is adopted by init process. When its parent Process dies.

Que:- What command do you run to check file system consistency?


Ans:-
The "fsck" command checks and interactively repairs inconsistent file systems. You should run this
command before mounting any file system.

Que:- What’s wrong with running shutdown on a network?


Ans:-
Nothing Gone wrong Because, "Shutdown" command is command which inform the connected user first
then it start his work. After complete this command we loss the Connectivity for until the system is not
up.

Que:- What can be wrong with setuid scripts?


Ans:-

Que:- What value does spawn return?


Ans:-

Que:- Write a script to send mail from three other machines on the network to root at the machine
you’re on. Use a ‘here doc’, but include in the mail message the name of the machine the mail is
sent from and the disk utilization statistics on each machine?
Ans:-

Que:- Why can’t root just cd to someone’s home directory and run a program called a.out sitting
there by typing “a.out”, and why is this good?
Ans:-

Que:- What is the difference between UDP and TCP?


Ans:-
TCP(Transmission Control Protocol): TCP is a connection-oriented protocol, a connection can be made
from client to server, and from then on any data can be sent along that connection.
· Reliable - when you send a message along a TCP socket, you know it will get there unless the
connection fails completely. If it gets lost along the way, the server will re-request the lost part. This
means complete integrity, things don't get corrupted.
· Ordered - if you send two messages along a connection, one after the other, you know the first
message will get there first. You don't have to worry about data arriving in the wrong order.
· Heavyweight - when the low level parts of the TCP "stream" arrive in the wrong order, resend
requests have to be sent, and all the out of sequence parts have to be put back together, so requires a
bit of work to piece together.
UDP(User Datagram Protocol): A simpler message-based connectionless protocol. With UDP you send
messages(packets) across the network in chunks.
· Unreliable - When you send a message, you don't know if it'll get there, it could get lost on the way.
· Not ordered - If you send two messages out, you don't know what order they'll arrive in.
· Lightweight - No ordering of messages, no tracking connections, etc. It's just fire and forget! This
means it's a lot quicker, and the network card / OS have to do very little work to translate the data
back from the packets.

Que:- What does nslookup do?


Ans:-
The "nslookup" utility is a program to query Internet domain name servers. It has two modes:
interactive and non-interactive. Interactive mode allows the user to query name servers for
information about various hosts and domains or to print a list of hosts in a domain. Non-interactive
mode is used to print just the name and requested information for a host or domain.

Que:- How do you create a swapfile? mkfile used to create swapfile


Ans:-mkfile swap_file 1G ; swapadd –a swap_file

Que:- How would you check the route table on a workstation/server?


Ans:-
Via “route” command and table name is /etc/network in this we store the IPs for routing.
Que:- How do you find which ypmaster you are bound to?
Ans:-

Que:- How do you fix a problem where a printer will cut off anything over 1MB?
Ans:-

Que:- What is the largest file system size in solaris (SunOS)?


Ans:-
ZFS (zettabytes file system)

Que:- What are the different RAID levels?


Ans:-
There are total 10 types of RAID levels:
· RAID level 0
· RAID level 1
· RAID level 2
· RAID level 3
· RAID level 4
· RAID level 5
· RAID level 6
· RAID level 10
· RAID level 50
· RAID level 0+1

Que:- List the files in current directory sorted by size ?


Ans:-
ls –lS
ls -l | grep ^- | sort -nr

Que:- List the hidden files in current directory ?


Ans:-
ls –la
ls -a1 | grep "^\."

Que:- Delete blank lines in a file ?


Ans:-
grep –v ^$ filename ’ > new_sample.txt
Sed ‘/^$/d’filename

Que:- Search for a sample string in particular files ?


Ans:-
grep –w “string” filename

Que:- Display the last newly appending lines of a file during appending data to the same file by
some processes ?
Ans:-
tail-f filename

Que:- Display the Disk Usage of file sizes under each directory in currentDirectory ?
Ans:-
du -k * | sort -nr (or) du -k | sort –nr
du –h *|sort –rn|head -1 OR in the current directory we use ls –lShr
OR find ./ -printf ‘%s %p\n’|sort –rn|head -5

Que:- Change to a directory, which is having very long name ?


Ans:-
cd file_name_ong* or many file name combination we use.

Que:- Display the all files recursively with path under current directory ?
Ans:-
find . -depth –print
find . –type f -print

Que:- Set the Display automatically for the current new user ?
And:-
In the user .{shell}rc file or in the .profile we need to add this entry
export DISPLAY=hostname:0.0
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.

Que:- Display the processes, which are running under yourusername ?


Ans:-
ps –aef|grep –w “username”

Que:- List some Hot Keys for bash shell ?


Ans:-
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.

Que:- Display the files in the directory by file size ?


Ans:-
find ./ -printf “%s %p\n”
Que:- How to save man pages to a file ?
Ans:-
man top | col -b > top_help.txt

Que:- How to know the date & time. When script is executed ?
Ans:-
ls –lu -- It show access time of script
Add the following script line in shell script.sh echo "Script is executed at `date`".

Que:- How do you find out drive statistics in UNIX OS?


Ans:-
iostat –x or -E

Que:- Display disk usage in Kilobytes ?


Ans:-
du -k

Que:- Display top ten largest files/directories ?


Ans:-
ls –lS|head -10
ls -l|awk -F" " ' {print $5, $0}'|sort -rn|head -10|awk -F '{print $1}'
du -sk * | sort -nr | head

Que:- How much space is used for users in kilobytes?


Ans :-
quot -af

Que:- How to create null file ?


Ans:-
cat /dev/null > nullfile

Que:- Access common commands quicker ?


Ans:-

Que:- Display the page size of memory ?


Ans:-
pagesize -a

Que:- Display Ethernet Address arp table ?


Ans:-
arp –a
ifconfig -a|tail -1

Que:- Display the no.of active established connections to localhost ?


Ans:-
netstat –a |grep EST

Que:- Display the state of interfaces used for TCP/IP traffice ?


Ans:-
netstat -i
Que:- Display the parent/child tree of a process ?
Ans:-
ptree

Que:-Show the working directory of a process ?


Ans:-
pwdx

Que:- Display the processes current open files ?


Ans:-
pfile

Que:- Display the inter-process communication facility status ?


Ans:-
ipcs -a

Que:- Display the top most process utilizing most CPU ?


Ans:-
top –b 1 in linux

Que:- Alternative for top command ?


Ans:-
prstat -a

Que:- How do you find out what’s your shell?


Ans:-
echo $0, echo $SHELL

Que:- What’s the command to find out today’s date?


Ans:-
date

Que:- What’s the command to find out users on the system?


Ans:-
cat /etc/passwd|awk –F”:” ‘{print $1}’

Que:- How do you find out the current directory you’re in?
Ans:-
pwd

Que:- How do you remove a file?


Ans:-
rm filename

Que:- How do you find out your own username?


Ans:-
whoami

Que:- How do you send a mail message to somebody?


Ans:- using mailx command in solaris

Que:- How do you count words, lines and characters in a file?


Ans:
Via “wc” command.
wc –c file –-count how many character available in this file.
wc –w file –-count how many word are available in this file.
wc –l file –count how many line are available in this file.

Que:- How do you search for a string inside a given file?


Ans:-
Via “grep” command
grep –i “sting” file_name

Que:- How do you search for a string inside a directory?


Ans:-
Via “find” command
find / -type f –exec grep –i “sting_name” {} \;

Que:- How do you search for a string in a directory with the subdirectories recursed?
Ans:-
find /path/name –name filename*|xargs grep word

Que:- What are PIDs?


Ans:
Process ID every process have Unique id.

Que:- How do you list currently running process?


Ans:-
Current Shell Process we use “ps” and for all process we use “ps –aef”

Que:- How do you stop a process?


Ans:-
kill -23 pid of process “23” is the signal of stop process”

Que:- How do you find out about all running processes?


Ans:-
ps -aef

Que:- How do you stop all the processes, except the shell window?
Ans:-
Que:- How do you fire a process in the background?
Ans:-
sh filename.sh & OR sh filename.sh Press Enter button and then type “bg” command.

Que:- How do you refer to the arguments passed to a shell script?


Ans:-
In the file we use $1 $2 $3 $4 it get four argument from the command line

Que:- What’s the conditional statement in shell scripting?


Ans:-
if-then-else-fi

Que:- How do you do number comparison in shell scripts?


Ans:-
In the if and while condition we use –gt, -eq, -ne, <=, >=, !=, == etc

Que:- How do you test for file properties in shell scripts?


Ans:-
we use the options in the if block are ::
-s:- check if file size is greater than zero.
-z:- check if the string size is null.
-n:- True if the length of string is non-zero.
-f:- check it is file or not and check is exist or not.
-d:- check the directory.
-r:- if the file exist and read-only mode.
–w:- if the file exist and writable mode.
-x:- if the file exist and executable mode. Etc

Que:- How do you do Boolean logic operators in shell scripting?


Ans:-
-o –a !=

Que:- How do you find out the number of arguments passed to the shell script?
Ans:-
echo $#

Que:- What’s a way to do multilevel if-else’s in shell scripting?


Ans:-
if [condition]
then
Statement;
else
If [condition]
then
Statement;
else
Statement;
fi
fi

Que:- How do you write a for loop in shell?


Ans:-
for i in {1..10}
do
echo $i
done

Que:- How do you write a while loop in shell?


Ans:-
i=1
while [ 1 –lt 10 ]
do
echo $i
done

Que:- How does a case statement look in shell scripts?


Ans:-
case $i in
1) echo hello one;;
2) echo hello two;;
3) echo hello three;;
*) echo defult;;
esac

Que:- How do you read keyboard input in shell scripts?


Ans:-
read variable

Que:- How do you define a function in a shell script?


Ans:-
#!/bin/bash
function name
{
echo “Hello Dear are you Ok.”
}
OR
name()
{
Statements
}
For calling the function if u define a function in file.env file the you have to source the file in the
execution script and call the function by its name.
For Example:
vi file.sh
. /path/file.env – source the .env file.
name – Name of the function.
~
~
:wq

Que:- How does getopts command work?


Ans:-
getopts obtains options and their arguments from a list of parameters that follows the standard POSIX.
Typically, shell scripts use getopts to parse arguments passed to them. When you specify args on the
getopts command line, getopts parses those arguments instead of the script command line.
For Example:
while getopts d:s o
do
case "$o" in
d) seplist="$OPTARG";;
s) paste=hpaste;;
[?]) print >&2 "Usage: $0 [-s] [-d seplist] file ..."
exit 1;;
esac
done

Each time it is invoked, the getopts utility shall place the value of the next option in the shell variable
specified by the name operand and the index of the next argument to be processed in the shell
variable OPTIND . Whenever the shell is invoked, OPTIND shall be initialized to 1.
When the option requires an option-argument, the getopts utility shall place it in the shell variable
OPTARG . If no option was found, or if the option that was found does not have an option-argument,
OPTARG shall be unset.

Que:- The parameters to your script can be passed as -n 15 -x 20. Inside the script, you can iterate
through the getopts array as while getopts n:x option, and the variable $option contains the value
of the entered option.
Ans:-
#!/bin/bash
while getopts n:x option
do
case $option in
n) echo this is a $OPTARG;;
x) echo this VB $OPTARG;;
*) echo default;;
esac
done

Que:- How do you export a function in unix ?


Ans:-
#!/bin/bash
echo “The program of Function Calling”
function fun1()
{
echo “Hello dear are you OK”
}
export –f fun1
fun1 --call function on prompt.
OR
Inside file we need to source that file like:
. function_file_name –- “ .” is the source operator
sh call.sh –execution of script.

Que:- write a shell script to check whether all the directories in the path exist has read and write
permission Explain how you Automate your application using Shell scripting.
Ans:-
Just use a find command Like:
find /path/path/ -type d –perm -222 –print
So, via this u can get the information.

Que:- In a single command how do you run the previous command in the command prompt.
Ans:-
!n --n where “!” for last execution command where command name start from “n” character.

Que:- Where cron file kept?


Ans:-
If root edits the files directly, changes will not take effect in most cases and can even be lost. With
most versions of cron, the answer to the question is "in memory". Those files are read only as cron
starts up. The alternative would be to reread them every minute which would put quite a load on the
system. It is critical that you use the crontab command to view and change those files. The crontab
command interacts with cron to change the tables in cron's memory. And it creates a file every time in
the tmp directory for security purpose. When users open crontab –l then file name is show different
name so u open it many time then filename come diff again and again.

Que:- How u convert string "hi pravin how are you?" to "Hi Pravin How Are You?"
Ans:-
echo “hello unix programming” |sed 's/ [a-z]/\U&/g'|sed 's/^[a-z]/\U&/g'

Que:- How can I Debug a shell scripts and Perl scripting. (at the compile time error or run time
error) in Unix environment ?
Ans:-
sh –n filename.sh – compile time for syntax error.
set –x in shell script for debugging script.
perl –d program.pl

Que:- How to delete all the files with extension .dat from a directory tree from root to third level
in a single unix command?
Ans:-
Specified the three level directure in the file.lst file and write the file.sh script
cat file.lst|while read line
do
cd $line
rm *.dat
done

OR
find /path/ –maxdepth 3 –exec rm –f {} /;

Que: - Create a bash shell script to sort and then uniq the file from the command line and store it
to a new file and output the results to the screen. Name this script "sortAndUniq.sh"
Ans:-
cat file.txt|sort|uniq 2> outputfile.txt ; cat outputfile.txt

Que:- How do you list the files in an UNIX directory while also showing hidden files?
Ans:-
ls –ltra
Que:- How do you execute a UNIX command in the background?
Ans:-
Use the "&"
Que:- What UNIX command will control the default file permissions when files are created?
Ans:-
Umask
Que:- Explain the read, write, and execute permissions on a UNIX directory.
Ans:-
Read: allows you to see and list the directory contents.
Write: allows you to create, edit and delete files and subdirectories in the directory.
Execute: gives you the previous read/write permissions plus allows you to change into the directory
and execute programs or shells from the directory.
Que:- the difference between a soft link and a hard link?
Ans:-
A symbolic (soft) linked file and the targeted file can be located on the same or different file system
while for a hard link they must be located on the same file system.
Que:- Give the command to display space usage on the UNIX file system.
Ans:-
df –lk
Que:- Explain iostat, vmstat and netstat.
Ans:-
Iostat: reports on terminal, disk and tape I/O activity.
Vmstat: reports on virtual memory statistics for processes, disk, tape and CPU activity.
Netstat: reports on the contents of network data structures.
Que:- How would you change all occurrences of a value using VI?
Ans:-
Use :%s///g
Que:- What is the use of "shift" command in passing parameters?
Ans:-

Que:- What is the need of including script interpreter in your shell script?
Ans:-

Que:- what is the use of "exec" command?


Ans:-
Que:- How to create environment variables? What are the conditions for creating variables?
Ans:-

Que:- What is Path variable? What is its use?


Ans:-

Que:- In which variable prompt value is stored?


Ans:- PS1

Que:- How to modify the PATH variable and make it executable?


Ans:- export and edit in /etc/profile because it is global executable file.

Que:- How to change our default shell?


Ans:-

Que:- What are environment variables?


Ans:- echo $PATH, $SHELL

Que:- What are the different shells available?


Ans:-

Que:- How to modify the PATH variable and make it executable?


Ans:-

Que:- When you login to a c shell, which script would be run first?
Ans:- .profile

Que:- What is the difference between a 'thread' and a 'process'?


Ans:-

Que:- What are the three main forms of enabling debugging in a shell script?
Ans:-

Que:- How Connect to a Database in Shell Programming?


Ans:- vi connect.sh
Sqlplus –s scott/tiger<<EOF
Set feedback off
Set heading off
Select ename from emp where empno=7900;
EOF

Que:- What is the most important UNIX command?


Ans:-

Que:- How do I create a directory?


Ans:- mkdir dir_name

Que:- How do I find out what processes are running?


Ans:- ps -aef

Que:- How do I exit Emacs/How do I exit vi?


Ans:- escap :q
Que:- What does the grep command do?
Ans:- using grep command we can search pattern from a file.

Que:- How do I stop a process?


Ans:- kill -24 process pid

Que:- How do I test for the presence of a file in Bourne Shell?


Ans:-

Que:- In a shell script, how do I print the scripts arguments?


Ans:- echo $*

Que:- How do you make a shell-script executable?


Ans:- chmod +x script_name

Que:- What is the difference between ' ` and "?


Ans:-

Que:- How do I connect processes, so stdout of one becomes stdin of another?


Ans:-

Que:- How do I redirect stderr under a Bourne Shell?


Ans:- ls –lrt 2> /tmp/abc

Que:- How do I determine the home directory of a user in a shell script?


Ans:- echo $PWD

Que:- What is a regular expression?


Ans:- grep , egrep, fgrep, sed

Que:- Explain shell job control. fg,bg,&amp;,^Z


Ans:- fg – it means forground if any process running in back ground then using fg is come in
forground
bg – it send the process in background
^Z- means it suspend the process which are running in forground

Que:- Whats the differences between a Bourne and C-Shell?


Ans:-

Que:- How are new processes created?


Ans:- using fork command in UNIX

Que:- How do I find out who is logged into the system?


Ans:- who –T

Que:- What are the fields in the password file?


Ans:-

Que:- What steps to setup a new user?


Ans:- useradd –md /export/home/user_name -s /bin/bash user_name
Que:- What directory is typically used as scratchspace?
Ans:-

Que:- How do I stop a UNIX system?


Ans:-

Que:- Name some top-level (under /) directories?


Ans:-

Que:- How do I install a new printer?


Ans:-

Que:- What does fsck do?


Ans:- fsck checking all file system and repair those

Que:- Explain the concept of virtual memory?


Ans:-

Que:- what kind of permission would "chmod 755" yeild on a file?


Ans:- owner can read, write , execute
Group can read and execute
Other can read and execute

Que:- What is an "s" in a file's permission mean?


Ans:- setuid

Que:- What does a "b" as the first letter of a file's permissions mean?
Ans:- block special file.

Que:- How do I make a new disk available for files?


Ans:-

Que:- If I'm logged in as root, what command lets me "become" another user id?
Ans:- su – user_name

Que:- What's the difference between "su" and "su -"?


Ans:- su its not login with users home directory.
Su – its login with users home directory.

Que:- What command will tell me how busy the system is? (load average)
Ans:- top, prstat,mpstat, iostat

Que:- How do I see what print jobs are pending?


Ans:- job –l

Que:- How do I setup a printer?


Ans:-

Que:- What's the startup files for the C shell (or Bourne)?
Ans:- .login.cshrc file
Que:- What is /etc/aliases?
Ans:-

Que:- How can we find out What's the current version of your OS?
Ans:- uname –r

Que:- What is /etc/inittab?


Ans:- its file read on startup time when our O/S is start

Que:- Where is the "main" mail configuration file for a system?


Ans:-

Que:- What is the first process to start on a UNIX system, after the kernel?
Ans:- init , shedular

Que:- What is an inode?


Ans:- inode is number which are point to a particular file in UNIX

Que:- What does the ipcs command do?


Ans:- it is display Interprocess communication

Que:- What is the Changed time on an inode/file mean?


Ans:-

Que:- What's an indirect block?


Ans:-

Que:- What is an X Server?


Ans:-

Que:- What are two X Clients?


Ans:-

Que:- What is RAID?


Ans:-

Que:- How do I change the priority of a process?


Ans:- using renice command in UNIX renice 20 pid

Que:- What is a web server? What is a web client?


Ans:-

Que:- How can I copy a file from one system to another?


Ans:- cp /u01/abc.txt /u02/abc.txt

Que:- What command lets me remotely log into another system?


Ans:- telnet, ssh, rlogin

Que:- Give an example of a domain name?


Ans:-

Que:- Give an example of a host name?


Ans:-

Que:- What is an IP address?


Ans:-

Que:- What is a subnet?


Ans:-

Que:- What is a MAC accress?


Ans:-

Que:- What is a hub?


Ans:-

Que:- How do I test to see if a system is setup on the network correctly?


Ans:- using ping command

Que:- How do I display the route table?


Ans:- arp –a

Que:- What's in the inetd.conf file?


Ans:-

Que:- What is DNS?


Ans:-

Que:- What features of Anonymous FTP make it secure?


Ans:-

Que:- What is NSLOOKUP? tool for querying names/addresses in DNS


Ans:-

Que:- What are RPC's? Remote Procedure Calls


Ans:-

Que:- What is an A record?


Ans:-

Que:- What is an MX record? mail domain mapping record


Ans:-

Que:- What is NFS?


Ans:-

Que:- How do I setup a system as an NFS server?


Ans:-

Que:- How do I setup a system as an NFS client?


Ans:-

Que:- What is SMTP?


Ans:-
Que:- What is traceroute?
Ans:-

Que:- How does traceroute work?


Ans:-

Que:- What are shadow passwords?


Ans:-

Que:- What is an rhosts file? Why is it bad?


Ans:-

Que:- Why are set-uid shell scripts a bad idea?


Ans:-

Que:- What is SSH?


Ans:- it is a secure shell login

Que:- Explain (briefly) Kerberos?


Ans:-

Que:- What is the problem with running fingerd(1)?


Ans:-

Que:- Who is CERT? What do they do? Computer Emergency Response Team, issue advisories
Ans:-

Que:- What does the @ in a variable indicate? its an array


Ans:- it holds all values

Que:- What is a Hash? a key-data pair type of array variable


Ans:-

Que:- Why * is proceeded by ?


Ans:-

Que:- What are different types of shells


Ans:-

Que:- How to execute shell script?


Ans:- sh script_name , ./script_name

Que:- Explain syntax of for loop?


Ans:- for a in {1..10}
do
echo $a
done

Que:- How arithmetic operations are done in Shell?


Ans:- using expr and bc command in shell scripts
Que:- How to combine echo &amp; read?
Ans:-

Que:- Explain syntax of while loop?


Ans:- i=1
While [ $i –lt 10 ]
Do
Echo $i
I=`expr $i + 1`
done

Que:- How to check whether the given string is file or not?


Ans:- using if conditions

Que:- Which command is used for copying a file?


Ans:- cp command

Que:- Explain the syntax of command used for renaming the file?
Ans:- mv command

Que:- Which command is used to list files in Directory


Ans:- ls command

Que:- What vi stands for?


Ans:-

Que:- Which command is used for display file?


Ans:- ls –l |grep ^-

Que:- Which command is used to count the no. of lines?


Ans:- cat file_name |wc -l

Que:- Explain the syntax of wc?


Ans:- wc means word count
Option- l for line
C for character
W for word
Syntax wc –l file_name

Que:- What is shell?


Ans:- shell is interpreter which are interpret with user and kernels

Que:- Explain the syntax of if Conditional Stmt?


Ans:-
If [ 1 –gt 2 ]
then
echo TRUE
else
echo FALSE
fi
Que:- What is vi editor?
Ans:-
Que:- How to know what permission the file or directory has?
Ans:-

Que:- Which command is used to list file in given directory along with permission?
Ans:-

Que:- What is the purpose of sort command?


Ans:-

Que:- Explain syntax of cmp command?


Ans:-

Que:- How to know how many users are currently log in?
Ans:-

Que:- What is pwd?


Ans:-

Que:- Explain the syntax of switch case statement?


Ans:-

Que:- Which command is used for linking a file?


Ans:-

Que:- What do you mean by linking a file?


Ans:-

Que:- Which command is used for displaying time?


Ans:-

Que:- Which command is used to search a pattern in given file?


Ans:-

Que:- Explain syntax of cat command?


Ans:-

Que:- What are the three modes of vi editor?


Ans:-

Que:- Which commands are used to perform copy &amp; paste operations in vi editor?
Ans:-

Que:- What is kernel?What are the various shell responsibilities?


Ans:-

Que:- What are the various shell commands?


Ans:-

Que:- What is the procedure to create &amp; execute C program in Unix?


Ans:-
Que:- What is system calls? System call provide interface between programme and kernel.
Ans:-

Que:- Explain the syntax of open() &amp; read() system calls?


Ans:-

Que:- What is the purpose of lseek system call?


Ans:-

Que:- Where the object code of c program is getting saved in unix?


Ans:-

Que:- Explain opendir() system call?


Ans:-

Que:- What are the various options that can be used with ls command?
Ans:-

Que:- Explain different uses of cat command?


Ans:-

Que:- What is the purpose of mv command? Rename file


Ans:-

Que:- What are the various elements of different structure?


Ans:-

Que:- What is inode table? What all information it consist of regarding files?
Ans:-

Que:- How to know the inode has no. of a particular file?


Ans:-

Que:- How we can access the inode table?


Ans:-

Que:- What is the pipeline? Explain with Example?


Ans:-

Que:- $who | wc l what will be the output of this command?


Ans:-

Que:- Pipeline is example of which redirection?


Ans:-

Que:- What is input &amp; output of redirection?


Ans:-

Que:- How can we declare in variable as integer in bash shell or declared in korn shell as integer?
Ans:-

Que:- What is the use of "shift" command in passing parameters?


Ans:-

Que:- What is the need of including script interpreter in your shell script?
Ans:-

Que:- what is the use of "exec" command?


Ans:-

Que:- How to create environment variables?What are the conditions for creating variables?
Ans:-

Que:- What is Path variable?What is its use?


Ans:-

Que:- In which variable prompt value is stored?


Ans:-

Que:- How to modify the PATH variable and make it executable?


Ans:-

Que:- How to change our default shell?


Ans:-

Que:- What are environment variables?


Ans:-

Que:- What are the different shells available?


Ans:-

Que:- How to modify the PATH variable and make it executable?


Ans:-

Que:- When you login to a c shell, which script would be run first?
Ans:-

Que:- What is the difference between a 'thread' and a 'process'?


Ans:-

Que:- What are the three main forms of enabling debugging in a shell script?
Ans:-

Que:- How Connect to a Database in Shell Programming?


Ans:-

Que:- What is the most important UNIX command?


Ans:-

Que:- How do I create a directory?


Ans:-

Que:- How do I find out what processes are running?


Ans:-
Que:- How do I exit Emacs/How do I exit vi?
Ans:-

Que:- What does the grep command do?


Ans:-

Que:- How do I stop a process?


Ans:-

Que:- How do I test for the presence of a file in Bourne Shell?


Ans:-

Que:- In a shell script, how do I print the scripts arguments?


Ans:-

Que:- How do you make a shell-script executable?


Ans:-

Que:- What is the difference between ' ` and "?


Ans:-

Que:- How do I connect processes, so stdout of one becomes stdin of another?


Ans:-

Que:- How do I redirect stderr under a Bourne Shell?


Ans:-

Que:- How do I determine the home directory of a user in a shell script?


Ans:-

Que:- What is a regular expression?


Ans:-

Que:- Explain shell job control. fg,bg,&amp;,^Z


Ans:-

Que:- Whats the differences between a Bourne and C-Shell?


Ans:-

Que:- How are new processes created?


Ans:-

Que:- How do I find out who is logged into the system?


Ans:-

Que:- What are the fields in the password file?


Ans:-

Que:- What steps to setup a new user?


Ans:-
Que:- What directory is typically used as scratchspace?
Ans:-

Que:- How do I stop a UNIX system?


Ans:-

Que:- Name some top-level (under /) directories?


Ans:-

Que:- How do I install a new printer?


Ans:-

Que:- What does fsck do?


Ans:-

Que:- Explain the concept of virtual memory?


Ans:-

Que:- what kind of permission would "chmod 755" yeild on a file?


Ans:-

Que:- What is an "s" in a file's permission mean?


Ans:-

Que:- What does a "b" as the first letter of a file's permissions mean?
Ans:-

Que:- How do I make a new disk available for files?


Ans:-

Que:- If I'm logged in as root, what command lets me "become" another user id?
Ans:-

Que:- What's the difference between "su" and "su -"?


Ans:-

Que:- What command will tell me how busy the system is? (load average)
Ans:-

Que:- How do I see what print jobs are pending?


Ans:-

Que:- How do I setup a printer?


Ans:-

Que:- What's the startup files for the C shell (or Bourne)?
Ans:-

Que:- What is /etc/aliases?


Ans:-

Que:- How can we find out What's the current version of your OS?
Ans:-

Que:- What is /etc/inittab?


Ans:-

Que:- Where is the "main" mail configuration file for a system?


Ans:-

Que:- What is the first process to start on a UNIX system, after the kernel?
Ans:-

Que:- What is an inode?


Ans:-

Que:- What does the ipcs command do?


Ans:-

Que:- What is the Changed time on an inode/file mean?


Ans:-

Que:- What's an indirect block?


Ans:-

Que:- What is an X Server?


Ans:-

Que:- What are two X Clients?


Ans:-

Que:- What is RAID?


Ans:-

Que:- How do I change the priority of a process?


Ans:-

Que:- What is a web server? What is a web client?


Ans:-

Que:- How can I copy a file from one system to another?


Ans:-

Que:- What command lets me remotely log into another system?


Ans:-

Que:- Give an example of a domain name?


Ans:-

Que:- Give an example of a host name?


Ans:-

Que:- What is an IP address?


Ans:-
Que:- What is a subnet?
Ans:-

Que:- What is a MAC accress?


Ans:-

Que:- What is a hub?


Ans:-

Que:- How do I test to see if a system is setup on the network correctly?


Ans:-

Que:- How do I display the route table?


Ans:-

Que:- What's in the inetd.conf file?


Ans:-

Que:- What is DNS?


Ans:-

Que:- What features of Anonymous FTP make it secure?


Ans:-

Que:- What is NSLOOKUP? tool for querying names/addresses in DNS


Ans:-

Que:- What are RPC's? Remote Procedure Calls


Ans:-

Que:- What is an A record?


Ans:-

Que:- What is an MX record? mail domain mapping record


Ans:-

Que:- What is NFS?


Ans:-

Que:- How do I setup a system as an NFS server?


Ans:-

Que:- How do I setup a system as an NFS client?


Ans:-

Que:- What is SMTP?


Ans:-

Que:- What is traceroute?


Ans:-
Que:- How does traceroute work?
Ans:-

Que:- What are shadow passwords?


Ans:-

Que:- What is an rhosts file? Why is it bad?


Ans:-

Que:- Why are set-uid shell scripts a bad idea?


Ans:-

Que:- What is SSH?


Ans:-

Que:- Explain (briefly) Kerberos?


Ans:-

Que:- What is the problem with running fingerd(1)?


Ans:-

Que:- Who is CERT? What do they do? Computer Emergency Response Team, issue advisories
Ans:-

Que:- What does the @ in a variable indicate? its an array


Ans:-

Que:- What is a Hash? a key-data pair type of array variable


Ans:-

Que:- Why * is proceeded by ?


Ans:-

Que:- What are different types of shells


Ans:-

Que:- How to execute shell script?


Ans:-

Que:- Explain syntax of for loop?


Ans:-

Que:- How arithmetic operations are done in Shell?


Ans:-

Que:- How to combine echo &amp; read?


Ans:-

Que:- Explain syntax of while loop?


Ans:-

Que:- How to check whether the given string is file or not?


Ans:-

Que:- Which command is used for copying a file?


Ans:-

Que:- Explain the syntax of command used for renaming the file?
Ans:-

Que:- Which command is used to list files in Directory


Ans:-

Que:- What vi stands for?


Ans:-

Que:- Which command is used for display file?


Ans:-

Que:- Which command is used to count the no. of lines?


Ans:-

Que:- Explain the syntax of wc?


Ans:-

Que:- What is shell?


Ans:-

Que:- Explain the syntax of if Conditional Stmt?


Ans:-

Que:- What is vi editor?


Ans:-

Que:- How to know what permission the file or directory has?


Ans:-

Que:- Which command is used to list file in given directory along with permission?
Ans:-

Que:- What is the purpose of sort command?


Ans:-

Que:- Explain syntax of cmp command?


Ans:-

Que:- How to know how many users are currently log in?
Ans:-

Que:- What is pwd?


Ans:-

Que:- Explain the syntax of switch case statement?


Ans:-
Que:- Which command is used for linking a file?
Ans:-

Que:- What do you mean by linking a file?


Ans:-

Que:- Which command is used for displaying time?


Ans:-

Que:- Which command is used to search a pattern in given file?


Ans:-

Que:- Explain syntax of cat command?


Ans:-

Que:- What are the three modes of vi editor?


Ans:-

Que:- Which commands are used to perform copy &amp; paste operations in vi editor?
Ans:-

Que:- What is kernel?What are the various shell responsibilities?


Ans:-

Que:- What are the various shell commands?


Ans:-

Que:- What is the procedure to create &amp; execute C program in Unix?


Ans:-

Que:- What is system calls? System call provide interface between programme and kernel.
Ans:-

Que:- Explain the syntax of open() &amp; read() system calls?


Ans:-

Que:- What is the purpose of lseek system call?


Ans:-

Que:- Where the object code of c program is getting saved in unix?


Ans:-

Que:- Explain opendir() system call?


Ans:-

Que:- What are the various options that can be used with ls command?
Ans:-

Que:- Explain different uses of cat command?


Ans:-
Que:- What is the purpose of mv command? Rename file
Ans:-

Que:- What are the various elements of different structure?


Ans:-

Que:- What is inode table? What all information it consist of regarding files?
Ans:-

Que:- How to know the inode has no. of a particular file?


Ans:-

Que:- How we can access the inode table?


Ans:-

Que:- What is the pipeline? Explain with Example?


Ans:-

Que:- $who | wc l what will be the output of this command?


Ans:-

Que:- Pipeline is example of which redirection?


Ans:-

Que:- What is input &amp; output of redirection?


Ans:-

Que:- How can we declare in variable as integer in bash shell or declared in korn shell as integer?
Ans:-

Que:- How to make readonly variable in unix?


Ans:-

Que:- Find a particular string in the all current directory file?


Ans:-
find ./ -type f|xargs grep word
find ./ -type f –exec grep hello ‘{}’ \;

Que:- See only files name from the “ls” command.


Ans:-
ls –l |grep –i ^-
ls –l |grep –v ^d
ls –p |grep -v /

Que:- what is the use of mkdirhier and mkdir -p ?


Ans:-
Create a multiple sub directorys in one shot
Example:- mkdir –p rr/y/i/{tt,uu,I,kk/jj/kk/}/jj.
OR mkdirhier rr/y/i/{tt,uu,I,kk/jj/kk/}/jj.
Que:- what does mean total in the output of “ls –l”?
Ans:-
It show the all block size in current directory.

Que:- What is use of character special file and how it’s create?
Ans:-

Que:- What is the use of /var/spool/mail/root file on UNIX?


Ans:-
In Unix OS that file is read by the mail command by default the mail are stored in this file.

Que:-How to delete a “n”th character of a line or string?


Ans:-
sed 's/^\(.\{7\}\).\(.*\)/\1\2/' file.txt
OR
n=2; echo "$line" | sed "s/^\(.\{${n}\}\)./\1/"

Que:- How to delete last two an first two character from a file?
Ans:-
cat file.txt|sed ‘s/^..//
cat file.txt|sed ‘s/..$//’

Que:-How to print second field of a file via sed command?


Ans:-

Que:- How to replace the 3rd character with “-“ character?


Ans:-
echo "Hello word"|sed 's/^\(.\{2\}\)./\1-/'

Que:-How to create a virtual command on unix prompt and then run?


Ans:-
we can do this via “xargs”, “-exec”, “shell name like: ksh, bash, tcsh etc.”
Example:- ls | awk ‘{print “cp “ $1 “ /path1/path2”}’|ksh

Que:- How to find the largest file in current directory and sub directory?
Ans:-
du –h *|sort –rn|head -1 OR In the current directory we can use “ls –lShr”
OR find ./ -printf ‘%s %p\n’|sort –rn|head -5

Que:- what are the inode numbers and how to get the information of a file via inode number?
Ans:-
With the help of “ncheck” command. We can use it only by the Super User (root).

Que:- What is the use of “Stat” and “istat“ command?


Ans:-

Que:- What is the difference between “–n”, ”+n” and “n” in the find command ?
Ans:-
n – It will look only ‘n’th day of file from the current timestamp?
-n – It will look the files from current timestamp to ‘-n’th day.
+n – It will look all the file after ‘+n’ th day.

Que:- What are the orphan and Zombai process?


Ans:-
Orphan process:
An orphan process is a computer process whose parent process has finished or terminated, though itself
remains running.In a Unix-like operating system any orphaned process will be immediately adopted by
the special init system process. This operation is called re-parenting and occurs automatically. Even
though technically the process has the "init" process as its parent, it is still called an orphan process
since the process that originally created it no longer exists.
Zombai process:
On Unix and Unix-like computer operating systems, a zombie process or defunct process is a process
that has completed execution but still has an entry in the process table. This entry is still needed to
allow the parent process to read its child's exit status. The term zombie process derives from the
common definition of zombie — an undead person. In the term's metaphor, the child process has "died"
but has not yet been "reaped". Also, unlike normal processes, the kill command has no effect on a
zombie process.

S-ar putea să vă placă și