Q: Are we really using UNIX?

A: We don't know.

Servers may be using either UNIX or LINUX, but the commands for both operating systems are essentially the same. So, if we learn the commands and behaviors for one, we probably can work easily on the other as well.

UNIX/LINUX using a terminal connection

You are about to learn enough UNIX commands to be dangerous to yourself and others.

A little knowledge is a dangerous thing. This is especially true of UNIX. In UNIX it is possible to erase every one of your files with one little command and never get an "Are you sure?" message or warning.

Ask me.
I've done it.
And while I've done it to my own files, some network managers have done it to every user's files.

Accessing Isis, the UNC server systems

To login, you need to make a terminal connection to the isis server (isis.unc.edu is actually a bunch of computers).

For Windows machines, SILS uses a terminal client program called "SSH", but you can use other compatible clients.

If you are using a Mac, connecting with Terminal is somewhat similar.

SSH uses ssh (the Secure Shell) to login, so that your username and password are not visible to other people on the campus network.

To login from your Internet-connected computer wherever it is

  1. Start the program (from your desktop, the Start menu, or from the Run dialog box)
  2. Select "Quick Connect", then enter isis.unc.edu in the dialog box and enter your onyen.
  3. Accept and Save the host key, if requested. (This is the encryption key that lets Isis identify itself).
  4. You will be prompted for your username & password; provide them. Connect to Remote Host dialog box
  5. Once there, you are in a shell session and thus into UNIX. The $ is the UNIX prompt. (the Linux prompt is a bit different).
schematic of how UNIX works like a bullseye with the Kernel at the center, surrounded by the Shell, 
						which is surrounded by the Applications Enter a Shell session from the command line in Isis

What does this mean? Where exactly are we? Are there any clues?

We are in our "home" directory.

  • In UNIX file system parlance there are directories similar to the "folders" that you may be used to using on Mac or Windows systems.
  • These directories exist in a hierarchical structure where your "home" directory is the "root" or top level of your files and directories.
  • Some general tips on logging into and working on remote computers

    • Your mouse won't do much. You can't click things to make them happen.
    • You can, however, copy and paste between applications.
    • You can scroll up and down in your SSH window to see what you did previously.
    • You can switch between your login window and other windows, or set them up so you can see multiple windows. This is very useful when editing a Web page while logged in, and viewing it in a Web browser in another window.

    [top]

    Working within UNIX

    We will work from the UNIX command line [the $].

    This would be a good time to get used to a convention.
    Working with Unix/Linux at the command line requires us to know certain exact commands.
    But we also want to become comfortable with the fact that some commands require an argument to effectively carry out the command.
    Sometimes the argument will include a specific value that must be appended to the argument in order to carry out the command.

    We will have to get used to this syntax as it will be a common theme in all the tools we will encounter.

    • We will start by creating a file with which we can experiment.
    • At the $ prompt, type pico which will open up a UNIX text editor. Then type in something to create a text file. Use CNTL+O to save the file. [yes, I know, it's an odd way to save, but it's how Pico wants to work]
    • Save it as firstfile01.
    • Once it's saved, use CNTL+X to exit Pico and go back to the $ prompt. This created a file called firstfile01 which we will copy and use.
    • Let's use a new UNIX command. cp copy file
      Type cp firstfile01 secondfile02
      This creates a copy of your firstfile01 file called secondfile02.

    Now that we've created a file we can use, here are some commands that can manipulate it.

    • The more command is useful for viewing the contents of a file:
    • more secondfile02 will view the file one line at a time (don't worry about reading the contents, it's just for demonstration)
    • In more:
      spacebar goes to the next page
      return goes forward a line
      q quits and returns you to the prompt
      b goes back a page
      /x searches forward for x (or whatever you type, then press return)
      h gives a help screen
    • One also wants to learn the man command. Man is the online UNIX manual. It takes a command name as an argument. The manual page is viewed using more, which you've just learned how to use. To find out more about more, try this: man more

    [top]

    Directories

    Let's see how UNIX handles directories.

    All UNIX users have their own "home" directories. We are sent to the home directory there on login. Any files we create will be stored here, but unaccessible to other people on the system (unless we grant them permission).

    • pwd prints your working directory. Unless you've changed it, this will be your "home" directory.
    • cd changes your directory. With no argument, it takes you "home".
    • cd public_html changes to your public_html subdirectory.
    • Type ls and you'll see what files you have (probably none, except for a "public_html" directory).

    Try this: cd public_html then ls or pwd

    Do you see that you changed to a new directory?

    Type cd to return home.

    More on ls (that's "ELL ESS"):

    • ls -l gives a long directory listing, including the file size, creation date, and access permissions
    • ls -s gives the size (in blocks) of a file
    • ls -a shows all files. Otherwise, files starting with a dot (.) are skipped. Your current directory is always abbreviated as ., and the parent directory is always abbreviated as ..
    • ls -l testfile02 will give long directory information on only the "testfile02" file
    • see how this is different than just ls

    Finally, let's manipulate our secondfile02. We can rename it, copy it, and delete it:

    • cp secondfile02 newfile copies the file to a new filename. You can use ls to see both files, and notice they are the same size.
    • mv newfile anotherfile renames the file newfile to the new filename, anotherfile.
    • Use ls to confirm this.
    • rm anotherfile permanently removes the file anotherfile.

    rm is forever! Be careful with it.

    [top]

    Create directories and files

    The next step is to create some directories and files in your home directory.

    There are several commands that you will use to create directories and files.

    • mkdir make directory
    • rmdir remove directory
    • mv move file
    • rm remove file

    These are (again) command line commands. They all have options, and they all take one or more arguments. In UNIX parlance, an argument is a file or directory name, or some other piece of information needed to complete the command.

    We will look at the arguments.

    • To create a directory, type the make directory command mkdir followed by the name you want the directory to have. This looks like:
      mkdir mynewdir In this case, mynewdir is the argument for the mkdir command.
    • Removing a directory is similar; the argument is the name of the directory you want to remove. Try it.
      rm for removing a file takes one argument, the name of the file.
    • The remaining two commands, cp and mv, each take two arguments.
      In the copy command, the first argument is the name of the file you wish to move or copy, the second argument is the name of the file you want to copy into or move the file to.
    • cp mynewfile mynewfile1 makes a copy of the file named mynewfile and names it mynewfile1
      The move command is essentially a rename command.

    The arguments are not limited to file and directory names in the local directory. An argument can specify another directory and a file in that directory. For instance, if you have a directory called public_html (which you should), then you can move a file from your home directory into this directory as follows.

    • mv thisfile public_html/
    • If in addition to moving the file, you want to rename it, then the new file name can be typed following the slash, as follows:
      mv thisfile public_html/thatfile

    [top]

    Editing with pico

    Pico is a simple text editor that allows you to edit text documents. Pico is not a word processor, as word processors allow you to format objects like text, tables, and paragraph types whereas text editors only allow one object - text.

    To invoke Pico, just type pico at the command line and you will be "in" the editor.

    The editor commands are found at the bottom of the screen. In addition to pico, there are two other text editors, vi and emacs, available for your use. If you are already using vi or emacs, continue to use them, but pico is probably the simplest to learn to use because of the command listing at the bottom.

    Use pico to create a file in your home directory that contains your name, some facts, and information about yourself.

    [top]

    Do some navigating

    As you move around among your files and directories, you may become disoriented as to "where" you are. UNIX has the concept of "current" directory, also known as the working directory, or the directory you are currently "in". Two additional commands will be useful to determine what directory you are in.

    • to find yourself, use the pwd print working directory command
      pwd doesn't take any arguments
    • to move between directories, use the cd change directory command
      cd takes the destination directory as its single argument.
    • [top]

      UNIX file literacy

      These are commands commonly used. You will find them valuable when you edit your Web pages on the UNIX system, and for other UNIX tasks as well. Remember:

      UNIX is case-sensitive

      Commands can have arguments and options. Options usually have a hyphen.

      Most common errors in UNIX come from not knowing what directory you are in. Use the pwd and ls commands to keep track.

      Use the man command to get usage information

      [top]

      More UNIX

      from ITS

      [top]


      operating system | command line | command line - mac | text editing | text processing | 01.05 | next session