Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Using The Terminal

From Nest Guides
Revision as of 23:59, 24 January 2024 by Shuchir (talk | contribs) (Created page with "Most modern operating systems will ship with a terminal. A terminal allows you to run commands that will tell your computer what to do. You will be using the terminal for most of this guide. * On windows, the default terminal is either cmd.exe or PowerShell. You have the option of using these or using WSL or another SSH client to connect to Nest. * On macOS, the default terminal is Terminal. There are also other Terminal apps you can install for free, such as AlacriTTY...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Most modern operating systems will ship with a terminal. A terminal allows you to run commands that will tell your computer what to do. You will be using the terminal for most of this guide.

  • On windows, the default terminal is either cmd.exe or PowerShell. You have the option of using these or using WSL or another SSH client to connect to Nest.
  • On macOS, the default terminal is Terminal. There are also other Terminal apps you can install for free, such as AlacriTTY or iTerm2.
  • On Linux, the default terminal application will vary, but is usually titled Terminal or Console.

Once you have selected a terminal, you will be greeted with a prompt similar to one of these upon opening the terminal:

~$
username@hostname:~$
bash-3.2$
PS C:\Users\username>

For the rest of this guide, we will be using the first, but don't be alarmed if yours looks different. In addition, we will be focused on Linux commands, since that is what Nest runs on. The concept applies to Windows as well, however some commands are different.

To run a command, simply type your command and press the 'Enter' or 'Return' key. Once you do, the output of the command will be displayed right below the prompt. For example, if you type:

~$ echo "Hello, world!"

and press 'Enter', your terminal will read:

~$ echo "Hello, world!"
Hello, world!
~$

The echo command 'echoes' whatever is after it:

~$ echo "I am creating a website using Nest!"
I am creating a website using Nest!
~$

Commands are usually of the format command options arguments. Options are usually prefixed with one or two dashes (ie, -o --option). One dash signifies an option that is one letter long, and allows you to chain options (ie, -al is the same as -a -l). Two dashes signify a single option which is usually an entire word or phrase (ie, --output). It is important to note that all commands follow these rules, and not all commands have the same options. You can usually check a command's manual page using man command to get a list of options, or run the command with -h or --help to get information about the command.

Notice how the ~$ is repeated at the end. Whenever you see the ~$ (or your computer's equivalent), it means that your terminal is ready for another command.

Other linux commands that are useful to know include:

  • cd, Change Directory - Notice the tilde (~) or path (C:\Users\username) in the examples above? That is known as your current working directory, or CWD. It corresponds to the folder that your terminal is in, and will affect what certain commands do. Using cd, you can change your working directory:
~$ cd Documents
~/Documents$

Folders can be nested inside other folders, indicated with a slash (/). On windows, a backslash (\) is used instead. the tilde (~) corresponds to your home directory, which is /Users/username on macOS and /home/username on Linux.

  • ls, List - This command will list what files and folders exist in the CWD or path provided:
~$ ls
Desktop  Documents  Downloads 
~$ ls Documents
Contract.pdf  Taxes  Work

Adding -l expands the list and provides more information:

~$ ls -al
drwxr-xr-x 2 username group 4096 Dec 17 06:43 Desktop
drwxr-xr-x 2 username group 4096 Dec 18 22:22 Documents
drwxr-xr-x 2 username group 4096 Nov 12 15:08 Downloads
~$ ls -al Documents
-rw-r--r-- 1 username group  524288 Dec 18 22:22 Contract.pdf
drwxr-xr-x 2 username group    4096 Apr 21 07:32 Taxes
drwxr-xr-x 2 username group    4096 Dec 18 15:43 Work
But what does something like drwxr-xrw- mean?

There are 4 parts to this: d, rwx, r-x, and rw-

d- Indicates this is a directory. Notice how Contract.pdf does not have this letter in its permission string.

rwx -> r stands for read, w stands for write, and x stands for execute. The first 3 letters indicate the permissions for the file owner. The file owner is named right after the permission string: username. rwx means the file owner can read, write, and execute the file.

r-x -> The second group is for the group, in this case just group. Group can be a bunch of users combined. r-x means people in the group can read and execute the file but can't write.

rw- -> The third and final group is for everyone else. Here, everyone else can read and write but can't execute.

  • mkdir - this command creates a new directory.
  • cat - This command reads the contents of a file
  • nano, vi - These are text editors. nano is recommended for beginners due to its ease of use.
To use nano:
~$ nano newfile.txt

This will pull up a file editor with a blank screen or the file content, based on whether the file exists or not. Once you're done, hit CTRL + X, click y to confirm you'd like to save, confirm the file name, and click enter to save.

Running File Programs in the Background

Need to keep a script running after you close your SSH session? nohup tells the process to ignore your leave and keep running.

~$ nohup [command to run] > [file.log] &