What to do at the prompt
Once you can access your account, you will be presented with the prompt. At this prompt, you can do many many many things. For all of these, we hope to have tutorials soon.
A few basic examples of what you can do:
- Setup a website
- Read your group e-mail
- Setup rules to forward email to another address
- Transfer files from your computer or your FAS account
- Grant/remove access from other FAS usernames
- Setup SSH keys to simplify access (avoid the double login!)
- Check your quota
- Anything else a modern Linux computer does.
Here, we'll try to give a simple overview of UNIX basics as they relate to typical use of our systems.
Getting Around, Looking Around
At the prompt, you start off in your home directory, which is represented by the tilde "~". Commands are entered by typing stuff and pressing enter. An easy example: to list the files in your home directory, type
and press enter; you will receive a list of files. Configuration files in UNIX are usually hidden by prefixing them with a period. To view all these hidden files/folders, use
which should return a longer list. For the long details on each item, such as type and size, you need to add the
-l flag, so type
ls -a -l
for short. As you can see, adding options after the command name changes the output in various ways.
Sometimes the output is more than you can see on one screen. To break it up into chunks, you can use common UNIX technique called "piping", which utilizes the character "|", typed by pressing shift+backslash. Basically, we can send the output from one command,
ls, to another program called
less which helps us view it one screen at a time, using the "|" character. Try
ls -al | less
to see how this works; you should be able to use your arrow keys to scroll and then press "q" to exit back to the command line. Any command can likewise be piped into
less by suffixing it with
| less. Piping is what extends simple UNIX commands into powerful workflows.
cat to dump files
You will probably see a bunch of hidden files in your home directory with completely foreign-looking names like
.cshrc. To view the contents of any file, use
and it will be dumped to your screen. This is where piping to
cat .cshrc | less
may also come in handy. Most of these files will probably hold a lot of code that you won't understand, but that's okay! The key is to be able to get a sense of what's already lying around.
Switch directories with
To move out of your home directory, you use the
cd path command.
cd takes either relative paths or absolute paths. Try
(the space is necessary in UNIX) to move up one directory level, or
to move to the root "/" directory of the system. You will usually see the change in your current path reflected in your prompt. Sometimes, you will not be able to enter directories because you won't have sufficient privileges. You can always type
to return to your home directory, where you will always have full privileges.
man to get help
For any command that we will ever introduce, or any other commands out there, you can usually get the long story on everything they can do and every option you could possibly use by typing
less, you can use arrow keys to scroll, and press "q" to quit back to the command line.
Making and Editing Things
Make directories with
To host a website on HCS that people can view at http://www.hcs.harvard.edu/group-name, you simply put files into a folder called "web" in your home directory. (If you have a people.fas site, this would be equivalent to your public_html folder there.) But of course, you need to create this directory in the first place, and here is where you can use the
mkdir command. While in your home directory (
cd ~ if you aren't sure) use
and observe the results with
ls. Move into your newly created directory with
This is where you can now build a website.
pico to edit files
Every website needs files. To make files, you use an editor. A good editor for beginners is
pico, which behaves a lot like the popular mail client
pine. There are many other editors, and the most l33t picks are usually
emacs, but both of these have a bit of a learning curve, so you can tackle them later.
Making a file is as simple as calling an editor with a filename that doesn't yet exist; for instance try
from your web directory. index.html is the file that comprises the homepage for your group, and from there you can link to the rest of your pages. Now that you're in pico, start typing something! If you don't know html yet, we suggest:
Group Name Website
Hello world! Nothing to see here yet; try going to <a href="http://www.google.com">Google</a>.
(If you're lazy you can probably copy and paste that into your terminal program. To paste it on the Mac it's Command-V in Terminal.app; in SecureCRT for Windows it's Shift+Insert.)
Once you've done that, notice that there are a bunch of commands listed at the bottom of the screen. You can execute any of them by pressing Control (^ stands for control) and the indicated letter. We're going to Exit, so press Control-X. It will ask you whether you want to save your changes; hit Y, and then when it prompts for the filename hit Enter to accept the one we specified when we ran
pico, which was index.html. A tip: WriteOut is pico-speak for "save", so use Control-O if you want to save your progress while working on something important.
Now check out your new website! Go to http://www.hcs.harvard.edu/group-name to see what you've made. You've just created a webpage on the internet.
Copying, Moving, and Deleting Things
Say you wanted to make another page, but you don't want to type all that code again. Simply copy the file! From within ~/web, let's use
cp index.html newpage.html
You'll see by using
ls that there are now two files in the directory. To edit the new one using
pico, you would then type
and perform your edits and then save them. Try it, the new page will be at http://www.hcs.harvard.edu/group-name/newpage.html when you are finished.
Now, say you've made it into a page about Harvard, and you want to name it appropriately.
mv is the tool that both renames a file and moves it to another directory, if you want. Try
mv newpage.html harvard.html
and check the results with
ls. Also, go ahead and see if you can guess what the URL for your new page would be. If you want to move it into a directory, you specify a path instead of just a filename for the second argument; for example,
mv harvard.html schools/
would put harvard.html into a new directory called schools. Tip: you can use the relative path
../ to move something into its parent directory.
Deleting: maniacal use of
It's nice that we made a website, but you'll probably want to make something different and get rid of the files from this tutorial. It's OK, we won't take it personally. This is done with
rm. To ditch our index.html page, go ahead and type
to which you should be asked
rm: remove regular file `index.html'?
and then pressing Y gets rid of it forever. By default your shell will prompt before deleting files, but this can be overridden with the
-f flag. You can also delete directories and everything inside of them in one shot; to delete the schools directory that we made and the page inside, use
rm -rf schools
Note that we added the
-r flag to have it delete the entire directory, and the
-f flag ignores the prompts.
You are well on your way toward managing your new HCS account, but there's so much else you can do! First of all, remember that you can access help on any command with
man; we should have more tutorials here soon for help on other functions. Here's a list of other useful programs you can use on your HCS account:
pwd- tells you what directory you're in
pine- check your mail
quota- check how much disk space you have left
ps- list your running processes
access- edit who can access the account (an HCS-written program)
zip- make .zip archives
chmod- set permissions (very important, learn to use it)
grep- search within files (the sysadmin's swiss army knife)
exit- gracefully log out.
Many more in-depth tutorials on UNIX can be found online with a bit of googling, such as this one; good luck and don't be afraid to ask acctserv@hcs if you have issues!