Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. What keys on the keyboard would I use to scroll back and forth through the co

ID: 3844438 • Letter: 1

Question

1. What keys on the keyboard would I use to scroll back and forth through the commands I've previously issued from the terminal? (5 points) 2. If I typed "cd ~/Vi" at the command line in terminal (running under a default Mint installation), then hit the tab key, then hit the [return] key, what would happen? (5 points) 3. What command would I use to create the following nested directory structure: ~/Desktop/September/2015 4. In the nano editor, the key combination ^O does what? (5 points) 5. I'm in the directory '~/Desktop/September/2015/'. At the command prompt I type 'cd ../..' In what directory would I be now? (5 points) 6. I'm in ~. Give me the command that would use the ABSOLUTE path to change to the following directory: ~/Videos/one/two/three/four. (5 points: Don't have that directory? Then CREATE IT!) 7. My present working directory is ~. I want to delete all files in the ~/Videos/one/two/three/four directory that end with the extension '.docx'. What command would I run to do this? (5 points: Hints: 1) Create that directory; 2) create some *.docx files; 3) run a command to see if it works as expected!) 8. What command would I use to make a copy of the file "~/Bob" and name it '~/Videos/one/two/three/four/Bob2'. (5 points) 9. My present working directory is "~/Videos/one/two/three/four". Give me a command using a RELATIVE path that would take me to ~. (5 points) 10. This question is related to Question 9 above. Now I want to change back to directory '~/Videos/one/two/three/four'. What simple command would I use to do this? (5 points) 11. What command would I use to create the nested directories "~/hello/world/how/dare/you" (hint: Use a SINGLE command. See the man pages). (5 points) 12. I have a file called "bjork.txt" in the directory '~/bjork/bjork/bjork', which is my present working directory. I want to move the file "bjork.txt" to that directories parent directory (~/bjork/bjork). What command would I use to do this? (5 points) 13. What command would I use to display a big text file called "mybigfile.txt" to the screen so I could move through it a line or a page at a time? (5 points) 14. Root can update an Mint installation with the following command line: aptitude update && aptitude safe-upgrade What commands must a NON-ROOT user use in order to update their installation? (5 points) 15. What is the option for the 'ls' command that provides a directory listing hidden and non hidden files? (5 points) (Hint: Use the man page, and give me the ENTIRE command) 16. I want to move the file "~/Videos/one/two/three/four/Bob2" to my ~/Documents directory. What command would do this? (5 points) 17. My present working directory is ~. I want to rename the file ~/Pictures/film1.txt to ~/Photos/film2.txt. What command would do this? (5 points) 18. I'm in the following directory: ~/Desktop/September/2015/hello/world/how/dare/you. I type: 'cd ../../../../' then {return} at the command prompt. In what directory would I be then (give me the FULL path)? (5 points) 19. I have 24 files in the ~/Documents directory and I want to delete two them. I want to be prompted for removal for each file. What command would do this? (5 points: hint - use the man page) 20. My current working directory is ~. What command would I use to remove the empty directory "~/Videos/one/two/three/four"? I ONLY want to remove the 'four' directory, NO OTHER DIRECTORY. (5 points)

Explanation / Answer

1) You can use Up/Down arrow keys to scroll back and forth through the commands you have previously used.

2) Path would be changed to your Videos directory. cd refers to change directory. ~ refers to your home folder. When you press tab key after typing "cd ~/Vi" it will expand to "cd ~/Videos" pressing the return key will run the command and path will be changed to Videos directory.

3) mkdir -p ~/Desktop/September/2015. mkdir is used to create directories. -p option is used to create missing parent directories.

4) ^O in nano is used to WriteOut / save your file.

5) You will be in the Desktop Directory. ~/Desktop/September/2015/ implies you are currently in 2015 directory. A .. refers to parent directory. Therefore ../.. will refer to parent of parent directory which is Desktop in this case. cd ../.. will therefore change the directory to Desktop Directory.

6) cd ~/Videos/one/two/three/four. In place of tilde, if you know the username, then cd /home/USERNAME/Videos/one/two/three/four can be used. If directories don't exist then you can use mkdir -p ~/Videos/one/two/three/four to make the directories. After that you can cd into the created directories. You can also combine both the commands in single command using &&.

7) rm ~/Videos/one/two/three/four/*.docx. rm is the remove command. Syntax of rm is rm followed by the file name/names. We have used a wildcard (*) here to match any file name which ends with .docx. * matches one or more characters.

8) cp ~/Bob ~/Videos/one/two/three/four/Bob2. The syntax of cp command is cp [source] [destination]. Note that directories must exist where you want to copy the file.

9) cd ../../../../.. will take you to ~ directory. As mentioned above, .. refers to parent directory of current working directory so this command uses .. multiple times to move to parent directory 5 times.

10) "cd -" without quotes. - refers to previous working directory.

11) mkdir -p ~/hello/world/how/dare/you should be used as mentioned above.

12) "mv bjork.txt ../" wilthout quotes. mv is the move command with syntax similar to cp command. mv [source] [destination]. Again .. refers to parent directory.

13) less mybigfile.txt can be used to display mybigfile.txt page by page. less is a program used to display text files page by page. Syntax is less filename

14) sudo aptitude update && aptitude safe-upgrade. using sudo before any command gives root privileges to non root user.

15) ls -a. -a option stands for all files. So ls -a will show both hidden as well as non hidden files. Note that hidden files starts with a period(.)

16) mv ~/Videos/one/two/three/four/Bob2 ~/Documents/ This follows the same mv command syntax as mentioned above.

17)  mv ~/Pictures/film1.txt to ~/Photos/film2.txt In linux there isn't a specific command to rename a file. Instead of that mv is used.

18) You will be in ~/Desktop/September/2015/hello/ directory. using .. 4 times moves up 4 parent directories.

19) rm -i file1 file2 where file1 and file2 are the name of two files you want to delete. -i option stands for interactive mode which will prompt you before deleting file.

20) rm -r ~/Videos/one/two/three/four will delete "four" directory retaining the parent directories. -r option stands for recursive and used to delete directories.

Hope it helps!