Linux and Shell Programming
Test on Linux/Unix and shell programming
Questions
Which command is used to set permissions like read, write, etc. on a file?
- useradd
- chmod
- changemode
- groupadd
- cat
The ___ command is used to display the path of the current directory.
- path
- ls
- mv
- cp
- pwd
Which of the following commands will print a sorted list of users on the screen?
- ls | more
- who | sort
- who | sort > list.txt
- who | wc -l
- who | grep STEVE
Which key(s) is/are used to delete a single character in Vi editor?
- nx
- dd
- G
- x
- u
Which directory contains all the executable files required during the booting process?
- /boot
- /etc
- /dev
- /bin
- /usr
Each 'if' statement in Linux must be closed with a matching
- end if
- else if
- else
- fi
- end
The _____ command executes the given command and stores the standard output of that command in to one or more files.
- wc
- tee
- top
- cal
- ln
Which of the following statements is the correct way of changing the user ID of a user named ABC to 555?
- usermod -u 555 ABC
- usermod -u ABC 555
- usermod 555 ABC
- usermod ABC -u 555
- useradd-u 555 jim
Which command is used to remove an existing environmental variable?
- delete
- remove
- unset
- free
- set
Which of the following statement is used to accept value from the user and store it in a variable?
- print
- read
- echo
- Input
- Get
Which of the following statements is false regarding user defined variables (UDV)?
- The name of a variable can start with an underscore.
- Variable names are case sensitive.
- Variable names must be unique.
- Variable declaration must start with the $ sign.
- Variable names can contain '?'.
Which of the following is not a valid shell script operator?
- -eq
- -ne
- -le
- -gt
- -mt
What will be the output of the above code?
i=5
while test $i != 0
do
echo "$i"
i=`expr $i - 1`
done
- 5 4 3 2 1
- 5 4 3 2 1 0
- 1 2 3 4 5
- 0 1 2 3 4
- 5
Which of the following is not a pre-defined AWK variable?
- FILENAME
- OFS
- EXIT
- NF
- NR
Which command is used to combine the contents of two files?
- merge
- comm
- sort
- join
- uniq
Which of the following statements is false regarding Shell?
- Shell provides user interface.
- Shell is a part of the system kernel.
- It is a command language interpreter.
- Several shells are available for Linux.
- Shell opens up automatically on log on.
Which of the following is not a part of the 'etc/passwd' file?
- Home directory
- Command/shell
- User ID (UID)
- Password
- Access Permissions
Which command is used to extract a column from a text file?
- cut
- paste
- tee
- tr
- man
Which permission allows you to modify the contents of a file?
- read
- write
- execute
- edit
- delete
Which of the following is not a communication command?
- grep
- mail
- mesg
- write
- ping
The head command writes the first ____ lines of a file on the screen.
- 10
- 1
- 5
- 20
- 15
Which form of the 'ls' command is used to display the list of hidden files?
- ls -a
- ls -l
- ls -f
- ls -r
- ls -lS
Which of the following is not a valid process signal with reference to the 'kill' command?
- SIGHUP
- SIGQUIT
- SIGINT
- SIGTSTP
- SIGBREAK
Which wild card character represents a range of characters during pattern search?
- *
- ?
- < >
- { }
- [ ]
What will be the output of the above code?
if [( $x -eq 3 ) -a ( $y -eq 5 -o $z -eq 10 )]
then
echo $x
else
echo $y fi
- Compilation error
- x
- 3
- 5
- y