|
|
Line 1: |
Line 1: |
| 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.
| | #REDIRECT [[Linux]] |
| | |
| * 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 <code>command options arguments</code>. Options are usually prefixed with one or two dashes (ie, <code>-o --option</code>). One dash signifies an option that is one letter long, and allows you to chain options (ie, <code>-al</code> is the same as <code>-a -l</code>). Two dashes signify a single option which is usually an entire word or phrase (ie, <code>--output</code>). 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 <code>man command</code> to get a list of options, or run the command with <code>-h</code> or <code>--help</code> to get information about the command.
| |
| | |
| Notice how the <code>~$</code> is repeated at the end. Whenever you see the <code>~$</code> (or your computer's equivalent), it means that your terminal is ready for another command.
| |
| | |
| Other linux commands that are useful to know include:
| |
| | |
| * <code>cd</code>, '''C'''hange '''D'''irectory - 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 <code>cd</code>, 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.
| |
| | |
| * <code>ls</code>, '''L'''i'''s'''t - 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 <code>-l</code> 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: <code>d</code>, <code>rwx</code>, <code>r-x</code>, and <code>rw-</code>
| |
| | |
| <code>d</code>- Indicates this is a directory. Notice how <code>Contract.pdf</code> does not have this letter in its permission string.
| |
| | |
| <code>rwx</code> -> 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: <code>username</code>. <code>rwx</code> means the file owner can read, write, and execute the file.
| |
| | |
| <code>r-x</code> -> The second group is for the group, in this case just <code>group</code>. Group can be a bunch of users combined. <code>r-x</code> means people in the group can read and execute the file but can't write.
| |
| | |
| <code>rw-</code> -> The third and final group is for everyone else. Here, everyone else can read and write but can't execute.
| |
| | |
| * <code>mkdir</code> - this command creates a new directory.
| |
| * <code>cat</code> - This command reads the contents of a file
| |
| * <code>nano</code>, <code>vi</code> - These are text editors. <code>nano</code> 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 <code>CTRL</code> + <code>X</code>, click <code>y</code> 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] &
| |