Unformatted text preview:

What is Unix? • An operating system which runs on many different kinds of computers – Suns, HPs, DECs, PCs, Macs. Linux is a version of Unix. • Users access the operating system via what is called a shell. You are probably using tcsh or bash. They are many available sh, csh, ksh, etc, though not all may be available on our system. • Unix prompt, or shell prompt, is where you type your commands. • The way you prompt looks depends on which shell you are running and how you configure it. • Anything running on the machine (even the operating system itself) is called a process. • Unix has been called confusing and a pain to learn, but it's also flexible and powerful.Prompts Look depends on which shell you are running and how you have things configured. This configuration can involve including this like which machine you are on, which directory you are in, time, date, process number, etc. <64> stat /home/irwin% (system default) bash-2.05a$ (bash default) stat:~> (mine. set prompt="%m:%~> ") All commands are given to the shell are typed at the prompt. This command might be a script you’ve written. You can write your own programs using Unix commands.Basic Unix Commands ls lists files in a directory ls (lists file in current directory) ls –l unixcourse/*.s (lists all files in directory unixcourse ending in .s in the long format) fisher:~/statcomp> ls EAgrant/ formexamples/ regentsgrant unixcourse/ SurvCourse/ import.info sitelicence.mac webcontent WWW/ important sitelicence.pc webpages brian.phone laptop.shili sitelicence.sun website fisher:~/statcomp> ls -l unixcourse/*.s -rw-r--r-- 1 irwin parstaff 20 Sep 27 14:53 unixcourse/temp.s -rw-r--r-- 1 irwin parstaff 20 Sep 27 14:53 unixcourse/temp2.s Files and directories whose names start with a “.” aren’t shown unless explicitly asked for with the –a option. fisher:~/statcomp/unixcourse> ls -a ./ combined.s temp2.s tempdir2/ ../ combined.txt temp23.s tempdir3/ .sdotfile temp.s tempdir/ weizens.pdf fisher:~/statcomp/unixcourse> ls combined.s temp.s temp23.s tempdir2/ weizens.pdf combined.txt temp2.s tempdir/ tempdir3/ cd change directory cd unixcourse (goes to directory unixcourse located in the current directory) cd ~irwin/pub (goes to my public directory) cd .. (goes to parent directory)Special Characters in file names: ~ home directory ~user user’s home directory . current directory .. parent directory / directory break character * wildcard character – represents any character string ? matches any single character unix:~/statcomp/unixcourse> dir total 120 drwxr-xr-x 5 irwin parstaff 4096 Jun 26 2001 ./ drwxr-xr-x 7 irwin parstaff 4096 Feb 18 2003 ../ -rw-r--r-- 1 irwin parstaff 20 Sep 28 2000 .sdotfile -rw-r--r-- 1 irwin parstaff 204 Jun 26 2001 combined.s -rw-r--r-- 1 irwin parstaff 204 Sep 27 2000 combined.txt -rw------- 1 irwin parstaff 20 Sep 27 2000 temp.s -rw-r--r-- 1 irwin parstaff 184 Sep 27 2000 temp2.s -rw-r--r-- 1 irwin parstaff 20 Sep 27 2000 temp23.s drwxr-xr-x 2 irwin parstaff 4096 Jun 26 2001 tempdir/ drwxr-xr-x 2 irwin parstaff 4096 Jun 26 2001 tempdir2/ drwxr-xr-x 2 irwin parstaff 4096 Sep 27 2000 tempdir3/ unix:~/statcomp/unixcourse> dir *.s -rw-r--r-- 1 irwin parstaff 204 Jun 26 2001 combined.s -rw------- 1 irwin parstaff 20 Sep 27 2000 temp.s -rw-r--r-- 1 irwin parstaff 184 Sep 27 2000 temp2.s -rw-r--r-- 1 irwin parstaff 20 Sep 27 2000 temp23.s unix:~/statcomp/unixcourse> dir temp*.s -rw------- 1 irwin parstaff 20 Sep 27 2000 temp.s -rw-r--r-- 1 irwin parstaff 184 Sep 27 2000 temp2.s -rw-r--r-- 1 irwin parstaff 20 Sep 27 2000 temp23.s unix:~/statcomp/unixcourse> dir temp?.s -rw-r--r-- 1 irwin parstaff 184 Sep 27 2000 temp2.s -rw-r--r-- 1 irwin parstaff 184 Sep 27 2000 temp3.srm remove files rm –i temp3.s (removes file temp3.s. The –i flag asks whether you really want to do this and is the default setup on our system. For most people typing rm temp3.s has the same result.) rm –r tempdir (removes the directory tempdir and all file and directories contained in it) fisher:~/statcomp/unixcourse> rm -i temp3.s rm: remove temp3.s (yes/no)? y mv move (rename) files and directories mv temp2.s newname.txt (renames the file temp2.s to newname.txt) mv tempdir/* tempdir2 (moves all files in directory tempdir to directory tempdir2) fisher:~/statcomp/unixcourse> ls tempdir garbage fisher:~/statcomp/unixcourse> ls tempdir2 fisher:~/statcomp/unixcourse> mv tempdir/* tempdir2 fisher:~/statcomp/unixcourse> ls tempdir fisher:~/statcomp/unixcourse> ls tempdir2 garbagecp copy files and directories cp temp2.s newname.txt (copies the file temp2.s to newname.txt) cp tempdir/* tempdir2 (copies all files in directory tempdir to directory tempdir2) fisher:~/statcomp/unixcourse> ls tempdir garbage fisher:~/statcomp/unixcourse> ls tempdir2 fisher:~/statcomp/unixcourse> cp tempdir/* tempdir2 fisher:~/statcomp/unixcourse> ls tempdir garbage fisher:~/statcomp/unixcourse> ls tempdir2 garbage mkdir make a new directory off of the current directory mkdir newdir (makes directory newdir) rmdir removes a directory rmdir olddir (removes directory olddir)man print manual page man man (prints manual page for command man) man(1) man(1) NAME man - format and display the on-line manual pages manpath - determine user's search path for man pages SYNOPSIS man [-acdfFhkKtwW] [--path] [-m system] [-p string] [-C config_file] [-M pathlist] [-P pager] [-S section_list] [section] name ... DESCRIPTION man formats and displays the on-line manual pages. If you specify section, man only looks in that section of the manual. name is normally the name of the manual page, which is typically the name of a command, function, or file. However, if name contains a slash (/) then man interprets it as a file specification, so that you can do man ./foo.5 or even man /cd/foo/bar.1.gz. See below for a description of where man looks for the


View Full Document

HARVARD STAT 335 - Unix

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