Basic linux interview questions
1)How do you find out what’s your shell? – echo $SHELL
2)What’s the command to find out today’s date? – date
6)What’s the command to find out users on the system? – who/users
11)How do you search for a string inside a directory? – grep string *
16)How do you find out about all running processes? – ps -ag
21)How do you do number comparison in shell scripts? – -eq, -ne, -lt, -le, -gt, -ge
the argument is a file, and not a directory, -d filename tests if the argument is a directory, and not a file, -w filename tests for writeability, -r filename tests for readability, -x filename tests for excitability
26)How do you write a for loop in shell? – for {variable name} in {list} do {statement} done
31)How does getopts command work? – The parameters to your script can be passed as -n 15 -x 20.Inside the script, you can iterate through the getopts array as while getopts n:x option, and the variable $option contains the value of the entered option.