Unix Tutorial

Reviews
Shared by: techmaster
Stats
views:
164
rating:
not rated
reviews:
0
posted:
10/29/2008
language:
English
pages:
0
Unix Tutorial Presented by UBC IEEE Student Branch Topics to be Covered: • • • • • Unix Shell Basics Unix file system Email forwarding Suspending and Killing processes Printing Shell Basics • Shells are command line interpreters. This is where a user can type in commands to create/del. files.. etc • Depending on the type of shell you use, the prompt may look different. – tcsh: prevost:~> – bash: bash-2.05b$ – csh: prevost<31> • To check which shell you are running type: • To change the type name of the shell and hit enter. • Command Format – Eg. If I wanted to use tcsh, just type in tcsh and then enter at the command line – Command [options] [arguments] – Eg. ls –la *.cpp – Echo $SHELL Unix File Structure • Tree Hierachy Diagram From CS219 Directory Navigation • Directory Paths – unlike MS-DOS, UNIX file systems use forward slashes – Eg. /usr/bob/hmwk/ (UNIX) \mydocuments\hmwk\ (MS) • Change Directory: cd directory_path • Useful Commands – Go up to parent directory: cd .. – Go to home directory: cd ~ – pwd: returns “present working directory” – ls: “list contents of directory” • ls –la “lists all files incl. hidden files + shows file permissions Directories Cont… • To create a new directory: • To remove an empty directory: – mkdir dir_name – rmdir dir_name • To remove a directory that has files and subfolders: • To delete files – rm file_name – rm –R dir_name File Permissions prevost:~/demo> ls -la total 16 drwx------ 3 m0r1 undergrad drwx--x--x 23 m0r1 undergrad -rwxr-xr-x 1 m0r1 undergrad -rw------- 1 m0r1 undergrad drwx------ 2 m0r1 undergrad • d|r|w|x|r|w|x|r|w|x • r: readable „d‟ de• w: writable • X: executable 512 Jan 11 14:39 ./ 3584 Jan 11 14:39 ../ 7 Jan 11 14:39 calc.c* 12 Jan 11 14:39 helloWorld.txt 512 Jan 11 14:39 test/ – First character „d‟, if shown, means that it is a directory – 3 groups of r|w|x. – r|w|x permission groupings • First r|w|x group is the permissions of the file for the user • Second group of r|w|x is for group members • Third group of r|w|x is for any other user File Permissions cont.. • to change file permissions: – Method: • Eg. chmod [target][ops][permissions] [file name] – targets:  u  g  o – ops:  +  – permissions:  r  w  x (user) (group) (other) (add permission) (remove permission) (read) (write) (execute) – Tips: • Eg. chmod g+rwx helloWorld.txt • To protect your home directory, and all subdirectories on your Unix acct. – chmod –R 755 ~ – this command changes the permissions for all folders, subfolders, and files in a user‟s home directory to allow read, write, and execute for the owner ONLY. Email Forwarding • To enable email forwarding: – type in: echo email_address > ~/.forward • To cancel email forwarding – type in: rm ~/.forward Processes and Job Control • To check what jobs (programs) that you are running – type in: jobs – Eg. prevost:~> jobs [1] + Suspended • • To suspend a running program • To kill a running program – press [Ctrl-z] on the keyboard – press [Ctrl-c] on the keyboard Here we can see that a program called “man” with the argument “more” was suspended man more • To recover a suspended program • To run a program in the background – type in: program_name & – type in: %[job number] – Eg. %1 (brings back the “man” program in the above example) (the ampersand will run the program in the background) Printing Documents • To print a file: – lpr –Pprinter_name filename – Eg. lpr –Plaserprn1 work.txt • To check printing queue: – lpq –Pprinter_name – This will output list of print jobs. • To remove printing queue: – lprm –Pprinter_name job# Useful Links • SSH setup for remote connection to ECE – http://www.ece.ubc.ca/twiki/bin/view/ITHelp/ HowToForEndUsers • UNIX Cheat Sheet – http://www.ece.ubc.ca/~ieee/resources/unix M.html

Related docs
Unix Tutorial
Views: 676  |  Downloads: 91
UNIX Tutorial
Views: 265  |  Downloads: 87
UNIX Tutorial
Views: 231  |  Downloads: 47
Unix Tutorial
Views: 266  |  Downloads: 87
Unix Tutorial
Views: 124  |  Downloads: 10
Linux/Unix Tutorial
Views: 18  |  Downloads: 4
UNIX
Views: 341  |  Downloads: 54
Basic Unix Commands
Views: 68  |  Downloads: 22
Unix Programming Tools
Views: 98  |  Downloads: 22
A Basic UNIX Tutorial
Views: 215  |  Downloads: 63
A Small UNIX Tutorial
Views: 27  |  Downloads: 11
A Small UNIX Tutorial
Views: 73  |  Downloads: 23
Introduction to UNIX
Views: 146  |  Downloads: 49
Introduction to UNIX
Views: 283  |  Downloads: 62
Other docs by techmaster
Form 7 Committee Note
Views: 111  |  Downloads: 0
Belize Economic Report for 2006
Views: 254  |  Downloads: 1
FORM 16B CAPTION SHORT TITLE
Views: 374  |  Downloads: 0
Sample Business Plan Vision Cast
Views: 384  |  Downloads: 23
National Labor Relations Act _1935_ - 1
Views: 113  |  Downloads: 0
OSHA EMPLOYEE WORKPLACE RIGHTS
Views: 420  |  Downloads: 13
FRENCH REVOLUTION HISTORY
Views: 355  |  Downloads: 3
Sample Business Plan Nycom Inc
Views: 264  |  Downloads: 7
Dominica Economic Report for 2006
Views: 147  |  Downloads: 2
Torts III University of Texas
Views: 292  |  Downloads: 2
UNITED STATES BANKRUPTCY COURT NOTICE OF APPEAL
Views: 175  |  Downloads: 0