Exercise 1.1: Command line exercises


In this exercise, you will play around with the command line on your machine and get more familiar with it.

a) Let’s play around with some options for the ls command. First cd into a directory that has some interesting files in it (like ~git/bootcamp/command_line_tutorial). Try the following if you are using bash.

ls -F
ls -G    # Might not be as cool with Git Bash on Windows
ls -l
ls -lh
ls -lS
ls -FGLh

You should be able to infer what these different options do, but you can ask the course staff as well.

Normally, files that begin with a dot (.) are omitted when listing things. They are also generally omitted when you use your OS’s GUI-based file handling system (like Finder on Macs). To see them, use ls -a. So, cd into your home directory (you remember how to do that, right?), and then do

ls -a

b) The nuclear option to delete everything in a directory is rm -rf. The r means to delete recursively, and the f means to “force” deletion. I was going to give you an exercise that uses the nuclear option, but I’m not going to do that. So, just forget I said anything. For this part of the problem, I want you to discuss with someone else in the class when the nuclear option might be used, and what needs to be in place before exercising it.

c) Try doing this if you are using macOS or Linux:

ls /

What is /? Try cd-ing there and seeing what’s in there. Do not delete anything!

Solution

This problem more or less consisted of messing around with the command line.