|
If you have never used Linux or UNIX before, this section will help you get started. This section assumes that you have never used Linux before and have not logged into your account before. If you have logged in before, some command output will be slightly different.
When you first ssh to Saguaro (see Accessing Saguaro), you will be presented with a command prompt that looks like:
[yourusername@saguaro2 ~]$
Don't Panic! Within a few minutes you will know the basics of using Linux. The command prompt tells you some useful information that helps you keep track of who you are, what system you are on, and where on the system you are. In this case it says that you are logged in as yourusername to the saguaro2 system and that you are in the ~ directory. Directories are like folders in Microsoft Windows. ~ is a short name for your home directory, which actually is located at /home/username. As you move through the filesystem, the ~ will be replaced with the name of the directory you are currently in.
The first thing you need to know is how to look around. The ls command lists the contents of the current directory. Commands are run from the command prompt by typing the command in an hitting the "Enter" or "Return" key on your keyboard. If you run the command now, you should get the following output:
[yourusername@saguaro2 ~]$ ls [yourusername@saguaro2 ~]$
There are a few things to learn here. First, when a command is done running, you get another command prompt. Second, though it looks like ls did nothing, it really just told you that there a no files or directories in your home directory. Actually there are some hidden files, to see them run ls -a:
[yourusername@saguaro2 ~]$ ls -a
. .. .bash_logout .bash_profile .bashrc .emacs .gtkrc .kde .ssh
[yourusername@saguaro2 ~]
Files are hidden by putting a . at the beginning of their names. Hidden files are usually used to hold preferences and other information needed by the system. You do not have to worry about them now.
The command prompt only shows the name of the directory you are currently in. To see the full path (name) of the directory you are in run pwd:
[yourusername@saguaro2 ~]$ pwd
/home/yourusername
[yourusername@saguaro2 ~]$
Directories are arranged like a tree, with each new directory nested in the preceding directory. The / symbol is used to separate directory names. Here we learn that home is in the top level directory, and that it contains a directory named yourusername, which is the directory we are currently in. ~ is another name for your home directory, which is located at /home/username. When you log in you will always start in your home directory.
Now that you can look around, lets move around a little bit. First we need some place to move to, so we will create a directory. The command mkdir newdir makes a directory called newdir and looks like this:
[yourusername@saguaro2 ~]$ mkdir newdir [yourusername@saguaro2 ~]$
Doesn't look like much yet, but now if you look around with ls you get:
[yourusername@saguaro2 ~]$ ls
newdir
[yourusername@saguaro2 ~]$
Notice that ls now produces output in the form of newdir. There is the newdir that you created with mkdir. Assuming that the ssh program you are using supports color, you will notice that newdir is blue which means that it is a directory. Files that are not directories are black.
Now that we have a directory, let's go into it and look around. You change directories with the cd command.
[yourusername@saguaro2 ~]$ cd newdir
[yourusername@saguaro2 newdir]$
Notice that after changing to the newdir directory the ~ in the command prompt changed to newdir. This is because you are now in the newdir directory. Now let's see the full path of the directory we are in and then see if there are any files:
[yourusername@saguaro2 newdir]$ pwd
/home/yourusername/newdir
[yourusername@saguaro2 newdir]$ ls
[yourusername@saguaro2 newdir]$
There are two ways to move up a directory (i.e., change to /home/yourusername. The first is to use the special "parent directory" directory name: ..:
[yourusername@saguaro2 newdir]$ cd ..
[yourusername@saguaro2 ~]$
This method always moves you up one directory level. The second method is to use the full path name of the directory you want to move to:
[yourusername@saguaro2 newdir]$ cd /home/yourusername
[yourusername@saguaro2 ~]$
This method allows you to move to any directory that you know the full path name to. You can quickly change to your home directory by running cd with out a path name, or using ~ as the path name.
[yourusername@saguaro2 newdir]$ cd
[yourusername@saguaro2 ~]$ or
[yourusername@saguaro2 newdir]$ cd ~
[yourusername@saguaro2 ~]$
~ is always the same thing as your home directory. For instance /home/yourusername/newdir and ~/newdir are full path names to the same directory.
Now that we can move around, let's try manipulating files. First we need to create one. The touch command will create an empty file:
[yourusername@saguaro2 ~]$ touch newfile
[yourusername@saguaro2 ~]$ ls
newdir newfile
[yourusername@saguaro2 ~]$
Now that we have a file to work with, let's make a copy called newfile2 with the cp command:
[yourusername@saguaro2 ~]$ cp newfile newfile2
[yourusername@saguaro2 ~]$
To move a file to another directory you use the mv. To move newfile2 to the newdir directory I would run:
[yourusername@saguaro2 ~]$ mv newfile2 newdir
[yourusername@saguaro2 ~]$ ls newdir
newfile2
[yourusername@saguaro2 ~]$
So we moved newfile2 into newdir and looked in newdir to see if it was there. It was. You can also use the mv command to rename files.
Since this is only a tutorial, you don't actually need any of the files or directories that we created, so lets remove them. File can be removed with the rm command, directories with the rmdir command. Once a file is removed it is gone. It cannot be unremoved, so be careful! Here are the commands to use to remove the files and directories we created:
[yourusername@saguaro2 ~]$ rm newdir/newfile2
[yourusername@saguaro2 ~]$ rmdir newdir
[yourusername@saguaro2 ~]$ rm newfile
[yourusername@saguaro2 ~]$ ls
[yourusername@saguaro2 ~]$
That was easy! The only thing to really notice, besides the fact that the files were in fact removed, was when I deleted newfile2. Remember that newfile2 was moved into the newdir directory. Just like / separates directory levels in a full path name, we can use it to specify partial path names starting with the directory we are in, therefore newdir/newfile2 refers to the newfile2 in the newdir directory that is in the directory we are currently in.
Well now you know the basics of moving around and organizing your data. Most of the commands here are able to do more things than I showed here. To learn more about a specific command, run man commandname to get a manual page (I like to call them 'man pages') for that command. The arrow keys will help you move around the man page viewer. When you are ready to exit, press q.
Edit Files
Files can be edited on your workstation and then transferred to Saguaro, or they can be edited on Saguaro. We provide the following editors:
- Text-based interface
- Graphical interface (X-Windows)
If you do not know how to use any of these editors, start with nano but running nano filename where filename is the file you want to edit. Use the arrow keys to move around and make the changes you need. When you are done, hold down the Control Key (some times marked as Ctrl) and press x. Nano will then prompt you to save (or not save) the file. Check nano's web site for more information on using nano.
|