DOC PREVIEW
UI STAT 5400 - Using Linux and the text editor

This preview shows page 1 out of 3 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

22S:166Lab session 1Using Linux and the text editorAug. 25, 20061 Getting startedLog onto the lab computers using the username and password provided to you bythe Computer Support Group.Left click the icon of a computer screen at the bottom of the screen to bring up aterminal window. If you are using the Linux network for the first time, change yourpassword by enteringpasswdand then following the prompts.2 The course home pageBring up the Mozilla Internet browser by clicking on the icon of the world with amouse on it.Type in the URL (address) of the course homepage:www.stat.uiowa.edu/~kcowles/s166_2006Go to the “Web resources” section, and click on “Mathematical Sciences Libraryreserve.” Right now this course doesn’t appear on their course listing, but this iswhere you will find solutions to homework and practice exams as the semester goeson.Go back to the “Web resources” page, and notice links to reading assignments. Youshould complete the readings by the end of the week under which they are listed. Forexample, you should finish reading “Learning the shell” from the Linux Commandlink by today.3 Using the Linux shellThe Linux shell passes the commands that you type to the operationg system.There are actually a choice of several different shells under Linux. The sytem ad-ministrators at the Computer Support group have made tcsh the default shell onour network, and that is what we will use in this class.The Linux shell has hundreds of commands. However, most basic tasks can beaccomplished using only about a dozen of them.Linux commands and filenames are case-sensitive; e.g. “LS” is different from “ls.”13.1 ls• probably most often-used command in Linux• lists contents of a directory of the current directory unless you tell it otherwise• hidden files– files whose names start with a period are “hidden”; e.g. .cshrc – theconfiguration file– use ls -a to include the hidden files in the listing• use ls -l to get the “long listing,” including security modeEnter the command to list the contents of your home directory. Use the up-arrowto recall the line that you just typed. Add the option on the end to include thehidden files. Use the up-arrow again; backspace to remove the previous option andadd the one to get the detailed listing.3.2 more• used to view the contents of a file• syntax: more <filename>• got its name because after displaying each page of text in the file, it pausesand prints “–More–” at bottom of screenyou hit spacebar to see next screenful• stops and returns you to Linux prompt when end of file is reachedEnter the command to display the contents of your configuration file.If you try to use more on a file that is not a text file, you will get strange results, aswe will see later.4 Text editorNow we will use a text editor to create two text files in the home directory. If youalready know a Linux text editor such as Vi, Vim, or Emacs, you are welcome touse it for this course. If not, please learn to use the Gnu text editor called gedit. Toinvoke it, enter geditWe will type a file with the names of dogs. If you have one or more dogs, type intheir names, one on each line. If not, type in the names of some of my dogs:KiriLucy2We now will use the File menu and the “Save as” option to save this file in the homedirectory under the name “dogs.” If you already have a directory called “dogs” insideyour home directory, you will have to choose a different name.Use gedit again to create a text file named ”cats.” If you have one or more cats,enter their names. Otherwise put in a single line with the word NoneSave the file. Use the appropriate command to list the files in your home directory,so you can make sure that the two new files are there. Then use the appropriatecommand to view the contents of the dogs file.5 Linux shell commands, continued5.1 mkdir• short for “make directory”• creates a new directoryin the current directory unless you tell it otherwiseCreate a directory called “pets” in your root directory.5.2 mv• moves or renames a file or directory• syntax: mv <source> <destination>• examples:– mv dogs petsmoves the dogs file out of the home directory and into the pets directoryUse ls to verify that dogs is no longer in the home directory.– mv cats felinesrenames cats to be called felinesuse “ls” to make sure it worked• Now rename the file back to “cats.”• Now issue the command to move the cats file into the pets directory5.3 cd• changes the active directory• syntax:cd <directory name>3• example: cd pets– if the directory you want to change to is in the current directory• cd /group/ftp/pub/kcowles/datasets– need “pathname” to go to a directory that is elsewhere– This is the directory that the “Datasets” link on the course web pageaccesses– List its contents using the long form. Interpret the security mode for oneof the files. Is this what you would expect for a file in this directory?– Enter more campaignsample.zip to see what a non-text file looks likewhen you try to display it with more. You may need to close the terminalwindow and open a different one after doing this.• cd by itself with no directory name will return you to your home directory;do that now.5.4 pwd• prints the current (working) directory• syntax:pwdYour home directory isn’t really the top of the tree – there are other higher directorieson the server where our home directories reside.You can tell this because there are lots of parts to the pathname of directory. Theslashes separate the names of the levels of the tree.To go back to the directory immediately above the current directory, use cd .. (thetwo periods are part of the command).Pathnames enable you to carry out operations on directories other than the currentone. A relative pathname assumes that the path of the current directory goes beforethe part that you type. For example, from in your home directory, enterls petsmore pets/dogsls /group/ftpThe last row above contains an absolute pathname. Note that it starts with a slash.Suppose that we decide to organize our “pets” subdirectory differently. We want tohave individual subdirectories called “mammals,” “reptiles,” “birds,” and “Other”in the pets directory, and we want the files called “dogs” and “cats” to be in the“mammals” subdirectory.To practice using pathnames, let’s create the new subdirectories and move the fileswhile


View Full Document

UI STAT 5400 - Using Linux and the text editor

Documents in this Course
Load more
Download Using Linux and the text editor
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Using Linux and the text editor and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Using Linux and the text editor 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?