Skip to content

Commit

Permalink
clarifications to assignment 1 and lesson 2
Browse files Browse the repository at this point in the history
  • Loading branch information
cuttlefishh committed Oct 9, 2018
1 parent a8a5a7d commit 65a582b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
32 changes: 22 additions & 10 deletions assignments/assignment1.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
### Assignment 1 - Basic Shell Commands

Execute these commands in your terminal. Copy and paste the commands and output (i.e., your terminal session) to a text file, then save and submit this text file as your completed assignment. You may use plain text (.txt) or Markdown (.md) format. Please name your file `1_first_last.txt` or `1_first_last.md` (substitute your first and last name).
Do the exercises below. *How to provided your answer is specificed in italics.* Copy your answer to a text file then save and submit this text file as your completed assignment. You may use plain text (.txt) or Markdown (.md) format. Please name your file `1_first_last.txt` or `1_first_last.md` (substitute your first and last name).

#### A. Basic commands

*Copy your terminal commands and output as your answers.*

1. Navigate to your working directory for the class.
2. Within that directory, create a temporary test directory.
3. Create a file using one method I showed you.
Expand All @@ -12,26 +14,32 @@ Execute these commands in your terminal. Copy and paste the commands and output
6. Copy one of the files.
7. Delete one of the files.
8. Delete the temporary directory.
9. Get a list of the commands you've typed already.
10. See which processes are running on your computer.

#### B. Working with commands

1. Learn more about a command from class using a Unix command.
2. Learn more about a command from class using a Google search.
3. Find out where the commands `mv` and `cp` are located on your computer.
4. Get a list of the commands you've typed already.
5. See which processes are running on your computer.
6. What happens when you type `Tab` in the middle of typing a command?
7. What happens when you type `Tab` in the middle of typing a file name or path?
*Write your answers.*

1. Pick a command from class. Using a Unix command to find out, what does this command do?
2. Pick a command from class. Using a Google search to find out, what does this command do?
3. Where are the commands `mv` and `cp` are located on your computer?
4. What happens when you type `Tab` in the middle of typing a command?
5. What happens when you type `Tab` in the middle of typing a file name or path?

#### C. Setting up your bash environment

*No answers need be submitted.*

1. Download a text editor such as [Atom](https://atom.io) or [Sublime Text](https://www.sublimetext.com) if you haven't already.
2. Using your text editor, customize your terminal by editing the file `.bash_profile` in your home directory.
2. Using your text editor, customize your terminal by editing the file `.bash_profile` in your home directory. Alternatively, you can edit the file `.bashrc` in your home directory and have it automatically sourced by `.bash_profile` (see Lesson 2).
3. Source your bash profile file with the command `source ~/.bash_profile`.
4. Open a new terminal to make sure it automatically sources your bash profile file. You may have to change the preferences in the Terminal app.

#### D. More commands

*Copy your terminal commands and output as your answers.*

1. Print the first 5 lines of a text file.
2. Print the last 10 commands you entered.
3. View the contents of a file without printing anything to the screen.
Expand All @@ -43,6 +51,8 @@ Execute these commands in your terminal. Copy and paste the commands and output

#### E. Paths and variables

*Copy your terminal commands and output as your answers.*

1. Navigate to root and home directories using absolute paths.
2. Navigate to root and home directories using relative paths.
3. Store an integer as a shell variable then print it.
Expand All @@ -53,5 +63,7 @@ Execute these commands in your terminal. Copy and paste the commands and output

#### F. Executing bash scripts and dot-files

*Copy the text of your bash script and the terminal output as your answers.*

1. Write a bash script that uses the commands `mkdir`, `cat`, `mv`, `echo`, and a `for` loop.
2. Execute you bash script using the terminal.
2. Execute your bash script using the terminal.
20 changes: 19 additions & 1 deletion lessons/lesson02.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,25 @@ For small jobs or if you want to stay inside the terminal, there are other usefu

There are several things you can do to set up your bash environment, which is what you see when you use the terminal (command line). You put these commands in a file called `.bash_profile` (or `.bashrc` or `.profile`) in your home directory. Yes, that's a period at the beginning of the file, and the file is called a dot-file, which is a system file your computer uses to customize your shell.

Shown below are some commands that I have put in my `.bash_profile`. You might want to use some of these to customize your terminal. In Assignment 1, you will have the chance to edit your `.bash_profile` using a text editor like Nano or Atom. Be careful to not overwrite what's already there, and to not add any extra commands or stray text. It's a good idea to save a copy of your existing `.bash_profile` with a different name as a backup.
In Assignment 1, you will have the chance to edit your `.bash_profile` using a text editor like Nano or Atom. Be careful to not overwrite what's already there, and to not add any extra commands or stray text. It's a good idea to save a copy of your existing `.bash_profile` with a different name as a backup.

As an alternative to editing your `.bash_profile` directly, you can edit (or create and then edit) your `.bashrc` file and have `.bash_profile` source this file whenever it runs. To do this:

1. Type `cd` to go to your home directory.
2. Type `nano .bash_profile` (or `sudo nano .bash_profile` if you need root access).
3. Past this text at the top of your `.bash_profile`:
```
if [ -r ~/.bashrc ]; then
source ~/.bashrc;
fi
```
4. Save `.bash_profile` and exit nano.
5. Type `nano .bashrc`.
6. Add any of the commands you want to .bashrc instead of .bash_profile. This way, you won't have to use sudo every time you want to customize your shell.

You can learn more about `.bash_profile` and `.bashrc` on macOS [here](https://scriptingosx.com/2017/04/about-bash_profile-and-bashrc-on-macos/).

Shown here are some commands that you might want to put in your `.bash_profile` or `.bashrc` to customize your terminal:

```
# customize prompt with color and pwd
Expand Down

0 comments on commit 65a582b

Please sign in to comment.