Skip to content

Wrapping it All Up (All Review Questions)

FlintMitchell edited this page Jan 16, 2022 · 8 revisions

Back to Section 8: Basics of Bash Scripting

Go back to tutorial overview

Conclusion

You've finished the Command Line Training Module for Scientists! Nice work! Let's see if you can answer all of the review questions without going back to the wiki pages related to them... This time the questions don't have the answers immediately underneath. They are at the bottom of this page, so refrain from scrolling down to test yourself. Copy and paste the questions into a text document (like word) and try answering them!

Questions

  1. How does the CLI compare to the graphical user interface of your computer?

  2. Why is the CLI a practical and important skill?

  3. How can the command line make your experiments more efficient?

  4. How do you review past commands?

  5. When you log onto an EC2 instance within your CLI window, do your commands get sent to your own computer or a virtual computer in the AWS cloud?

  6. What is the command line prompt?

  7. Can you access the internet via the command line?

  8. What is your current working directory?

  9. How do you find out what your current working directory?

  10. How do you list the contents of your directory?

  11. How do you change directories to a subdirectory named "example-dir"?

  12. How do you move back to your home directory?

  13. What are directories?

  14. What is a subdirectory vs a parent directory?

  15. What are text and data files used for?

  16. What is an executable?

  17. How can you find out more information about a given command?

  18. What is a command option?

  19. What command can you use to gain administrator privileges on the CLI session?

  20. What is a variable?

  21. What is the path of a directory?

  22. What command is useful for when we are a bit lost and don't know where we are on the computer?

  23. What command do you use to create a new directory?

  24. What command do you use to create empty text or data files?

  25. How do you move files to different locations?

  26. How can you get the path of a location that you want to move a file into?

  27. How do you edit files?

  28. How do you read files into the CLI window?

  29. How do you copy files?

  30. How do you delete files?

  31. What command displays the amount of free storage space in our EC2 instance?

  32. What is a block device similar with your own computer to in the context of an EC2 instance?

  33. What command lists the block devices?

  34. What command shows us a real-time view of the softwares that our EC2 instance is currently running?

  35. What command shows us the number of newlines, words, and bytes in a specific file (or multiple files!)?

  36. What command searches for patterns within files or directories?

  37. What command takes the output of one command and allows you to use it as the input of a second command?

  38. What command can search for and change a pattern inside of a file?

  39. What are commands that you can use for downloading software packages?

  40. Which commands download files from web servers?

  41. What command would you use to uncompress a .tar or .tar.gz file?

  42. What command would you use to uncompress a .gz file?

  43. What command would you use to uncompress a .zip file?

  44. What commands can you use to download python packages?

  45. How do you download a Github repository to your current working directory?

  46. Which character is symbolic of "all files" (for instance, "list all files in the current directory", or "list all files that end with ".txt")?

  47. Which character redirects the the output of a command into a new file and overwrites any other file that might already exist with the name you gave it?

  48. Which character redirects the the output of a command into a new file and but, instead of overwriting another file, appends that output to the end of the file instead?

  49. Which command allows for you to create a secure connection to another computer host (like an EC2 instance)?

  50. What is a private keypair used for?

  51. Which command would you use to copy a file from your computer to another computer?

  52. What information besides the keypair is required to log into another computer system with SSH? What extra information do you need for using SCP?

  53. What happens when you use the command (Control + C) when a program is running?

  54. What command would you use to create a virtual terminal for running programs on behind the scenes on your EC2 instance?

  55. What do you press to log out of a tmux virtual terminal?

  56. Which tmux options do you use to reattach to a virtual terminal?

  57. What are 2 tools you can use for finding software that is relevant to doing analysis that you are interested in?

  58. Where should you look to find out how to download and install a third party software?

  59. Where can you find out more information about how to use the software? What command or option is useful for doing this?

  60. What information should you include when you ask a question on an online forum (or any time you ask a question for that matter!)?

  61. What is Bash?

  62. What is a bash script?

  63. What is a variable?

  64. What is a for loop?

  65. If you try to operate a script and it tells you you don't have the correct permissions, what command can you use to change the permissions of the file so that you can execute it?

  66. Is scripting / programming something that you are capable of learning?

Of course!! All it takes is practice. (I thought I'd just give you the answer to this one)



Answers

  1. You can do many of the same things on the command line as you can with your mouse. You can open and navigate around folders, create and edit files, and use programs.

  2. It is an important skill for many fields of science that require analyzing large datasets, for have a larger set of tools to analyze data with because many programs don't have GUIs, and for furthering your career as a scientist.

  3. You can set up multiple data analyses to run one after another to change variables in between runs, meaning that you don't have to manually do that yourself and free up your own time.

  4. You press the up arrow.

  5. They get sent to a computer in the cloud! Your personal computer will not receive any of the commands you send it!

  6. It is the area for you to enter text and commands that will be sent to the computer. The prompt contains text that holds information regarding the user who is logged into the computer, the name of the computer (the host), the current working directory (where you are on the computer, and the type of user you are.

  7. Yes!

  8. It is the location on your computer that your CLI session currently resides and decides what files and directories you have immediate access to.

  9. You use the command pwd.

  10. You use the command ls.

  11. You use the command cd with the folder named after it: cd example-dir.

  12. You use the command cd or cd ~

  13. They are like folder and they store other files or more directories.

  14. A subdirectory is inside of a parent directory.

  15. Text and data files hold information! They can have a variety of different filetypes, like excel files (.xls), comma-separated values (.csv), or the text-based format for storing both a biological sequence and its corresponding quality scores (.fastq), etc.

  16. An executable is a file whose contents holds instructions for the computer to follow. Can be thought of as a "program".

  17. Use the manual! To read the manual, use the command man [command-name], example for ls: man ls. You can also sometimes use the option --help after the command, ex: [command] --help

  18. A command option is a feature for customizing a command. Sometimes commands can be run in different ways (like using ls to list in different ways) or the options are used to input datafiles.

  19. The command sudo is used for gaining administrator privileges, but is dangerous to use because you can potentially overwrite important files!

  20. A variable is a storage container for information.

  21. A directories path is the series of directories that lead the computer to that directory. For example, in dir1/dir2/dir3/dir4/file.txt., the path to the file file.txt is dir1/dir2/dir3/dir4/.

  22. The command pwd is useful for finding out what our current working directory is.

  23. You can use the mkdir [directory-name] command to build new directories.

  24. You can use the touch [filename] command to create empty text or data files

  25. You use the mv command to move files or directories to different locations.

  26. You can either use /.. to signify that you want to move the file into the parent directory, or you can navigate into the directory you want to move the file into and use pwd to find its path. Then you put a ~ at the beginning of the path because that will tell the computer that it should look for that path within the home directory.

  27. To edit files you can open them in the Nano editor by using the command nano [filename].

  28. You use the command cat [filename] to read a file.

  29. You use the command cp [filename1] [filename2] copy filename1 into a new file with the name filename2.

  30. You use the command rm [filename] to delete files

  31. df -h!

  32. It is like an external hard drive, that when mounted (attached) onto the computer, adds storage space that you can save files to.

  33. lsblk

  34. top

  35. wc

  36. grep

  37. The pipe command |.

  38. sed

  39. apt, yum, dpkg. For using apt the syntax is: sudo apt install [package-name]

  40. wget and curl

  41. tar

  42. gunzip

  43. unzip

  44. pip and conda (but you can only use conda if the program Anaconda is installed, for our EC2 instances, you can use conda instead of pip!)

  45. git clone [desired-repository-url]

  46. *

  47. >

  48. >>

  49. To use the Secure Shell Protocol, SSH, you use the command ssh.

  50. It acts like a password and is necessary to get permission to use SSH to log into another computer.

  51. To use the Secure Copy Protocol, SCP, you use the command scp.

  52. You need to have the username you will log into the other computer system with and the hostname of the computer. For SCP, you also need to have the path to the location you want to copy your file to or the path and the filename that you want to copy to your own computer.

  53. It force quits the program and send you back to the command prompt!

  54. tmux or screen

  55. You press and release (Command + B) together and then press D

  56. attach-session to tell tmux you want to attach to a currently running virtual terminal and -t [virtual-terminal-name to tell tmux the name of that virtual termianl you want to attach to.

  57. Both a literature search and Google are good options for finding the names and use cases of analysis softwares.

  58. Look at the documentation pages for the software. This is usually in the Github repository or on the university / academic lab's website.

  59. Look at the documentation, README, or manual pages (these are all effectively synonymous). Use the command man [software-package] or the --help option after you have installed the software.

  60. Be sure to include: The question you are asking in as clear terms as you can word it, How you have already tried to answer the question, meaning other questions you have asked, webpages or sources you have looked at, and attempts at solving the problem you have already tried.

  61. Bash is the program that receives the commands you enter in the Command Line Interface window, looks for the instructions to operate those commands on the computer, and then executes those instructions.

  62. A bash script is a collection of instructions that Bash follows one after another. This is done to automate tasks instead of having to manually enter them yourself.

  63. A variable is a container used to temporarily store information. It can change when it is assigned another value (numbers or text).

  64. A for loop is a set of instructions for the computer to follow until a condition is met. When the computer enters a for loop, it is given conditions (like "until the variable i is equal to 100, with i starting at 0, and i increasing by 1 every loop) that tell it when (if ever) to leave the for loop. For as long as it is inside of the for loop, it follow the instructions inside of it.

  65. chmod +x [filename]

Go back to tutorial overview

Clone this wiki locally