Navigating UNIX Systems
You have been introduced to the NFS (NCSU File System) and some of its functionality here at NC State. Much of what you have learned is what this system looks like and what comprises a pathname. Now you will learn some basic commands to make your use of NFS easier and more effective.
Computers these days have a variety of interfaces for giving them commands; fancy graphical user interfaces, voice interfaces, and even AR/VR are everywhere. These are great for 80% of use-cases, but they are often fundamentally restricted in what they allow you to do — you cannot press a button that isn’t there or give a voice command that hasn’t been programmed. To take full advantage of the tools your computer provides, we have to go old-school and drop down to a textual interface: The Shell.
Nearly all platforms you can get your hands on have a shell in one form or another, and many of them have several shells for you to choose from. While they may vary in the details, at their core they are all roughly the same: they allow you to run programs, give them input, and inspect their output in a semi-structured way. To open a shell prompt (where you can type commands), you first need a terminal. Your device probably shipped with one installed, or you can install one fairly easily. For NC State, we’ll have you get on remote Eos to get uniformity across all students, however, most of these shell commands are available locally on your computer as well.
In UNIX/Linux, you interact with the system by typing commands into a terminal window. The computer shows a command prompt to let you know it’s ready for input. In the University’s Eos system, the computer command prompt is eos$. When you type a command and press Enter, the system tries to execute it and then returns to the prompt. When the system completes the requested action, it will issue another command prompt.
Linux/UNIX commands have options and/or arguments that can be typed after the basic command to further specify an action. Arguments are typically paths to files (ref. File Systems) and options assign more specific functions to the command, or add additional actions to the command.
Learning Outcomes
Navigate and operate UNIX-based command-line operations.
Chapter Learning Outcomes
- Use basic Unix commands such as
script, man, pwd, cd, list, mkdir
- Connect to a remote system using
ssh
and describe its purpose in secure communication - Explain the general syntax structure for Unix commands, including options and arguments
- Troubleshoot errors when using Unix commands by interpreting terminal output and correcting syntax
Extra Resources
If you would like to learn more about Unix commands, NC State offers a free account with LinkedIn Learning, which hosts a variety of tutorial videos. Once you have set up your LinkedIn Learning account, you can walk through Unix command training such as this one linked and earn a certificate.
Walkthrough
The syntax for a UNIX command is broken into three parts:
- the command
- a list of options, and
- a list of arguments.
For the purposes of this class, all three must be done in this order, although either the options or the list of arguments may be excluded depending on what command you are using and how it is being used. Each part of a command is separated by a space.
syntax: command -(options) argument1 argument2 ...
Command
The first part, the command, tells the computer what sort of operation is being done.
- For example, if I want to use the ls command (which outputs the contents of a certain directory), I would always begin by typing ls.
List of Options
Options modify how a command works. They’re usually single letters that start with a hyphen (-
), like -a
or -l
. You can combine multiple options with no spaces, like ls -al
combines the -a (“all”) and -l (“long”) option for the ls command. My “option list” could be -al or -la (order does not matter).
List of arguments
Finally, many commands use a list of arguments. Arguments tell the command what to work on; usually, it’s a file, folder, or path, but it can be any information. You’ll learn specific options and arguments for other commands as you go.
There can be more than one argument for a command, and arguments must always be supplied in the order they are expected. Each argument should be separated by a space (which is why it is important not to include spaces in the names of files and folders). For example, we could have the following command, options, and argument:
ls
= the command-al
= options~/
= argument (your home directory)
Putting it together:
eos$ ls -al ~/
You will learn more about the options and arguments for each command in the next few sections of this chapter.
Note: eos$ is given by the computer and should NOT be typed into the terminal.