DOC PREVIEW
UI STAT 5400 - Lab session 1

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. 28, 20091 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 th en following the prompts.2 The course home pageBring up the Firefox Internet browser by clicking on the icon of the world with aflaming fox on it.Type in the URL (address) of the course homepage:www.stat.uiowa.edu/~kcowles/s166_2009Go 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 operating system. Thereare actually a choice of several different shells under Linux. The sytem adminis-trators at the Computer Support group have made tcsh the default shell on ournetwork, and that is what we will use in this class.The Linux shell has hundreds of commands. However, most basic tasks can beaccomplished u sing only about a dozen of them.Linux commands and filenames are case-sensitive; e.g. “LS” is different from “ls.”3.1 ls• probably most often-used command in Linux1• 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 th e 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 reached• typing q also stop more and returns you to the Linux promptEnter the command to display the contents of your configu ration file.If you try to use more on a file that is not a text fi le, 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 dir ectory. If youalready know a Linux text editor such as Vi, Vim, or Emacs, you are welcome touse it for this course. If n ot, p lease 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:KiriLucyWe 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.2Use gedit again to create a text file n amed ”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 cur rent 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>• example: cd pets– if the directory you want to change to is in the current directory3• 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 th is 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 h ome 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 perio ds 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 d irectory 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 keeping the home directory as the current directory.mkdir pets/mammalsmkdir pets/reptilesmkdir pets/birdsmkdir pets/other45.5 cp• cp copies a file or directoryJust to be on the


View Full Document

UI STAT 5400 - Lab session 1

Documents in this Course
Load more
Download Lab session 1
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 Lab session 1 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 Lab session 1 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?