Git Product home page Git Product logo

command-line-starwars's Introduction

GA logo

LAB: Unix CLI Practice

Class: SEI
Creator: Thom Page
Modified by: Kristyn Bryan and Reuben Ayres
Topics: Getting familiar with the Unix Command Line


Setup

  • Open the Terminal app

  • Use the directions here to

    • fork + clone the repo at this step
    • after you're done with the assignment you'll run add/commit/push steps, as well as the create a pull request step/
  • IMPORTANT: After you've cloned you need to cd into that directory. (The directory should be called lab1-cli.)

Section 1: Terminal Practice

Episode X: A New Terminal

A long time ago in a Unix environment far, far away, young Jedi padawans who knew only of desktop software were seduced by the dark side of the Force to enter… The Terminal.

Follow the instructions below using all the console commands introduced in Fundamentals, class, or that you find on your own.

  • Also in the lab1-cli directory, create another directory called called star_wars and create a file called commands.txt. You will now have the commands.txt file and the star_wars directory and this README.md file side by side in the directory that was created when you cloned this assignment.

  • Paste the answer to each numbered question (i.e. the command(s) that accomplished the task) into commands.txt once you get it to work.

  • Remember, you can learn about any Unix command by typing man and then the command name. E.g., man ls. Type Q to get out of the Manual page ("man page") viewer.

Part I: Set the Scene

Complete all work inside the star_wars folder.

  1. Create a directory called death_star, and make the following files inside of it: darth_vader.txt, princess_leia.txt, storm_trooper.txt

  2. Create a directory called galaxy_far_far_away, make a directory named tatooine and create the following files in it: luke.txt, ben_kenobi.txt.

  3. Inside of tatooine make a directory called millenium_falcon, and in it create: han_solo.txt, chewbaca.txt


Part II: mv - rename

  • You can rename a file using the mv command.
  1. Rename ben_kenobi.txt to obi_wan.txt.

Part II: cp - copy

  • You can copy a file from one location to another using the cp command. (man cp for more info)
  • Directories can be sibling (parrell to each other) or can be parents (the folder that contains the folder you are in)
  1. Copy storm_trooper.txt from death_star to tatooine.

Part IV: mv - move

  • You can use the mv command to move files from one location to another. mv can be used for renaming, moving, or both. Run man mv to see the options—remember hit the Q key to get out of the manual page viewer.
  1. Move luke.txt and obi_wan.txt to the millenium_falcon.

  2. Move millenium_falcon out of tatooine and into galaxy_far_far_away.

  3. Move millenium_falcon into death_star.

  4. Move princess_leia.txt into the millenium_falcon.


Part V: rm - remove

BE CAREFUL WITH rm!!! THERE IS NO "TRASH" IN THE UNIX CLI. WHEN YOU DELETE SOMETHING IT IS GONE FOREVER!!!

You can use rm to delete a file.

  1. Delete obi_wan.txt.

Part VI: all together

  1. In galaxy_far_far_away, make a directory called yavin_4.

  2. Move the millenium_falcon out of the death_star and into yavin_4.

  3. Make a directory in yavin_4 called x_wing.

  4. Move princess_leia.txt to yavin_4 and luke.txt to x_wing.

  5. Move the millenium_falcon and x_wing out of yavin_4 and into galaxy_far_far_away.

  6. In death_star, create directories for tie_fighter_1, tie_fighter_2 and tie_fighter_3.

  7. Move darth_vader.txt into tie_fighter_1.

  8. Make a copy of storm_trooper.txt in both tie_fighter_2 and tie_fighter_3.

  9. Move all of the tie_fighters out of the death_star and into galaxy_far_far_away.


Part VII: rm -r: remove directories and everything they contain

BE CAREFUL WITH rm!!! THERE IS NO TRASH CAN IN THE UNIX CLI. WHEN YOU DELETE SOMETHING IT IS GONE FOREVER

Before you hit enter, make sure are deleting the right thing, or you could accidentally delete the contents of your computer (it has happened).

This command will not typically ask you if you "really want to delete." It will just delete.

  1. Remove tie_fighter_2 and tie_fighter_3.

Part VIII:

  1. Touch a file in x_wing called the_force.txt.

  2. Destroy the death_star and anyone inside of it.

  3. Return x_wing and the millenium_falcon to yavin_4.

Celebrate. You've reached the end of Lab 1 :)



🔴 Homework submission Practice: Commit and push your updated code:

"Add" your changes (prepare them to be "committed"):

$ git add -A

"Commit" your changes—any time you make a commit, you can always restore the files in the repo to that point:

$ git commit -m "Completed Lab assignment"

"Push" your commits to github:

$ git push origin master

Follow the directions on creating a pull request we went over in the second half of class here

"Hungry for more?"

Want an extra challenge? In many assignments or labs, you'll find a "Hungry for More" section which is designed for further learning. If they seem too overwhelming you can absolutely skip them. They won't factor into your homework score, and you will be totally fine for class as long as you complete and understand the main assignment up to that point. What they will do is encourage you to go deeper, explore, and push yourself. And that will pay off big time in the long run. Below is the "hungry for more" section for this assignment.

Try to complete the following, making a commit after each one.

...as long as you don't mess up the homework assignment you just did. They get more difficult/complex as you go (more or less).

  • Create a directory called test-dir with a couple files in it. Try to make a copy of that entire directory. (Hint: man cp for more info.)
  • Find and use command line shortcuts.
  • Try applying one command to multiple files at once.
  • Try applying one command to all files in a single directory (where necessery)
  • Try applying one command to all files that match a pattern.
  • Try using a mix of absolute and relative paths.

The grandfather of all modern text editors: vi (or vim)

  • Read about the famous text editor "vi" online. It's included with all Unix systems, and although it has a steep learning curve, it is an incredibly powerful text editor. You can run a tutorial program that will teach you the essential vi/vim commands by typing vimtutor in your Terminal. See if you can use it to create and edit a small "Hello, World!" JavaScript program!

command-line-starwars's People

Contributors

thecoachanna avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.