And learning some shell commands in the process
This brief tutorial has two purposes.
By the time you are finished, you should have a
githubdirectory immediately under the home directory of your SPIS ACMS account, that is a directory called
By the time you are finished, you’ll have learned about a few basic Unix commands, including the ones in the table below.
If both you and your pair partner are already thoroughly familiar with Unix command basics—that is, you know how to create
~/github, and you are throughly familiar with everything in the table below, you can just create ~/mkdir, and skip
the rest of this page.
But if either or both of you has any doubt, you are strongly encourage to go through this page carefully and slowly, to learn some of the basics of working with Unix commands at the bash shell. That is one of the most fundamental skills you’ll need throughout all of the courses that use the ACMS unix accounts during your entire stay at UCSD.
Unix commands covered in this tutorial
Here is a table of the Unix commands covered in this brief tutorial:
|Unix Command||Brief explanation|
||Show current date and time|
||Show history of recent unix commands|
||Print working directory|
||Create subdirectory (folder)
||Create subdirectory (folder)
||Change directory to home directory (1st option)|
||Change directory to home directory (2nd option)|
||Change directory to
||Change directory to parent of current directory (go up)|
||Change directory to
You should also learn the following concepts:
- Home directory (
~), directory, and subdirectory
- Unix/Linux directory tree, rooted at
- Bash Shell
- Shell prompt
Step 1: Bring up a bash terminal shell
Bring up a bash terminal shell. As a reminder, you can do this by selecting “Applications”, then either “Terminal” or “Konsole” from the menu that pops up. (Your Applications menu may have only Terminal, or only Konsole, or may have both. For our purposes, they work equally well.)
For now, we can use the following terms to mean more or less the same thing. (There are fine-grained distinctions among these terms, but those won’t be important until later in your studies)
- A “terminal session” on your ACMS account
- The “unix command line”
- The “bash shell prompt”
Let’s also establish that while “Unix” and “Linux” refer to different things, for our purposes in SPIS, it is enough to know that “Linux” is a particular flavor of the “Unix” family of operating systems. The systems we are running use Linux, in contradistiction to running Windows or Mac OS.
So, during SPIS, when we refer to Unix or Linux, these are, again more or less interchangable terms. The fine grained distinctions between the two can be saved for later.
Step 2: Learn about the bash prompt, date,
~ for home directory, and
When you open up a terminal session on the ACMS machines the bash terminal prompt typically looks like this:
It is called a prompt because it prompts you to enter some a command. One of the most basic commands you can enter is
date command. Try it: type in
date and press return Enter.
[spis16t3@ieng6-240]:~:32$ date Thu Aug 4 13:56:29 PDT 2016 [spis16t3@ieng6-240]:~:33$
The date is printed, and you get a new prompt. Note that the last
number in that prompt keeps increasing by one (1) each time you enter a command. Try entering
date commmand and pressing enter several times to see this.
These numbers refer to your “command history”. If you type the
history, you’ll see a list of all the recent commands you
have typed. Try it:
[spis16t3@ieng6-240]:~:33$ history 1 idle 2 idle 3 pwd
(I left some out here…)
31 exit 32 date 33 history [spis16t3@ieng6-240]:~:34$
You can see that the next command I type will be “number 34” in my history.
Step 3: Your account and machine in the prompt
There are a few others parts of the prompt.
spis16t3part is my account name. Your’s will be something like
xyare two letters
ieng6-240part is the machine I’m logged into. It’s full name is
- Finally, the
~part is a symbol for your home directory. That home directory is a very important concept.
Your home directory is a folder (called a directory on Unix) that stores all of the information you keep on the ACMS systems. When you first log on, you always start in your home directory.
Step 4: The
You can return to your home directory at any time by typing
by itself on the command line. The letters
cd stand for change
directory. Try it:
[spis16t3@ieng6-240]:~:34$ cd [spis16t3@ieng6-240]:~:35$
In this case, nothing changed, because we were already in our home directory. But, we can try changing into a different directory, and then returning to our home directory.
To see what other directories exist, we can type the
which is the list files command. Try it:
[spis16t3@ieng6-240]:~:39$ ls Desktop Documents Downloads Music Pictures Public Templates Videos [spis16t3@ieng6-240]:~:40$
You can see that there are eight folders (directories) under our home
directory. We are going to create one more. We’ll do that with the
mkdir command for make directory.
Step 5: The
Type this at the bash prompt:
mkdir github and the press enter. Then type
ls again and press enter:
[spis16t3@ieng6-240]:~:40$ mkdir github [spis16t3@ieng6-240]:~:41$ ls Desktop Documents Downloads Music Pictures Public Templates Videos github [spis16t3@ieng6-240]:~:42$
Now you see that there is an additional directory. Do you see it? It’s called github, and its the last one listed.
Step 6: More on
Our current directory is our home directory, as we can see from the
~ in our prompt. We can change our current directory to be the
github directory by typing
cd github, as shown here. Try it, and
ls right after that.
[spis16t3@ieng6-240]:~:42$ cd github [spis16t3@ieng6-240]:github:43$ ls [spis16t3@ieng6-240]:github:44$
You can see that the second part of the prompt changes to
show that we are our in our github directory. Since this directory is
located “under” our home directory, we sometimes call this a
Step 7: The
pwd command, and Unix paths
The next command we are going to learn is the
pwd command, for print working directory. Try it:
[spis16t3@ieng6-240]:github:44$ pwd /home/linux/ieng6/spis16/spis16t3/github [spis16t3@ieng6-240]:github:45$
You see that this command prints out our “working directory”. Current directory and working directory are just two different ways to say the same thing.
Lets look more closely at what was printed:
This is a list of parent directories (or folders), each of which contains the one below it.
A simplified view is this:
These files and directories, though exist in the context of a larger directory tree that contains many other directories and folders.
/home/linux/ieng6/spis16/spis16t3/github from the pwd command is called a path, since it shows the path from the root directory of the disk space on our machine, which is represented by the symbol
/, all the way down to the directory
github that we just created.
Our home directories for spis are all located inside
/home/linux/ieng6/spis16. They are, for example:
Each of you has their own home directory.
Step 8: Various directory navigation commands
As a reminder:
- The command
pwdtells us where we are by printing the current working directory.
- The command
lslists the files in the current directory
You can change the current working directory in a variety of ways. Try changing your directory in various ways,
exploring the directory tree shown in the diagram above, and using
ls to show the effect.
cdto go your home directory
cd ~spis16t2to go to a specific user’s home directory
cd ..to go up one level in the tree from where you are now.
cd /to go to the root of teh directory
cd footo go into a directory foo that is located in the current directory
You should be able to use the
pwd command at each level
cd /foo does NOT go one level down from the current
directory. Instead, it goes into the foo directory directly under the
Step 8: Finishing up in
When you are all finished, cd into your
~/github directory. Note that you can do this
from anywhere with a single command:
cd ~/github, as shown here:
[spis16t3@ieng6-240]:~:79$ cd ~/github [spis16t3@ieng6-240]:github:80$ pwd /home/linux/ieng6/spis16/spis16t3/github [spis16t3@ieng6-240]:github:81$
As shown above, use
pwd to verify that you are indeed in your
Your output won’t say
spis16t3, but instead will show your own ACMS username in place of that.
If you were doing these steps as part of SPIS 2016 lab02,
you can use this link to return there now: SPIS 2016 lab02