+ All Categories

Unix

Date post: 10-Sep-2014
Category:
Upload: jayant-agarwal
View: 593 times
Download: 2 times
Share this document with a friend
Popular Tags:
39
UNIX POINTS TO REMEMBER 1) Unix is a multiuser multitasking operating system. 2) Everything in Unix is treated as files.Including devices like printers,RAM etc 3) Unix can have multiple shells but only one kernel. 4) Shell is a command interpreter.It basically interpretes the command for the kernel and calls the kernel using system call functions. The kernel then performs the required action and returns the control to the shell. For eg : When we type a command using a metacharacter,the shell interprets that metacharacter and then passes it on to the kernel. In the case of rm *, the shell replaces * by all the files in the current directory and then passes it on to the kernel. 5) The Unix file system is like an inverted tree structure. 6) Root directory represents the uppermost directory in the file system under which all the files exists.Root is represented by FORWARD SLASH / 7) There are two types of paths one can use to navigate to different directories.Absolute and relative path. Absolute Path and relative Path Say U are in the path home/testing/hello/world/dir/files and U want to navigate to hello directory.We can do that using absolute and relative paths: Absolute: cd /home/testing/hello Relative : cd ../../.. (Note .. represents parent directory)
Transcript
Page 1: Unix

UNIX POINTS TO REMEMBER

1) Unix is a multiuser multitasking operating system.

2) Everything in Unix is treated as files.Including devices like printers,RAM etc

3) Unix can have multiple shells but only one kernel.

4) Shell is a command interpreter.It basically interpretes the command for the kernel and calls the kernel using system call functions. The kernel then performs the required action and returns the control to the shell. For eg : When we type a command using a metacharacter,the shell interprets that metacharacter and then passes it on to the kernel. In the case of rm *, the shell replaces * by all the files in the current directory and then passes it on to the kernel.

5) The Unix file system is like an inverted tree structure.

6) Root directory represents the uppermost directory in the file system under which all the files exists.Root is represented by FORWARD SLASH /

7) There are two types of paths one can use to navigate to different directories.Absolute and relative path. Absolute Path and relative Path Say U are in the path home/testing/hello/world/dir/files and U want to navigate to hello directory.We can do that using absolute and relative paths:

Absolute: cd /home/testing/hello

Relative : cd ../../.. (Note .. represents parent directory)

8) pwd command prints the present working directory. 9) cd is the command to change the directory.

10) cat is the command to concatenate files.

11) Just by simply typing cd would take us to the home directory defined by the $HOME variable.

12) The ls command is used to list files.

13) ls -l command would list files along with their permissions user name and group name and also the size.

Page 2: Unix

14) ls -a command would be used to list hidden files.

15) ls -r command will list files in revese order.

16) ls -i will list files against their inode number.

17) Files and metacharacters: ls * --- Will list all files in current directory. ls a? -- Will list files starting with a and second letter of the filename being any ASCII character. ls a* -- Will list all files beginning with a ls *.* --- WILL list all files with a single dot in between filenames. ls [!abc]art-- Will list files not beginning with a or b or c and next three characters being art. ls [b-dku-z]*-- Will list files beginning with either b-d which is b,c,d or with k or with u-z i.e u,w,x,y,z.

18) mkdir is the command to make directory. 19) rmdir is the command to remove directory.

20) chmod command is used to change the permissions of a file.

21) We can change the permissions of a file using the chmod command using the symbolic and absolute modes

Symbolic mode: chmod a+rwx xyz.doc (Note : a --- all, u --- user , g --- group, o --- others) Absolute mode: chmod 777 xyz.doc (Note : read --- 4 , write --- 2 , execute --- 1)

22) mv command can be used either to rename a file or change the location of a file.

23) There are two types of links : Hard and Soft Link. Hard Link : ln file1 file2 (Here file2 becomes a link for file1.On deletion of file1,file2 can be accessed.) Soft Link : ln -s file1 file2 (Here file2 becomes the soft link of file1 (basically a pointer to file1) hence on deletion of file1,file2 becomes a dangling pointer and the file1 contents are not accessible.)

Page 3: Unix

24) find command is used to find files in the Unix system.

25) grep(global search for regular expression and print) command is used for searching a particular pattern in a file.

grep [options] pattern filename

Example : grep "Testing" Testing.dat --- Will search for the word Testing in the file Testing.dat

26) tr command can be used to translate characters in a file.

27) vi Editor is used as a text editor for files in unix.There are three modes in vi editor

1 --- Command Mode ---- in this mode we can use commands to modify the text of the file.For eg: cw command entered during command mode is used to change a particular word. 2 --- Input mode ---- in this mode we can insert text into the file. 3 --- Last line mde ---- in this mode we can search for a particular pattern in the file.

28) :set nu is the command to number the lines :set showmode shows the mode :se ic used to ignore case

29) We use the fg command to bring a background process to the foreground.

30) nice command is used to reduce the priority of a process.We cannot increase the priority of a command but only reduce it using the nice command.

31) bc is the basic calculator utility in unix. If without setting the scale, 5/2 would result in 2. After setting the scale=2, 5/2 would result in 2.50.

32) Always assign the value of the variable without a space in between. Like name=256 and not name =256 or name= 256 or name = 256. 33) To see all the environmental variables set we can use the set command.

34) If a=5 and b=10 $a + $b would not add the two variables as they are treated as string of characters.In order to add them we use the expression in the backquote `expr $a + $b`.

35) In case of floating point arithmetic we use the bc utility as shown below:

Page 4: Unix

a=13.5, b=1.5 c=`echo $a + $b | bc`

36) export is the command to make the variable global i.e to make it available for all its child shells.

37) Parameters can also be used to pass arguments to a script.

If 1.sh is a script which requires 3 filenames as arguments then 1.sh file1 file2 file3 Here $1 --- file1 $2 --- file2 $3 --- file3 Positional parameters from $1 through $9 are available.For additional parameters the shift command can be used.

1.The File System used by unix is …………. Answer: Hierarchical or Inverted tree file system2.what are the default application programs installed with unix? Like gcc,g++,e.t.c…3.which of the following enforces security scheme?

a)kernelb)shell

4.types of shell available?5.which of the shell allows command history to be tracked??6.file naming conventions?7.what is known as referring a file from root directory?(Absolute path name)8.which command tells about present working directory?9.Options used with ls commands(be through with options of every command)?10.which option along with rm <file_name> will recursively remove the files?11.command used to list the contents of file?12.which option creates directories along path name?13.what are levels in file security?14.symbolic and absolute mode of changing file permissions?15.creating hard and soft link between files using ln?

Page 5: Unix

16.man command usage?17.cat>>file_name ,cat <file_name what will be output?18.cat<file_name | grep “string” emp.dat output??19.use of wildcards in filename?20.cursor movements ?21.screen movements?22.which commands is used for exit terminal without saving?

a)q! b)q c)none..23.command used for getting process id?24.usage of test and [] with if ..else?25.usage of echo statement?26.continue and break statement?27.usage of –gt,-lt,-le,etc…..?28.parameters to shell script??(ex:what is used to get pid of the shell)?29.usage of $#,$0?30.can the mv command be used to rename a file?

1. What is the output of the following Command$ls -R | wc - lw 1>The output of ls command is stored in SampleFile2>The output of wc command is stored in SampleFile3>The output of ls is treated as input to wc and the count is stored in SampleFile4>The output of ls is treated as input to wc and the count is displayed and stored in SampleFileANSWER>3

2. What is the output of the following command$ cat File1>File2>File31>Copies the contents from File1 to File2 and File32>It is a wrong command - gives error3>Copies File1 contents to File34>Copies File1 to File3 and creates an empty file File25>None of themANSWER>4

3. What is the command to Print the searched pattern with the line numbers in File11>$grep -N “Accenture” File12>$grep -nv “Accenture” File13>$grep -n File14>$grep -n “Accenture” File15>All are correct

Page 6: Unix

6>NoneANSWER>4

4. What is the output of the following command$rmdir dir1 dir1/dir2/dir31>deletes dir1 and dir3 directories2>deletes dir1 directory3>deletes dir1 dir2 and dir3 directories4>errorANSWER>4

5. In the vi editor to delete a char1>h2>j3>x4>k5>lANSWER>3

6. To save a file without quitting the vi editor is done using the command1>:q2>:w3>:w!4>:wq5>:q!ANSWER>2

7. What is the output the following command% sort -t “|” +3 -5 Students1>The records will be sorted based on 4th to 5th columns2>The records will be sorted based on 3rd and 5th columns3>The records will be sorted based on 3rd to 5th columns4>The records will be sorted based on 3rd to 4th columnsANSWER>1

8. Unix file system has which of the following file structure1>Tree Structure2>Standard Structure3>Hierarchical Structure4>None of the aboveANSWER>3

9. In unix grep-n command displays the1>Line matching the pattern along with its line number2>Only a count of the line that match a pattern3>Prints out all those lines that do not match the pattern

Page 7: Unix

4>None of the aboveANSWER>1

10. Which of the following represents an absolute path?1>../home/abc.txt2>bin/cat3>abcd/4>/usr/bin/catANSWER>4

11. Kernel Manage1>Entire resources of the system2>Schedules the work done by the CPU3>Enforces the security scheme4>a & b5>b & c6>a b & cANSWER>6

12. Which option of grep displays the count of lines matching the pattern1>-c2>-nc3>-v4>-lc5>-lnANSWER>1

13. You have a file with numerical data in it (i.e file with list of numbers in it). To sort this data which command/method you will prefer most. Assume that list is reasonably small and Quick output is high priority.1>sort <file_name>2>sort –n <file_name>3>Write a C/C++ program. Use quick sort.4>Write a C++ program. Use STL sort algorithmANSWER>2

14. You can always return to your home directory by using the command1>cd /2>cd \3>cd HOME4>cd ..5>cdANSWER>5

Page 8: Unix

15. You are currently placed in “trng” directory placed under the directory “training”. The command to move the file “file1” from “trng” directory to “data” directory placed under the directory “training” is:1>mv file1 data2>mv file1 data/.3>mv file1 ../data/.4>mv ../file1 ../data/.5>mv file1 /data/.ANSWER>3

16. You are currently placed in “data” directory placed under the directory “training”. The command to copy the file “file1” from “data” directory to “trng” directory placed under the directory “training” is:1>cp file1 ../trng/.2>cp file1 /trng/.3>cp ../file1 ../trng/.4>cp file1 /trng/.5>cp file1 trng/.ANSWER>1

17. who | wc –lWhat is the output of the following command if 10 users are connected?1>It will display the list of all the users connected.2>It will display an error in the command3>104>None of the aboveANSWER>3

18. Which unix command gives the number of lines , words and characters.1>cat2>ls3>wc4>grep filenameANSWER>3

19. Which option of sort allows you to sort data in descending order1>-r2>-o3>-f4>None of the aboveANSWER>1

20. Which option of ls will allow you to display the files in reverse order1>r2>-r3>R

Page 9: Unix

4>-R</5>None of the aboveANSWER>2

21. What command do you use to copy files from all sub directories to another directory1>$cp -r Dir1 Dir22>$cp -i Dir1 Dir23>$cp -a Dir1 Dir24>$cp -m Dir1 Dir2ANSWER>1

22. The command used to slice the files horizontally is1>cut2>paste3>head4>catANSWER>3

23. In the following command$paste -d “;:” Student1 Student21>-d stands for define2>-d stands for difference3>-d stands for delimeter4>NoneANSWER>3

24. Which of the following commands will display the names of hidden files ?1>ls –h2>ls –a3>ls –l4>ls –x5>ls –pANSWER>2

25. Which of the following commands will display the details of directories only of the current directory ?1>ls –d2>ls -l | grep “d$”3>ls -l | grep “^d”4>ls -l | grep “d^”5>ls -l | grep “$d”ANSWER>3

26. Which character must be specified at the end of the command in order to execute that command in the background ?1>&

Page 10: Unix

2>^3>%4>$5>#ANSWER>1

27. If there are 5 files in the current directory and if ls -l | wc -l command is given in the current directory, then the output of this command will be1>52>all the filenames will be displayed3>64>all the lines of all the 5 files.5>syntax error will be displayedANSWER>3

28. Which of the following escape sequences can be used to keep the cursor on the same line after displaying the output with echo command ?1>\a2>\b3>\c4>\k5>None of the aboveANSWER>3

29. ln -s <filename><linkfile> will create ----- link to the file1>soft link2>symbolic link3>hard link4>both 1 and 2ANSWER>4

30. __________ is the command to append into the contents of a file1>cat > filename2>cat >> filename3>cat < filename4>cat >>> filenameANSWER>2

31. State TRUE/FALSEUsing 'mv' command can we rename a file1>TRUE2>FALSEANSWER>1

32. Which option of “mkdir” command allows you to create sub-directories in one single statement

Page 11: Unix

1>w2>-w3>p4>-p5>None of the aboveANSWER>4z

33. Which of these expressions shows the proper way to add the directory /usr/bin to your path?1>PATH+=/usr/bin2>PATH=/usr/bin3>$PATH:/usr/bin4>PATH=$PATH:/usr/binANSWER>4

34. Which of these commands will set the permissions on file textfile to read and write for the owner, read for the group, and nothing for everyone else?1>chmod 046 textfile2>chmod 640 textfile3>chmod 310 textfile4>chmod rw r nil textfileANSWER>2

35. Which of the following represents an absolute path?1>../home/abc.txt2>bin/cat3>abcd/4>/usr/bin/catANSWER>4

36. Which of the following pieces of information is not contained in the passwd file?1>A user’s unencrypted password2>A user’s login name3>A user’s preferred shell program4>A user’s group IDANSWER>1

37. Which are the different ways knowing more about the command1>man2>help3>information4>All of the above ANSWER>1

38. State TRUE/FALSE: When you log in, the current directory is set to home directory.1>TRUE

Page 12: Unix

2>FALSEANSWER>1

39. When do we use the command, ps –e1>List full process showing the PPID2>Display All processes including user and system processes3>Dipslay Processes of User4>Displaying all Users processes.ANSWER>2

40. What would happen when a user executes the following command and enters the details as shown below?a) $ cat < test1 <enter>1>The cat command will take each line of the file test1 as input and display it on VDU.2>The cat command will take each line of the file test1 as Output and display it on VDU.3>None of the aboveANSWER>1

Page 13: Unix

Unix & O.S1 $cat <file1>file2-ans file1 is created and contents of file1 is copied to file2

2 $cat <testAfter execution the standard input is reassigned to the default device.

3 Wht connects 2 or more cmds- pipe ( | )4 Wht is used to move one line down in VI editor - j5 Wht is used to delete one line down in VI editor - x6 Wht is used to quit frm VI editor without saving - :q!7 Wht is used to save frm VI editor without quiting - :w8 Both saving & quiting :wq9 $echo$??---will display 0 if the cmd was successful Else 1

10. wht is absolute path?Referring file frm its root directory11. wht is relative path? Referring frm current directoryEg home/ulka.12.no newline \c is used.13.wht cmd is used to move to the next line ?14.\n newlinw is used15.wht is the job of nop hup?the process can continue execution even after the hang up16.wht is PID of init?1(PID process id )17.$ sleep 10 ---it will wait for 10sec18.wht is the o\p of ? Ls-L >data Ls>dataBoth will display the same output19. banner great >great ---great will be enlarged & stored in file name great 20.cat file1>file2>file3Content are copied to both file2 & file321. wht is the PID of current shell? $$22. unix structure is said to be?TREE,HEIRARCHIAL,RELATIONAL23.IF ANY CHANGES IN PERMISSION ARE TO BE DONE FOR A USER who is a owner then the option used is -o for owner(ans)-u for user -g group24. option used with mkdir? Answer is ( -p)

Page 14: Unix

1.1 How do you get help about the command "cp"? help cp man cp cp ? ans:b

1.2 How do you list all the files that are in the current directory?

list all ls -full ls -a ans:c

1.3 How do you rename file "new" in file "old"?

mv new old cp new old rn new old ans:a

1.4 How do you visualize the content of file "not_empty"?

type not_empty cat not_empty more not_empty

Page 15: Unix

ans:b

1.5 How do you create a new directory called "flower"?

newdir flower mkdir flower crdir flower ans:b

UNIX Quiz - Level 2

2.1 What is the command to search all files in your current directory for the word "plasmodium"? a>grep plasmodium * b>find plasmodium -all c>lookup plasmodium * ans:a

2.2 How do you print the first 15 lines of all files ending by ".txt"?

a>print 15 .txt b>cat *.txt -length=15 c>head -15 *.txt ans:c

2.3 Make a copy of file "upper" in the directory two levels up.

a>jump -2 upper b>cp upper ../.. c>cp upper -2/ ans:b

Page 16: Unix

2.4 Count the files you own in all your directories.

a>ls -lR | grep myusername | wc -l b>ls -a | cnt * c>ls -n ~myusername ans:a

2.5 Change the current directory to /usr/local/bin

a>mv /usr/local/bin b>cd /usr/local/bin c>setdir /usr/localbin ans:b

3.1 How do you change the access permission (add group read/write) to all the files in the current directory containing the word "cali" in their names? a>chmod g+rw *cali* b>setperm r+w *cali* c>chmod 0060 *cali* ans:a

Unix 3

3.2 What is the command to find the differences in the lines containing "1999" between the files orig.txt and copy.txt, and add the result to file result.1999

a>diff orig.txt -d copy.txt | grep 1999 > result.1999 b>diffb orig.txt copy.txt | grep 1999 >> result.1999 c>grep 1999 *.txt >> result.1999 ans:b

3.3 How do you tell the server to use your local display (197.42.197.67) for X-windows?

a>set display local b>setenv DISPLAY 192.42.197.67:0.0 c>setdsp x 192.42.197.67 ans:b

3.4 How do you uncompress and untar an archive called "lot_of_thing.tar.Z"

a>tar lot_of_thing.tar.Z | decomp

Page 17: Unix

b>zcat lot_of_thing.tar.Z | tar xvf - c>tar xvf lot_of_thing.tar.Z ans:b

3.5 Create a new file "new.txt" that is a concatenation of "file1.txt" and "file2.txt".

a>cat file1.txt file2.txt > new.txt b>make new.txt=file1.txt+file2.txt c>tail file1.txt | head file2.txt > new.txt ans:a

UNIX QUESTION

1).Which one of the following is the Correct syntax to declare a variable in PL/SQL

 a. variablename datatype := b.declare variable variablename datatype := c.variable variablename datatype := d. variablename variable datatype :=

 Ans:  2).To list all the files and directories of current directory... a. $ls -d b. $ls | grep $"[^d]" c. $ls | grep "[d^]” d. d$ls | grep "[d$]” e. $ls | grep "[$d]” Ans. To list all the files and directories ls is the option. (A) seems to be correct 

Page 18: Unix

3).What is the value of j after execution of this statement?a.Noneb.7c.8d.9 Ans.  4) What will be the output of the following command

.$val1=10; val2=25; $ x:=${val1-val2:=35} $ echo $x;

Ans:

5) What is output of value of x(something like this)a.10b.25c.35d.Errore.No value of x Ans: Error  6). We can remove only one file at a time a. True   b. false Ans: B) False 7). What will be the output of the following command

$echo $? a) Exit status of the previous command.b) Process id of the previous command.c) Previous command status.d) Displays $?

 Ans: Exit status of the previous command 8). What will be the output of the following command

$echo * a) It will display *b) It will display all the files of the current directoryc) It will not display anything ie blankd) Error.

Page 19: Unix

 Ans: B) It will display all the files of the current directory

 9). What will be the output of the following command

$rmdir dir1 dir1/dir2/dir3 a. remove dir1 only

b. remove dir1, dir2 and dir3c. remove only dir3

Ans: Remove dir1 only 10).Which is the correct format to print full month using the date command?a.%mb.%Mc.%Bd.%b Ans: C ---- %B 11).Minimum no. of joins to avoid cartesian products of tables a.n-1; b.n-2; c.n-3;Ans: 12). Which command will give the “WRITE PERMISSION ” to the user a)1 b)2 c)3 d)4 e)5 f)6 g)7 Ans:  13).Which option will print the files in reverse order? a) r b)R c)-r d)-R Ans:  Ans c) -r  14).How will be the declaration of a variable of identical data type ,as student_id of student

Page 20: Unix

a) v_id student_id%TYPEb) student_id number;c) number student_id

Ans:. 

15).Conditional predicates in a trigger bodya) Updatingb) Insertc) Deleted) select

Ans:

16). Raised exceptions are handled in seperate routines calleda) exception handlersb) exception statementc) exception blocksd) excution section

Ans.

17).What does this command will do$cat test.doc

Ans: (a).displays the contents of file test (b).0 (c).1 (d).none.

Ans) a) displays the contents

18) Command to get total no of words,lines,characters from a file 'data'? a) wc –l datab) wc –w datac) wc –c datad) wc data

Ans. D)

19) Exit statement used to terminate from which options – a) switch constructb) if constructc) loop construct d) while construct

Ans : c) loop construct

20) What will the following command will do ?

Page 21: Unix

$cut -c 3-5 data1a) Displays 3 char from 5th positionb) Displays 2 char from 1st position.c) Displays 2 chars from 3rd position.d) Displays 5 chars from 3rd position

Ans: It should display 3rd to 5th characters of every line. None of the options seems ok to me

21)What will be the output of the following commandCat < dataa) Takes output from the file and displays them on stndrd output..b) Takes the values from the stndrd input.c) Displays the contents of the file ‘data’d)none

Ans: c) Displays the contents of the file ‘data’

22) What will be the output of the following command$ ls sample*a)Displays hidden and non hidden files starting with sample.b).displays non hidden files starting with sample.c).displays non hidden files ending with sample.d)displays all files and dir’s starting with sample and after sample.

Ans: d)displays all files and dir’s starting with sample and after sample.

23) What will be the output of the following command $ date;sorta) Displays the system date and then prompts for the user input.b) Takes the system date and waits for the file to be sorted.c) Displays the system date and then prompts filename.d) Error.

Ans: a) Displays the system date and then prompts for the user input. Not sure but make a check

24) What will be the output of the following command echo "The sum isx='expr 20+30' ;echo $x;a)The sum is : 50b) 50c) Error

Page 22: Unix

Ans: Just check whether back quotes are used or single quotes are used. If single quotes are used in expr then error else a) option is the answer

25) Find the error(if possible) in the following snippet of code

Begin  v_ref+10=v_fnum +v_lnum; dbms_output.put_line('sum is',vref); end;{ Choose more than 1 answer}a) = operator can’t be used on the left hand side for the variable

declarations.b) v_ref and v_fun should be declared.c) Incorrect declaration.d) Error.

Ans: 

26) A variable that stores column value needs to have the same name as column (T/F)?Ans:

27) What will the following command doCat>file1> dest1 >dest2 2> dest 3a) file1 contents are in dest3 and dest1 and dest 2 is empty

  b) file1 contents are in dest1 and dest2 and dest3 are empty.d) file1 contents are in dest1 and dest2 and dest3 are empty.

Ans: Not sure

28) What the following command will do$ mkdir –p .\a\b\c

(Not confirmed about the options, please provide the correct answer)

It will create directory a with sub-directory b which will further have sub-directory c.

29) Which one gives the absolute path.a) ..\a\bb) \usr\bin\catc) \bin\cat\d) ..\home\usr\dir

Ans: b

Page 23: Unix

30) Which wild card character will be used to display more than one character.a)*b)[]c) ?d) /e) \

Ans: aits actually zero or more characters

31)What will be the output of the following command.$ rm test[1-3].txta) Remove test1,test2,test3 with .txt extension.b) Removes test1 or test2 or test and ending with .txt.c) Error cannot include range in [].d) Removes test1 and test3.

Ans: Remove test1,test2,test3 with .txt extension.

1. ---------------- option is to list in reverse order.a) –db) –n c) –r d) –a

2. ---------------------command to get information of a command.a) manb) helpc) info d) all of the above

3. To append a file, what is the right way.a) cat>fileb) cat>>filec) cat<<filee) cat<>file

4. Set of environment variablesa) Hone,Path,PS1

Page 24: Unix

b) $Home,$Path,$PS1c) $homed) none of the above

5. -----------------redirects command outa) &amp: >filenameb) :>filenamec) a:>filenamed) none of the above

6. If the value=’ls|grep’;echo $valuea) ls|grep b) “ls|grep”c) errord) none of the above

7. To display the last 20 lines of a filea) tail -20 <filename > b) tail +20 <filename>c) home -20 <filename>d) none of the above.

8. Shell is a -----------------------a) programming languageb) layer between kernel and user c) command interpreterd) all of the above

9. ------------------ is a metacharactera) ?b) \c) *d) $

10.Ending of case block is ----------------

a) esac b) case end c) end d) none of the above

11.Searching for files with specific string using --------------a) findb) grep c) find & grep

Page 25: Unix

d) find grep

12. Shell scripts cannot be used for a) system administrationb) open communicationc) implementing data structured) non-portable application

13. Files are searched based on name and extension using ------------a) find b) search c) grep d) locate

14. Shell scripts begin with a) # b) % c) & d) $

15. #!/bin/bash while[! –z$1] do echo $1; shift done

a) shift is not used peoperlyb) error message no such commandc) syntax errord) run-time error

16. To list the details of a file, using ----------------a) ls b) cd . . c) cd d) none of the above

Note: ls just gives the list of file. ls-l only will give the details of file.

Page 26: Unix

17.Which is a type of shell ?a) Korn b) corn c) hash d) bad

18.Redirection is used for a) inter-process communication. b) to connect one process to another c) d) none of the above

19.To locate the beginning of file with a and ending with a . followed by a number -------------------

a)cat a*. ?? [0-9] b) cat a?? *[0-9] c) cat a*[0-9] d) none of the above

21. Positional parameters where the values are positioned using

e) $1,$2 etc b) $1,2,$3 etc

c) 1

22. Cut –d “ “ –f 5- file1a) 5th field onwards to cut

b) 5th field from the beginning to cut c) 6th field from the end to paste d) none of the above

23. How to end the statement at the end of every case?a) ;;

b); c): d)::

24.export is used for a) making child shells to see their parent shellsb) making sub-programs to see the shell variables

c) none of the above d)for displaying errors

25. #!/bin/sh and #!<whitespace>/bin/sh ----------what is the difference between these two statements?c) nothing

Page 27: Unix

b) syntax error c) run-time error d) all of the above

26. a=20; echo ad) a will be displayed

b) runtime error c) 20 is diaplayed d) syntax error 27. In bash shell, using appropriate commands you have found out list of available jobs process ids, you are interested in one particular process job but unfortunetly it is runnig in the background. How will you make it run in the foreground.

e) I will use cmd %fg.

1) How are shell variables assigned in C shell & Bourne shell(Syntax)

2) How will you find a file and delete directory and execute.Ans: is this syntax correct Find/path-type d- exec command / * { };3) what is true of Inode?

a) there is a unique inode allocated for each active file , each current directory, each mounted on file, text file and the root.

b) An node is “named” by its device/ I-number pairc) An inode is the pid of the current processOptions: 1) a & b 2) a & c

3)b & c4) You have a file with numerical data in it(i.e file with list of

number in it) to sort this data which command/ method you will prefer most. Assume that list is reasonably small and quick o/p is high priority.

a) write a c++ program, use STL sort algorithmb) write a c/c++ program use quick sortc) sort d) sort –n

5) shell scripts cannot be used for which of the following: I sytem administrator II open source applications III implementing data structure

Page 28: Unix

IV non portable applicationsOptions: 1) I & II 2) II & III 3) only III 4) only IV

6) shell is aa) programming languageb) layer between kernel and user c) command interpreterd) all

7) _________ is a meta character a) ? b)\ c)* d)$

8) searching for files with specific string using a) find b)grep c)find & grep d) find grep

9) shell scripts cannot be used for a) system administrationb) open communicationc) implementing data structured) non-portable applicationoptions: i) a and b ii) b and c iii) only c iv) only d

10) what is the o/p? #!/bin/bash while[!-z $1]

doecho $1shiftdone

a) infinite loop with first and the parameter echoed during each loop cycleb) list of all command line parameter passedc) error message/ message indicating no such command for

shiftd) infinite loop with first command line parameter echoed during

each loop cycle.

11)filesa are searched based on name and extension using a) find b)search c)grep d) locate

Page 29: Unix

12) shell scripts begin with a) # b) % c)& d)$

13) # /bin/bashwhile[!-z $1]doecho $1; shiftdone

a) shift is not used propertyb) error message no such command c) syntax errord) run-time error

14) to list the details of a file using a) ls b) ls-l c) cat d)none15) redirection is used for

a) interprocess communicationb) to connect one process to anotherc) none of the above

16) After child process generated immediately what is the PID of ita) 0 b)>1 c) -1 d)none

17) diff between #!/bin/sh and #! <White space>/bin/sha) nothingb) interpreter gives one error on some flavour of unixc) because #! Is a 4 byte magic numberd) b and c

18)I communication between related process II communication between unrelated process III to avoid files in IPC IV none of the above Ans:- a) I & II b) II & III

c) III & IVd) None

19)To locate the beginning of a file with ‘a’ and followed by any character then ‘ . ‘ then 2 characters followed by a number

a) cat a*.??[0-9]b) cat a??*[0-9]c) cat a*[0-9]d) none

20) cut –d “ “ –f5 – file1a) 5th field onwards to cutb) 5th field from beginning to cut

Page 30: Unix

c) 6th field from the end to pasted) none

21) all lines begin with a numbera) ^[0-9]b) [^0-9]c) ^[#]d) ‘[0-9]. * $

22) !#1 bin/bash error is shown on stderr however script

23) export is used fora) making child shells to see their parent shellsb) making sub programs to see the shell variables c) none of the aboved) for displaying errors

24) syntax for tr command to delete a new line from a filea) tr-d ‘\n’ <xyz.txtb) tr-d ‘\r\n’ <xyz.txtc) tr. ‘c\r\n’ <xyz.txtd) tr ‘\n’ <xyz.txt

Note: It must be either a or b, because tr command accepts 2 parameters only.

25)For the command on a execute folder named test /bin/chmod a-x test         a)user will not be able to create any sub-directory         b) user will not be able to list the content of this folder         c) user will not be able to browse through the folder and subfolder         d) all the above 26)  when unix is installed which of the following is automatically installed      a) c++      b)c      c)perl      d) visual Basic

Note: I guess it is C

Page 31: Unix

1>The command which tells how many users are presently logged in?A.WHO

2>Which option creates multiple links in Unix file system?A.ln

5>The command rm test[1-3].txtA.deletes test1.txt,test2.txt,test3.txt

6>which method is used to prevent overriding of files?A.noclobber

11>DATE : 07/06/06$JULY is got by executingA.Date +date %d$b

12> cat test1 test2 test3>test4. what is the output of the following command??If test1 hello Test2 hi Test3 how r uA.hello hi how r u

19>Which is the command which helps to find the location of another command in unix??A.which


Recommended