Skip to main content

A light bash intro

The most commonly used shell, is the bash shell and here is a very light introduction to it.

Let's go through your first use step by step:

Opening up the Terminal
Do one of the following:
  • Right-click on the Start menu icon. You can find this button in the lower-left corner of your desktop. It will open your Power User Menu options in a pop-up.
  • You can also just press ⊞Win+X on your keyboard to open this menu.
  • Alternatively, you can right-click on any folder to start Command Prompt from a specific directory.

Let's type in some instructions#

Type this in your terminal and press enter.

echo "Hello world"

Congratulations πŸŽ‰ you have just given your computer an instruction and it executed it.
The command echo just prints out whatever you put afterwards. There are many shell commands you can execute for example:

  • cd : to move within your filesystem (alias for change directory).
  • mkdir: to create a directory (alias for make directory).
  • touch: to create a file.
  • ls: to list the files in the directory you currently are located (alias for list).
  • rm: to delete a file or directory (alias for remove).
info

Folder is the term used in the context of graphical user interfaces and directory is the term used in a filesystem's context.

Let's try all of these (type the command and press enter to execute it):

  1. ls : you should see all the files in the directory.
  2. mkdir iamawesome: this will create a directory named "iamawesome".
  3. ls : now you should see the directory you just created in the list.
  4. cd iamawesome: this will take you to the directory. See how the path on the left has changed.
  5. touch myfile.txt: you've just created a file!
  6. ls : do you see it?
  7. cd .. : you've just moved back to the parent directory.
  8. rm -r -v iamawesome: the -r is to indicate that you want everything in the directory removed and the -v is to indicate you want written feedback of the execution.

Now let's combine them in one line with the && operator, and add another command to write in a file. Write anything you want and do CTRL+C when you are done.

mkdir mydir && cd mydir && touch hello.txt && cat > hello.txt

Now look at what you have written with the command cat hello.txt.

Ok , let's stop here, sooner or later you will have to use it again...

There is so much more you can do, so if you are curious you can watch the video below (2m32s) and play around with scripts when you'd like to feel like a computer god.


Here is a cheatsheet of different commands you can use for future reference.