0

Linux and Shell Programming

Attempted 0/25 Correct 0 Score 0

Which command is used to set permissions like read, write, etc. on a file?

  1. useradd

  2. chmod

  3. changemode

  4. groupadd

  5. cat


Correct Option: B
Explanation:

The chmod command changes the access mode of one file or multiple files. The syntax for the chmod command is: chmod [option] mode files. The permission can be set for the user, group and others.

The ___ command is used to display the path of the current directory.

  1. path

  2. ls

  3. mv

  4. cp

  5. pwd


Correct Option: E
Explanation:

The pwd command display the path of the current directory. The full pathname will look something like this

/home/world/asia/india

Which of the following commands will print a sorted list of users on the screen?

  1. ls | more

  2. who | sort

  3. who | sort > list.txt

  4. who | wc -l

  5. who | grep STEVE


Correct Option: B
Explanation:

In this command, the output of the 'who' command is passed to the 'sort' command, therefore it will print sorted list of users.

Which key(s) is/are used to delete a single character in Vi editor?

  1. nx

  2. dd

  3. G

  4. x

  5. u


Correct Option: D
Explanation:

The 'x' key deletes a single character in Vi editor.

Which directory contains all the executable files required during the booting process?

  1. /boot

  2. /etc

  3. /dev

  4. /bin

  5. /usr


Correct Option: D
Explanation:

The /bin directory holds all the executable binary programs (file) required during booting, repairing, files required to run into single-user-mode, and other important, basic commands.

Each 'if' statement in Linux must be closed with a matching

  1. end if

  2. else if

  3. else

  4. fi

  5. end


Correct Option: D
Explanation:

Whenever an 'if' statement is used in Linux, it must be closed using the reverse of 'if', 'fi'.

The _____ command executes the given command and stores the standard output of that command in to one or more files.

  1. wc

  2. tee

  3. top

  4. cal

  5. ln


Correct Option: B
Explanation:

The tee command executes the given command and stores the standard output of that command into one or more files.

Syntax : tee [OPTION]... [FILE]..

Which of the following statements is the correct way of changing the user ID of a user named ABC to 555?

  1. usermod -u 555 ABC

  2. usermod -u ABC 555

  3. usermod 555 ABC

  4. usermod ABC -u 555

  5. useradd-u 555 jim


Correct Option: A
Explanation:

Each Linux user has a unique identification number known as User ID(UID) which is assigned automatically. To change its value, the command 'usermod -u UID username' can be used.

Which command is used to remove an existing environmental variable?

  1. delete

  2. remove

  3. unset

  4. free

  5. set


Correct Option: C
Explanation:

To remove an environmental variable the 'unset' command is used. Usage : unset variablename Example : unset marks

 

Which of the following statement is used to accept value from the user and store it in a variable?

  1. print

  2. read

  3. echo

  4. Input

  5. Get


Correct Option: B
Explanation:

The read statement is used to get input from keyboard and store it to a variable.

Which of the following statements is false regarding user defined variables (UDV)?

  1. The name of a variable can start with an underscore.

  2. Variable names are case sensitive.

  3. Variable names must be unique.

  4. Variable declaration must start with the $ sign.

  5. Variable names can contain '?'.


Correct Option: E
Explanation:

The name of a variable cannot contain '?'. The only allowed symbol is underscore ( _ )

Which of the following is not a valid shell script operator?

  1. -eq

  2. -ne

  3. -le

  4. -gt

  5. -mt


Correct Option: E
Explanation:

-mt is not a valid operator.

What will be the output of the above code?

i=5
while test $i != 0
do
echo "$i"
i=`expr $i - 1`
done

  1. 5 4 3 2 1

  2. 5 4 3 2 1 0

  3. 1 2 3 4 5

  4. 0 1 2 3 4

  5. 5


Correct Option: A
Explanation:

The initial value of variable 'i' is 5. The while loop will continue as long as the value of the variable 'i' is not equal to 0. Value of 'i' will be decremented in each iteration. Therefore, the result will be 5 4 3 2 1.

Which of the following is not a pre-defined AWK variable?

  1. FILENAME

  2. OFS

  3. EXIT

  4. NF

  5. NR


Correct Option: C
Explanation:

Exit is not a valid AWK variable.

Which command is used to combine the contents of two files?

  1. merge

  2. comm

  3. sort

  4. join

  5. uniq


Correct Option: D
Explanation:

The join command is used to merge the contents of two files. Usage : join file1 file2

Which of the following statements is false regarding Shell?

  1. Shell provides user interface.

  2. Shell is a part of the system kernel.

  3. It is a command language interpreter.

  4. Several shells are available for Linux.

  5. Shell opens up automatically on log on.


Correct Option: B
Explanation:

The shell is not part of system kernel, but uses the system kernel to execute programs, create files, etc.

Which of the following is not a part of the 'etc/passwd' file?

  1. Home directory

  2. Command/shell

  3. User ID (UID)

  4. Password

  5. Access Permissions


Correct Option: E
Explanation:

Permissions or privileges are not a part of the etc/passwd file.

Which command is used to extract a column from a text file?

  1. cut

  2. paste

  3. tee

  4. tr

  5. man


Correct Option: A
Explanation:

The cut command is used to extract a vertical selection of columns (character position) or fields from one or more files. The syntax for extracting a selection based on a column number is: $ cut -c n [filename(s)]

Which permission allows you to modify the contents of a file?

  1. read

  2. write

  3. execute

  4. edit

  5. delete


Correct Option: B
Explanation:

The write permission allows the user to write or edit the contents of the file.

Which of the following is not a communication command?

  1. grep

  2. mail

  3. mesg

  4. write

  5. ping


Correct Option: A
Explanation:

Grep is not a communication, but a search command that allows to search one file or multiple files for lines that contain a pattern.

The head command writes the first ____ lines of a file on the screen.

  1. 10

  2. 1

  3. 5

  4. 20

  5. 15


Correct Option: A
Explanation:

The head command writes the first ten lines of a file to the screen.

Usage : head sample.txt

Which form of the 'ls' command is used to display the list of hidden files?

  1. ls -a

  2. ls -l

  3. ls -f

  4. ls -r

  5. ls -lS


Correct Option: A
Explanation:

The ls -a command is used to print the list of all the hidden files. A hidden file in Linux is the one that starts with a dot (.)

Which of the following is not a valid process signal with reference to the 'kill' command?

  1. SIGHUP

  2. SIGQUIT

  3. SIGINT

  4. SIGTSTP

  5. SIGBREAK


Correct Option: E
Explanation:

SIGBREAK is not a valid process signal in Linux.

Which wild card character represents a range of characters during pattern search?

  1. *

  2. ?

  3. < >

  4. { }

  5. [ ]


Correct Option: E
Explanation:

The [ ] represents a range of characters. The range operator allows us to limit to a subset of characters.Usage : ls [sv]*

What will be the output of the above code?

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. Compilation error

  2. x

  3. 3

  4. 5

  5. y


Correct Option: C
Explanation:

The value of 'x', which is 3, will be printed.

- Hide questions