Skip to content

Instantly share code, notes, and snippets.

@Deltara3
Last active September 25, 2023 17:14
Show Gist options
  • Save Deltara3/213f91864065ac124acd31652b19edc0 to your computer and use it in GitHub Desktop.
Save Deltara3/213f91864065ac124acd31652b19edc0 to your computer and use it in GitHub Desktop.
A comprehensive beginners guide to the terminal.

Introduction

If you're reading this, chance is you want to use SPWN. You've likely never touched a terminal before and are confused why SPWN closes immediately. This guide will assist you in your journey. SPWN is not a graphical application, it is a command line application. What exactly does this mean? Unlike other applications like Google Chrome or Discord, SPWN does not have a user interface, everything is done via commands. Now without further ado, lets begin.

NOTE: If you just need information on the SPWN program itself, you should be reading the documentation.

Finding the Terminal Emulator

The terminal emulator installed depends on which operating system you have, here is a list, assume they are already installed unless stated otherwise.

General rule of thumb, try searching for Terminal or Console.

  • Windows: Windows PowerShell or Command Prompt
  • macOS: Terminal

Linux is a bit different, as each desktop environment has its own terminal emulator. I can't list of every single one but here's a small list.

  • GNOME: GNOME Terminal
  • XFCE4: XFCE4 Terminal
  • KDE: Konsole

XTerm is sometimes installed for Linux systems as well.

Once you've found your terminal application, go ahead and open it.

Becoming Familiar with the Terminal

Depending on your operating system and your shell you might see something different, and that's okay. My username is a placeholder for yours.

On Windows you should see one of these two:

  • PowerShell: PS C:\Users\Deltara>
  • Command Prompt: C:\Users\Deltara>

On macOS (with ZSH): deltara@Mac-Pro-8 ~ %

Again on Linux this varies a lot as there are many shells.

  • Bash: [deltara@mycomputer ~]$
  • ZSH: deltara@mycomputer ~ %

There is one integral part to your terminal prompt, being your current working directory. This might sound fancy, but it really isn't. Imagine your file explorer, normally at the top you see a path, like in the terminal, that is your current directory.

There's also something else I need to address, that ~. What is that? On Unix-like operating systems, ~ denotes the home directory. You can see that Windows doesn't show it, as it is not Unix-like.

You may ask, what is a home directory? The home directory is a folder that stores each user's personal data within it.

They are stored in:

  • Windows: C:\Users
  • macOS: /Users
  • Linux: /home

For example, my Linux home directory would be at /home/deltara.

Important Commands

Through using the terminal, you'll find yourself needing to use these two main commands.

  • dir (Windows) or ls (macOS and Linux)
  • cd

A helpful command is more (Windows) or cat (macOS and Linux).

NOTE: On PowerShell, the Unix style commands also function the same way.

What do these commands do?

dir / ls is a list directory command. They list all the files and folders in your current working directory. This will help you keep track of where exactly you are. It's not needed if you know the exact path but it can be useful.

cd is the change directory command. Simply put, it sets your current working directory to another one.

Finally, more / cat is a file concat command. The intended purpose is to join files together and output to the terminal, but they are also useful for reading back files.

When using dir / ls listing types are normally denoted by a tag or color.

On Windows you could see: <DIR> My Folder

On macOS or Linux you might see: My Folder but in blue.

Let's look at an example of cd:

C:\Users\Deltara>cd Desktop
C:\Users\Deltara\Desktop>

Notice how the path changed. But wait, what if I need to go down a directory? That's quite simple.

C:\Users\Deltara\Desktop>cd ..
C:\Users\Deltara>

Another tip for cd is, you don't have to type a single directory each time. Let's say I want to enter a folder on my desktop named Test.

We don't have to do this:

C:\Users\Deltara>cd Desktop
C:\Users\Deltara\Desktop>cd Test
C:\Users\Deltara\Desktop\Test>

We can just do:

C:\Users\Deltara>cd Desktop\Test
C:\Users\Deltara\Desktop\Test>

This also works for going down a directory an into another:

C:\Users\Deltara\Downloads>cd ..\Desktop
C:\Users\Deltara\Desktop>

NOTE: If a path includes spaces, you need to escape it or use quotes.

Example using quotations:

C:\Users\Deltara>cd "My Files"
C:\Users\Deltara\My Files>

Examples using escapes:

On Windows:

C:\Users\Deltara>cd My^ Files
C:\Users\Deltara\My Files>

And on macOS and Linux:

[deltara@mycomputer ~]$ cd My\ Files
[deltara@mycomputer My Files]$

In these examples, the escape character (^ or ) tells the terminal to continue interpreting the space as part of the same argument.

cd can accept relative or full paths.

Examples of each:

  • Relative: Data, ..
  • Full: C:\Users\Deltara\Data, /home/deltara/Data

A full path simply contains all the information. In a relative path, the information is inferred.

What about more / cat? Well here's an example of that.

Let's say I have a file named important.txt and it contains:

This is a very important document.

I can read this back like this:

C:\Users\Deltara>more important.txt
This is a very important document.

C:\Users\Deltara>

NOTE: The file has to be in your current working directory.

Conclusion

Now that you've read this, you should have a basic understanding of how to navigate and use the terminal. Hopefully, that wasn't too hard. If you have any questions or concerns you can ping me (@deltara3) in the SPWN Discord server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment