Week 6 – Bash Scripting

using python to interact with the operating system week 6 answers

Practice Quiz: Interacting with the Command Line

1. Which of the following commands will redirect errors in a script to a file?

  • user@ubuntu:~$ ./calculator.py >> error_file.txt
  • user@ubuntu:~$ ./calculator.py 2> error_file.txt
  • user@ubuntu:~$ ./calculator.py > error_file.txt
  • user@ubuntu:~$ ./calculator.py < error_file.txt

2. When running a kill command in a terminal, what type of signal is being sent to the process?

  • SIGINT
  • SIGSTOP
  • PID
  • SIGTERM

3. What is required in order to read from standard input using Python?

  • echo file.txt
  • cat file.txt
  • The file descriptor of the STDIN stream
  • Stdin file object from sys module

4. _____ are tokens delivered to running processes to indicate a desired action.

  • Signals
  • Methods
  • Functions
  • Commands

5. In Linux, what command is used to display the contents of a directory?

  • rmdir
  • cp
  • pwd
  • ls

Devendra Kumar

Project Management Apprentice at Google

Leave a Reply