Shell Ans 1
Shell Ans 1
a) Id
b) Ild
c) Idd
d) Lld
a) UID
b) UUID
c) UD
d) UIID
4. Which command will copy all.jpg files from the current directory to /backup/
directory?
a) ~/
b) /home
c) /
d) /usr
a) rmdir
b) rmd
c) removedir
d) rm -r
a) Lists the first 5 files in the current directory and sorts them alphabetically
b) Lists all files in the current directory that were modified within the last 5
minutes
c) lists the first 5 files in the current directory displaying details including
file transmission and ownership
d) Lists the sizes of the first 5 files in the current directory, sorsed by size
8. Which command will generate an archive of all files in the current directory?
9. What command is used to list all files and directories in the current directory
in Linux?
a) ls
b) cd
c) dir
d) find
declare -i shared_var=0
declare -i num_threads=4
declare -i counter=0
Increment() (
while true
do
break
fi
shared_var+=1
counter+=1
done
main()(
do
increment &
done
wait
main
a) Shared variable: 0
b) Shared variable: 100000
c) Shared variable: 200000
d) The script will encounter an error and terminate prematurely
a) 12350
b) 5
c) 12345
d) 10
a) bash
b) csh
c) jsh
d) zsh
17.Which command can be used to create a new file with read-write
permissions for the owner only, named 'newfile.txt' in the current directory?
18. What will be the output of the below code when values of p = 12, q = 14,
and r = 11?
read p
read q
read r
then
else
if test $q -gt $r
then
else
fi
fi
Answer : q is greater
19.
#!/bin/sh
cat $1 | sort |
doif [ $prev!=$line ]
fi
prev=$linedone
read p
read q
x='expr $p + $q
echo $x
Answer
a) -2
b) 26
c) 2
d) 12 14
21. Which command will enable shell to correct minor mistakes, for example to
execute cd test instead of (incorrect) cd terst?
a) set AUTOCORRECT='yes'
b) shopt -s cdspell
c) export CORRECT_DIR='yes'
d) unset STRICT_MODE
22. What is the output of the following command?
a) Hel
b) ello
c) llo
d) Lo W
a) List of all files with .txt extensions, size greater than 5 MB and owned by
root user in the root directory and sub-directories
b) List of all files with .txt extensions, size less than 5 MB and owned by root
user in the root directory and sub-directories
c) List of all files with .txt extensions, size greater than 5 MB and owned by non-
root user in the root directory and sub-directories
d) List of all files with .txt extention size less than 5MB and owned by non-root
users in the root directory and sub-directories
24.Which one of the following commands changes the directory to the
a) cd~
b) cd/
c) cd.
d) cd $
b) mk dirname
c) mk file dirname
d) newdir dirname
27. What does the command 'Is -I | head -n +5° do?
a) Lists the first 5 files in the current directory and sorts them alphabetically
b) Lists all files in the current directory that were modified within the last 5
minutes
c) Ousts the first 5 files in the current directory displaying details
including file Permission and ownership
d) Lists the sizes of the first 5 files in the current directory, sorted by size
28. Which of the following commands is used for finding the maximum
numbers of open files in the system
a) max-open-files
b) limit -n
c) ulimit -n
d) maxfiles
29. Which of the following commands used to find and replace all occuranced
of a string ‘old string’ with ‘new string’ in the file.txt
chmod
31. Which command is used to display the no.of words in the file
named 'example.txt'?
wc -w example.txt