More actions
Every computer that you use has an operating system. An operating system manages your computer's resources and makes sure that everything running on your computer, from the internal system tools to the web browser you're using to read this, has time to run. Popular operating systems include Windows, macOS, and Linux!
Linux isn't used as much as Windows and macOS for personal computers, but it's still popular among developers and enthusiasts. However, Linux is the standard for servers! That's why we use Linux for Nest. It's a little different from what you might be used to, but you'll be working with Linux in no time!
Linux used a text-based user interface (TUI) rather than a graphical user interface (GUI). This means that instead of moving your cursor around with a mouse or trackpad and clicking on items, you simply type commands in the "shell" for the computer to execute.
Nest actually runs two Linux distributions (distros):
- NixOS, a declarative distro using an immutable design for the Secure VM
- Debian 13 "Trixie", a reliable stable release distro for the user Nest VM
Using the Terminal
The default interface on Linux is the terminal. Other operating systems also have a terminal—on Windows, it's an app called PowerShell, and on macOS, it's just called Terminal.
Once you've entered the terminal, you will be greeted with a prompt like this:
username@hostname:~$
Note that for other systems, it may look different, but this is generally how terminal prompts look on Linux.
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 ~$ (the prompt) is repeated at the end. Whenever you see the ~$ (or your computer's equivalent), it means that your terminal is ready (or prompts you) 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 (working directory or CWD). It corresponds to the folder that your terminal is in, and will affect what certain commands do. Usingcd, you can change your working directory:
~$ cd Documents ~/Documents$
Directories (folders) can be nested inside other directories, 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 directories 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
Directories
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.
Some more commands
mkdir– this command makes a new directory.cat– This command reads (concatenates) the contents of a file.nano,vi(orvim,viimproved) – These are text editors.nanois recommended for beginners due to its ease of use.- To save and exit in
vi/vim, press Esc, then type :wq (write then quit).
- To save and exit in
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 (^X), Y to confirm you'd like to save, confirm the file name, and hit 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] &