You are currently viewing bash linkedin assessment answers
bash linkedin assessment answers_theanswershome

bash linkedin assessment answers

1. In Bash, what does a # at the end of the default prompt string indicate?

  • that there are updates for the system available
  • that the user is acting as root
  • that the current working directory is the root of the file system
  • that the user is unprivileged

2. The code below seems to work and outputs "8 is greater than 5". However, what unexpected result will tell you it is not functioning properly?

  • The variable svar is not quoted, which will lead to word splitting This script will fail with a “unary operator expected” message if you change the value of $var to “8 8”
  • There will be no unexpected results. This script works as is and the output will be “8 is greater than 5”.
  • There will be a file in the current directory named 5.
  • The comparison will not be able to handle floating-point numbers, as Bash only handles integers. So this example will output an error message if the value of $var is changed to “8.8”.

3. What does this command sequence do?

cat >notes -

  • It appends text to an existing file called “notes.”
  • It creates an empty file called “notes” and then exits.
  • It outputs the contents of the “notes” file to the screen, and then deletes it.
  • It accepts text from the standard input and places it in the “notes” file.

4. If a user wants to execute script.sh without a shebang line or execute permissions, what should the user type?

  • A shebang line is required to execute a shell script.
  • “exec script.sh”
  • “bash script.sh”
  • Execute permissions are required to execute a shell script.

5. What is the output of this code?

VAR="This old man came rolling"
echo "${VAR//man/rolling}"

  • This old man came man
  • This old rolling came rolling
  • This old man came rolling
  • This old came

6. Which variable contains the number of arguments passed to a script from the command line?

  • 0
  • $!
  • $@
  • $#

7. To run a group of commands without spawning a subshell, which syntax would you use?

  • ( command1; command2 ))
  • sh commandl; command2
  • ( commandl; command2 )
  • { command1; command2; }

8. Review the code below. For the user 'jon', what will the output be?

echo 'Hello, $ (whoami)!'

  • Hello, $(jon)!
  • Hello, jon!
  • Hello, $(whoami)!
  • Hello, whoami!

9. Which sed options should you use to change the second-to-last instance of variable to rock so it would read:
A constant is a variable that is a rock that isn't variable

var="A constant is a variable that is a variable that
isn't variable"
echo "Svar" | sed ______

  • s/\(.*\)variablel (.*variablel)/llrock\2/’
  • s/variable/rock/
  • s/ (.*\) variable\ (.*variablel)/\irock\2/’
  • s/variable/rock/g’

10. What is the difference between the $@ and $* variables?

  • $* is the wildcard that includes all arguments with word splitting, $@ holds the same data but in an array.
  • $@ treats each quoted argument as a separate entity. $* treats the entire argument string as one entity.
  • $* treats each quoted argument as a separate entity. $ treats the
    entire argument string as one entity.
  • $* is used to count the arguments passed to a script, $ provides
    all arguments in one string.

11. Given the listed permissions on data.txt is it possible that user2 could have read, write, and execute permissions on data.txt?

$ ls -1 total 0
-rWx------+ 1 user1 user1 0 Oct 27 10:54 data.txt

  • It’s possible that SELinux provides read, write, and execute permissions for user2 which are not visible with Is -I.
  • Yes, the + at the end of the 10-digit permission string signifies there’s an extended attribute set. This could give user2 permissions to read, write, and execute data.txt.
  • Yes, the + at the end of the 10-digit permission string signifies there’s an access control list. This could possibly give user2 permissions not visible by Is -I.
  • No, it’s clear that user2 does not have read, write, and execute permissions.

12. Which file allows you to save modifications to the shell environment across sessions?

  • ~/.profile
  • /etc/bashprofile
  • /etc/bash.conf
  • ~/profile

13. What would be in out.txt?

  • the number 5, which is written to the file using echo
  • the hyphen symbol (-)
  • 123456789
  • 123446789

14. How would you change your Bash shell prompt to this?

HAL>

  • export PS1=”HAL>”
  • SHELL=”HAL\>”
  • PS1=”HAL\>”
  • SHELL=”HAL>”

15. How can you copy a directory to another system with compression?

  • You can’t compress the stream.
  • scp -r directory user@192.168.1.1:/tmp
  • tar cuzf – /wwwdata | ssh root@192.168.1.201 “dd of=/backup/wwwdata.tar.gz”
  • tar –ssh user@192.158.1.1 /bin/newfile

Leave a Reply