Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Unix

Download as xlsx, pdf, or txt
Download as xlsx, pdf, or txt
You are on page 1of 14

Question Text Choice1 Choice2

Which command is used to copy files and


directories? copy cp
Which command is used to change permissions
for files and directories? mv chgrp
File names & Inode
The directory file contains ______ File names & File Sizes Numbers
In which drive you can find executable files that
are available to the users? /etc /dev

Which command is/are used to remove directory? rmdir rm -r


Which command is used to list all the files in the
current directory(including hidden)? ls -l ls -t

Choos one of the following action when you give sets write permission to sets write permission to
the command $ chmod o-w datafile? everyone for datafile others for datafile
What are the two types of device files? Character & Block Character & Socket
How do you rename a file? mv old new move old new
The cp command will The sort command by
preserve the meta data of default sorts in the numeric
Which of the following statement is true? the file order
Effective user id can be set using following
permission _____ 777 2666
What does rwx r-x r-- means in octal ? 755 743
The name of the top directory is ________ master top
Which is not one of the 3 classifications of users
granted permissions of files? manager group
Which one of the following is the numeric
equivalent for write permission type? 1 2

Where can I find the printer in the file structure? /etc /dev
Which UNIX command is used to update the
modification time of a file? time modify
Which of the following command is used to
display content of a file in octal format? octal cat
Which of the following command is used to count
number of lines in a file? wc -l wc -c
A user does a chmod operation on a file. Which The last accessed time of The last modification time of
of the following is true? the file is updated the file is updated
The permission -rwxr–r– represented in octal
expression will be ____ 777 666
Binary or executable files are _____ Regular files Device files
Which command is used to mount file system
read only? mount –a mount –v
Which of the following commands are used to
display last 10 line of the file? tail filename tail -10 filename
Which command is used to save and exit in vi
editor? q wq
When compare to word processor the vi
editor_____________ easy to use difficult to use
Which command is used to join current line and
next line in vi editor? J j
Which command is used to undo the last
command? undo un
Which command is used with vi editor to save file
and remain in the editing mode? w e
Which command is used to search text
repeatedly in opposite direction? /text ?text
Which command is used to append text after
current line in Vi Editor? A O
Which command is used to take the cursor into
beginning of current line? 0^

Which command sets the number for all lines? :set li :set ln
Which key need to be pressed to end insert mode
and to get edit mode? Control–C Control-D
The run control file in vi is called ______ .cshrc .virc
vi works in _____ 2 modes 3 modes
Which command is functionally equivalent to the
down arrow key? h j

Which command is used to specify the end of


current line? ^ G
Which command is used in vi editor to search a
pattern in forward direction? ?? //
What sign is used to back up over typing errors in
vi? ! $

Which command is used to close the vi editor? q wq


In vi editor, the key combination CTRL+f used moves to the next page
to_______ down moves to previous page up
Which vi editor command copies the current line
of the file? yy yw

In vi editor, which command reads the content of


another file and inserts it after current line.? read r
Which of the following command moves to edit
mode , adding a line directly above the position of
cursor? A a
Which command is used to delete the current and
next line from current file? dd2 2dd

In vi editor, command ‘ZZ’ does which of the Quits the editing session
following? copy the selected text forgetting all changes
Applications of Shell programming include
_______ Simplifying complex jobs Automating reptitive tasks
Which one of the following is not a valid shell
variable? _san san_2

Choose the examples of repetitive tasks that are


performed by system administrators ? Disk space inventories Security audits
Another term of shell program is _____ Scripts C Programs
Shell programs are ______ Compiled Interpreted
In the shell, by default, all variables are
considered and stored as _____ string integer

Flow control in a shell program allows parts of a


shell program to be executed _______ Repeatedly Conditionally
Which of the following is not a valid login in shell
in linux? C Shell Net Shell
which command is used to print the current
working direcotry? pwd echo $PWD

In Linux which of following command do you use


to know the purpose of a command? which whatis
How do you print the lines between 5 and 10,
both inclusive? cat filename | head | tail -6 cat filename | head | tail -5
Which of the following command can be used as
an alternative to echo command? print printr
Which command is used to change password of
your linux system? password pass
Which command is used to see the list of users
who are currently logged-in? login users
Which command is used to print the login shell of
an user?  echo $SHELL echo $LOGIN

Which is the purpose of id command? Print effective and real UID Print effective and real GID

Choose the format of shell variable declaration? echo $varname echo #varname
What is the meaning of a<<=b if a and b are 2
variables? b = a << b a = a << b

What is the output of following code?


a=2
b=4
c=$( expr a**b )
echo $c
exit 0 8 ab
Which one of the following is bitwise 'exclusive or'
operator? ^= |=
Which command reads user input from the
terminal and assign this value to a variable
name? read get
Which command is used to debug a shell script
program? set set -x
Choose the correct one to print out your current
directory? echo "$pwd" echo '$pwd'

What will be output of following command: The process id


is
$ echo "The process id is" $$$$ The process id is $$ $<pid>$<pid>

What would be the current working directory at


the end of the following command sequence?
$ pwd
/home/user1/proj
$ cd src
$ cd generic
$ cd
$ pwd /home/user1/proj /home/user1/proj/src
What is the output of the following code ?
os=Unix 1.Unix 2.Unix 1.Unix 2.Unix
echo 1.$os 2."$os" 3.'$os' 4.$os 3.Unix 4.Unix 3.$os 4.Unix
What is the return value ($?) of this code?
os = Unix
[$osName = UnixName] && exit 2
[${os}Name = UnixName] && exit 3 0 1

What is the output of the following program?


x = 3; y = 5; z = 10;
if [( $x -eq 3 ) -a ( $y -eq 5 -o $z -eq 10 )]
then
echo $x
else
echo $y
fi 1 3
Which command is used to create a new file
“new.txt” that is a concatenation of “file1.txt” and cat file1.txt file2.txt >
“file2.txt”? cp file.txt file2.txt new.txt new.txt
When the return value of any function is not
specified within the function, what function exit status of the last
returns? nothing command executed
Parameters can be passed to a function using by using the parameter by using the environment
_______ variables $1, $2, $3…… variables

Which of the following command provides the list


of the functions defined in the login session? declare -f declare -F

to define a variable within a to redefine any global


The keyword ‘local’ is used _______ function for its local scope variable

when we invoke a function,


it is already in the shell’s
memory, therefore a
Functions improves the shell’s programmability function runs faster than function provides a piece of
significantly, because _______ seperate scripts code for repetative tasks
Which loop is called a limited loop? while until

Which keyword is used to quit from a function? exit return


What are the different types of commonly used
shells  on a typical linux system? csh ksh

Which symbol is used to access the command


line arguments within shell scriprting? # @

How do you terminate a shell script if statement? endif end if


Which statement is useful when an error has
occurred but you want to try to execute the next
iteration of the loop? break return

Which of the following will always output "maple"? $tree=maple; echo $tree tree = maple ; echo $tree
Which command is used to remove the definition
of a function(sum) from shell? $unset .f sum $unset sum
Which expression use the value of the enclosed
arithmetic expression? $(()) $()

What is the output of the following program?


[ -n $HOME ]
echo $?
[ -z $HOME ] 0 1
echo $? 1 0

What is the output of this program?


#!/bin/sh
a=2
b=4
c=expr $a**$b
echo $c 8 16

for d in unix linux windows ; list=" unix linux windows"


do for t in $list ; do
Which one of the following code will display unix, echo $d echo $t
linux and windows as an output? done done
#!/bin/ksh #!/bin/ksh
myfile=$1 myfile=$1
if [ -f $myfile ] if [ -f $myfile ]
then then
echo "$myfile exists" echo "$myfile exists"
Choose the correct usage of if statement in shell if fi
scripting? exit 0 exit 0
case "dog" in case "cat" in
*) echo cat ;; cat) echo $1
Which of the following will output "cat"? esac exit

How could you check if two strings are equal? test $a -eq $b test $a -equal $b

What will be the output of  "echo this || echo that


&& echo other"? this that

What is the output of this program?


#!/bin/sh
san_function()
{
echo "Welcome to the Sanfoundry"
printf "World of Linux\n"
}
unset -f san_function
san_function
exit 0 Welcome to the Sanfoundry World of Linux

Print the process id of Print the process id of


What is the output of echo $0 ? currently executing script background process
Which command is used to extract specific
columns from the file? grep find
Which command is used to concatenate all files
beginning with the string 'emp' and followed by a
non-numeric characters? cat emp[!0-9] more emp[!0-9]
Which command is used to save the standard
output in a file, as well as display it on the
terminal? cat echo

Which symbol is used to separate more than one


command in the same command line? # $
Which of the following command(s) will print the
output as “$KK”? echo “$KK” echo “$$KK”
Choose the command from the below list that will
give size current directory? df du
How do you find out your own username? user whoisme
How to print top 10 lines in a file? head -10 filename head -11 filename
Which of the following commands is used to
identify the type of file by context? ls cat
Write a Command to list all the links from a
directory? ls | grep "^l" ls –lrt | grep '^l'
How will you find which operating system your
system is running on in UNIX? uname –a oslevel
How do you remove certain lines from unix file.
(Eg From line a to line b)? sed –i '1 d' file.txt sed '2,5 d' file.txt
How do you test a zip file has no errors or not
corrupted? unzip –j file.zip unzip file.zip

Which command is used to copy all files having


the string chap and any two characters after that
to the progs directory? cp chap?? progs cp chap* progs
You can append to a file instead of overwriting by
using the <symbol <<symbol
Which one of the following command(s) will be
needed to make the script executable for the
user? chmod u+x chmod u+r
Which of the following command(s) will change
directory to home directory? cd- cd
How do you count words, lines and characters in
a file? wc -l filename wc -c filename
What is the command will list all the filenames
starts with letter “a”? ls -d [a]# ls [a]*
How to remove directory and sub-directories
recursively? rm -R rm -a
How will you find the 15th line of a file file123
using only tail and head command? tail -n +15 file123 |head -1 tail -99 file123 |head -1
fc stands for ______ find command fix command
Which command is used to reexecute the
previous command? !! !cat
Which command allows to view the current jobs
being handled by the shell? jobs view

a unique number, assigned


What is job number? same as PID to each job in shell
stops the process running in
Ctrl-Z key combination does _____ generates a SIGINT signal the shell
Which command brings a background job into the
foreground? fg bg

Lists the available choices in


kill -L command will _______ a tablar format terminate the last job
Which command terminates a running process by
name of the process? kill pkill
Write standard output to
The redirection 2> abc implies ______ Write file 2 to file abc abc

Write standard output and


cmd 2>&1 > abc will _______ Write file2 to file1 standard error to abc
Which of these is the correct method for
appending “foo” in /tmp/bar file? echo foo > /tmp/bar echo foo >> /tmp/bar
Syntax to suppress the display of command error
and standard output to monitor ? command > &2 command 2> &1
file1 content will be file1 content will be
appended to file2 and finally appended to file2 and file3
cat < file1 >> file2 | file3 means _____ stored in file3 will be ignored

Executing cat /etc/password > /dev/sda as Write data into a regular file Write data to the physical
superuser will _____ called /dev/sda device sda
What command would send the output of cmd1 to
the input of cmd2? cmd1 | cmd2 cmd1 || cmd2
How can you search for blank line in a file? $ grep “ “ file $ grep “^$” file
Which directory contains all the config file of the
system? /etc /var

Which command is used to set the execute


permissions to all the files and subdirectories chmod –r +x chmod –R +x
within the directory /home/user1/direct? /home/user1/direct /home/user1/direct
How many links are created when we create a
directory file? 1 2
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? chmod 046 textfile chmod 640 textfile

Which is an example for character special file? Hard disk CD-ROM


Deletes both the softlink
Deleting a soft-link__________________ Deletes the destination file and the destination file

Choose the available modes/mode in vi editor? command insert

Which command is used to delete the character


before the cursor located in vi editor? X x
Which command searches the string in file
opened in vi editor? / or ? F or f
Which command shows all the abbreviations in vi
editor? abb ab
The vi editor is important to learn because It is the easiest editor to
______ learn It is the newest editor

What are the two separate modes in vi editor? Input and Output Command and Insert
Choice3 Choice4 Choice5

rm cpy

chmod set

File names & Address File names & Permissions

/bin /home

only b both a and b

ls -a ls -i

clears write permission clears write permission to


to everyone for datafile others for datafile
Block & FIFO Input & output
cp old new rn new old
The mv command will
change the meta data of The command ps will display
the file the filesystem usage

4744 1711
754 745
root topdir

owner all others

3 4

/lib /printer

cat touch

oct od

wc -w none of the listed options


The last change time of
the file is updated none of the listed options

744 711
Special files Directory files

mount –f mount –r

both a and b only b

:q! both a and b


Depends on
slower faster the user

join jn

u del

a b

n N
a o

$ #

:set nu :set nl

Escape Key Delete Key


.bashrc .exrc
any number of modes single mode

k l

$ #

? /

# @

both a and b none of the listed options


moves to the next line
down moves to the previous line up

yc none of the listed options

ex none of the listed options

O o

d2 2d

saves the file and quits


the editing session Deletes the current line of text

Both A and B none of the listed options

_san_2 2_san

System backups all of the listed options


Compiled programs Shell command language
Command Processed none of the listed options

character float

Both A & B none of the listed options

Bash Shell Z Shell

Both A and B Only A

what purpose
cat filename | tail +5 |
head cat filename | tail -5 | head -10

printf none of the listed options

change -p passwd

who which

echo $LSHELL none of the listed options


Print effective and real
UID and GID none of the listed options

echo var$name echo varname


none of the
b = b << a a = a << b above

32 none of the listed options

!= none of the listed options

declare set

debug db

echo $pwdplusthis echo "$pwd"plusthis


The process id is
<pid><pid> The process id is $$$$

/home/user1 /home/user1/proj/src/generic

1.Unix 2.Unix 1.Unix 2.$os 3.$os


3.Unix 4.$os 4.$os

2 3

5 error
mv file[12].txt new.txt ls file1.txt file2.txt | new.txt

0 none of the listed options

both (a) and (b) none of the listed options

both (a) and (b) none of the listed options

this is not a valid


keyword none of the listed options

both (a) and (b) none of the listed options


for if

break continue

bash Bourne all the above

$ *

fi if

do continue

tree=maple;
export tree;
export tree = maple; tree=maple; export $tree; sh sh -c "echo
echo $tree -c "echo $tree" $tree"

$remove .f sum $unset -f sum

${} $[]

0 1
0 1

32 none of the listed options

for d in unix linux windows ;


do
echo d
both a abd b done
#!/bin/ksh
myfile $1 #!/bin/ksh
if [ -f $myfile ] myfile=$1
then if [ -f $myfile ]
echo "$myfile exists" echo "$myfile exists"
fi fi
exit 0 exit 0
case (cat
case cat dog rabbit; echo echo cat | case $1 in dog rabbit)
$1 cat) echo $1 ;; esac { echo $2 }

test $a = $b sh -c test $a == $b
this
this that
other other other

both (a) and (b) It will print an error

Print the shell that is Print the number of arguments


being used passed to the script

cut paste cat

more [emp][!0-9] cat emp[x-z]

grep tee more

% ;

echo “\$KK” echo ‘$KK’ both c and d

file size
whoami finger
head 10 filename first -10 filename
none of the
file more above

ls –ltr | grep “$l” ls –ltr | grep “&l”

prtconf –k none of the listed options

sed –i '5,7 d' file.txt sed –d '5,7 d' file.txt

unzip –t file.zip none of the listed options

cp chap??* /progs/* cp chap[12] /progs/*.*


>>symbol >symbol

chmod u+w chmod u+rwx

cd. cd~

wc -c filename wc filename

ls -d [a]* ls -d [aa]*

rm -l none of the listed options

tail 99 file123 |head 1 head -15 /etc/passwd|tail -1


both (a) and (b) none of the listed options

!3 !$

show none of the listed options

both (a) and (b) none of the listed options


kills the process running
in the shell both (a) and (c)

jobs %1 none of the listed options

terminate the first job none of the listed options

killall none of the listed options


Write standard error to
abc none of the listed options

Write standard error to Write standard output to abc &


abc standard error to monitor

echo foo | /tmp/var /tmp/bar < echo foo

command 2> &2 command 2> /dev/null

file2 and file3 will have


same content syntax error
Create a temporary
file /dev/sda and write
data to it none of the listed options

cmd1 && cmd2 cmd1 ; cmd2 cmd1 cmd2


$ grep [“ “] file $ grep [^$] file

/lib /bin

chmod –f –r +x chmod –F +x
/home/user1/direct /home/user1/direct

3 4
chmod 310 textfile chmod rw r nil textfile

Terminal Memory
backup of the destination is
Deletes just the softlink automatically created

command line all of the listed options

D d

T or t none of the listed options

show display
It is available on most
unix systems Both b and c

Edit and Command Input and Command

You might also like