DOC PREVIEW
UI STAT 5400 - Lab session 1 - Using Linux

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. 26, 20111 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 enteringhpasswdand then following the prompts. Note: the cursor will not move as you type in yournew password.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_2011Go 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 shellIn the instructions below, I am using the angle brackets < and > to enclose text forwhich you substitute appropriate text. Do not type the angle brackets themselves.The 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.”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 w ith 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 n ame because after displaying each page of text in the file, it paus esand 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 L inux promptEnter 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 gedit, you are welcome to useit for this course. If not, please learn to use the text editor called Emacs. It hasspecial features that make it very convenient to use for LATEX and R programming.To invoke it, enter emacsUse the File menu to choose “Visit new file.” In the blank line that opens, type inthe name that you want to give the file, which is “dogs.txt” We will type into thewindow (or “buffer”). If you have one or more dogs, type in their names, one oneach line. If not, type in the names of my dogs:2LucyDesiOrbitWe now will use the File menu and the “Save” option to save this file in the homedirectory. If you already h ave a file or directory called “dogs.txt” inside your homedirectory, you will have to choose a different name.Use Emacs again to create a text file named ”cats.txt.” If you have one or morecats, enter their n ames. 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.txt petsmoves the dogs.txt file out of the home directory and into the pets direc-toryUse ls to verify that dogs is no longer in the home directory.– mv cats.txt felines.txtrenames cats.txt to be called felines.txtuse “ls” to make sure it worked• Now rename the file back to “cats.txt.”• Now issue the command to move the cats.txt file into the pets directory35.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 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 usin g the long form. Interpret the security mode for oneof the files. Is th is what you would expect for a file in this directory?• 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 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 directory goes beforethe part that you type. For example, from in your home directory, enterls petsmore pets/dogs.txtls /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,” “bird s,” and “Other”in the pets directory, and we want the files called “dogs.txt” and “cats.txt” to


View Full Document

UI STAT 5400 - Lab session 1 - Using Linux

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