1 / 54

UNIX

UNIX. What is UNIX? Getting Connected Basic UNIX Commands Help! Working with Directories Running Programs Editors The Shell Exercise. What is UNIX?. Multi-Tasking O/S Multi-User O/S Available on a range of Computers. Which UNIX?. SunOS Sun Microsystems IRIX Silicon Graphics

oria
Télécharger la présentation

UNIX

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. UNIX • What is UNIX? • Getting Connected • Basic UNIX Commands • Help! • Working with Directories • Running Programs • Editors • The Shell • Exercise

  2. What is UNIX? • Multi-Tasking O/S • Multi-User O/S • Available on a range of Computers

  3. Which UNIX? • SunOS Sun Microsystems • IRIX Silicon Graphics • HP-UX Hewlett Packard • Linux For IBM PC compatibles

  4. UNIX Internals (Simplified) • Kernel • System Internals • Shell • Command Interpreter • Programming language • File System • Process Management

  5. UNIX Shells • C-Shell • Bourne Shell • Korn Shell • T-Shell • bash

  6. Terminal Emulation Software • DOS Based Telnet • Windows 9x/NT/XP, Telnet and X Windows • Networked Macintosh, Telnet

  7. Graphical UNIX via Exceed • X Concepts • Using the Exceed Software • Starting the Common Desktop Environment

  8. Basic X Concepts • X Server runs on local machine • PC Exceed • UNIX Workstation Included in OS • Apple Mac Exodus • X Client runs on remote machine • Graphical Application • xterm • file manager • Modelling Package

  9. Basic X Concepts

  10. The Common Desktop Environment

  11. Starting CDE- XSession Options

  12. Setting the XServer Options

  13. Using Exceed :XTerm

  14. Using Exceed to Start an XClient

  15. Rules of Engagement • UNIX is case sensitive • Commands are in lower case • Backspace and Del Keys correct typing errors • Ctrl U clears the command line • Ctrl C Aborts a program or command • Do Not use the arrow keys

  16. Filenames • Filenames can comprise: a-z, A-Z alphabetic characters 0-9 digits .-_+ special characters mon+tue_01.06-03-96 • Wildcards * means any character or sequence of characters

  17. Format of UNIX commands • command [option ...] [filename ...] eg: ls ls -l tutorial more tutorial

  18. List Directory • ls list directory • ls -l list directory in long format • ls -a list all (inc. hidden) files -rw------ l course01 57 Oct 18 11:05 hello.c Access Permissions Number ofbytes in file Date and time last modified

  19. Displaying a Text File • morefilename Spacebar next screenful Enter next line q quit ? list commands

  20. Copy, Rename and Remove • Copy a file cp oldfile newfile • Rename a file mv oldname newname • Remove a file rm afile

  21. Searching Files • grep string file string = word or phrase file = file or list of files

  22. Redirection • The output of a command usually goes to the screen • Redirect the output to a file using ‘>‘ ls -l > dirlist

  23. Piping • Feeding the output of one command into the input of another command • The symbol ‘|’ is called a pipe command | command • eg: ls -al | more ls -la | grep Nov

  24. Manual Pages • man command • man - k topic • man - k topic | more

  25. Example Manual Pages • Synopsis mv [ - ] [- fi] filename1 filename2 optional options cp [ - ip] filename1 filename2 cp [ - iprR ] filename ... directory rm [ - ] [ - fir ] filename ... rmdir directory

  26. Directory Structure / (root) home1 usr me cs ph cs4un1 cs4un2 /home1/cs/cs4un1

  27. Directories • pwd print working directory • cd change directory cd move to home directory cd .. move up one level cd mydir move into a subdirectory cd /var/adm move to an absolute directory

  28. Managing Filestore • Each user has an allocation of filestore (Disk Space) • Monitor filestore usage with the ‘quota’ command EG: quota -v Disk quotas for username (uid 20002) Filesystem usage quota limit timeleft files quota limit timeleft /stoat-g 20 2000 4000 13 1000 1500 • The quota value can be exceeded for 7 days quota < usage < limit for 7 days • The limit value can not be exceeded usage < limit always • If usage > quota for 7 days account is expired and files can not be created

  29. Running programs • Two modes of operation foreground and background • Foreground Interact with program via keyboard/screen • Background No connection with keyboard/screen Submit to backbround by Appending ‘&’ EG: myprog >& myfile & The symbols ‘>&’ redirect output and any errors to the file myfile Another method of submitting programs to the background is via a batch processing system, such as Sun Grid Engine (as used on Titania)

  30. Foreground Program Control • Kill a program Ctrl C • Stop a program Ctrl Z Note a stopped program still exists in the system

  31. Program control within current shell • jobs Lists jobs (programs) • bg %job_id Place a job in the background • fg %job_id Return a job to the foreground • stop %job_id Stop a job • kill %job_id Kill a job jobs [1] + Running time.sh > out stop %1 [1] + Stopped (signal) time.sh > out bg %1 [1] + time.sh > out & kill %1 Terminated

  32. Program control using ‘ps’ and ‘kill’ • ps Report process status ps -f -u username UID PID PPID C STIME TTY TIME CMD username 24816 24585 0 16:23:04 pts/50 0:00 sleep 2 username 20169 19956 0 16:05:45 pts/50 0:01 -csh username 24585 20169 0 16:35:07 pts/50 0:00 /bin/sh time.sh • kill Terminate process • Find its process ID (PID) using the ps command • Kill the process using the kill command kill 24585 • Sometimes kill on its own does not work so try kill -KILL 24585

  33. Programe Control using top • top is a separate utility and not part of the OS top -Uusername • k kill program (process) k PID, k -KILL PID • h help • q quit top

  34. Vi Text Editor • Very powerful • Available on all versions of UNIX • No in-built help • Man page gives detailed help • Vi has three modes • Command • Text entry • Last line

  35. Editors • Dtpad • nedit • vi • emacs

  36. Desktop Note Pad Editor

  37. T-Shell - Filename Completion • Complete a partially typed filename • Operation • Type enough characters to uniquely identify the name • Press the ‘Tab’ key (for C – shell use ‘Esc’ key) • If the response is a ‘bleep’ press Ctrl-d to list possible matches • Setup • Add the following to your .cshrc file • set filec

  38. T-Shell -Repeating Previous Commands • Operation • history List previous commands • !! re-run last command • !n re-run the nth command • !str last command starting with str eg: !vi • Setup • Add the following to your .cshrc file • set history=40

  39. T-Shell - Command Aliasing • Definitions • alias ll ' ls -lF ' • alias h ' history 24 ' • alias dir ' ls ' • Setup • Add alias definitions to your .cshrc file

  40. The Secure shell protocol • SSH is a new method of communications over the Internet that encrypts data end-to-end • Replaces telnet, ftp, rsh and rcp • Components • Secure shell ssh • Secure ftp sftp • Secure copy scp

  41. Secure Shell • Program to log into another computer over a network • Execute commands on a remote machine • Move files from one machine to another • Provides strong authentication and secure communications over insecure channels. • Intended as a replacement for rlogin, rsh, rcp, and rdist.

  42. ssh • You only need the SSH client. The server is unnecessary, unless you wish to connect back to your home machine via the Internet using SSH. • Connecting to a WRG nodessh -l wrsmg maxima.leeds.ac.uk • To use X-windows add the "-X" flag • SSH will then carry Xwindows traffic over the Internet to connect • Range of options for changing ports, specifying authentication files, encryption algorithms etc…. • Use man ssh for help with options

  43. Secure ftp (sftp) • Establishes an FTP-style file transfer session between the Unix systems • sftp command always used in the form: sftpuser@server • e.g.from titania sftp wrsmg@maxima.leeds.ac.uk

  44. Transferring Files Using sftp From the SFTP prompt (sftp>) can do the following: • get command to retrieve a file from the remote Unix server. • get test.txt • put command to transfer a file from your Unix system to the remote Unix system you are connected to. • put file2.txt

  45. Navigating file systems using sftp From the SFTP prompt (sftp>) can do the following: • ls command to display the contents of a directory on the remote Unix system you are connected to. • ls /home/user. Will display the contents of the directory /home/user on the remote Unix system. • cd and lcd commands change current remote directory, or current local directory. • e.g. cd /home/user. Will change the current remote directory to /home/user.

  46. Summary of sftp commands 1 • mget Retrieve multiple files from server • Mput Transfer multiple files to server • pwd Display remote working directory • quit or exit Quit sftp • rename oldpath newpath Rename remote file • rmdir path Remove remote directory • rm path Delete remote file • version Show SFTP version • ? Synonym for help

  47. Summary Listing of SFTP commands 2 ascii Use text transfer mode help Display the help text image Use binary transfer mode lls [ls-options [path]] Display local directory listing lmkdir path Create local directory ls [path] Display remote directory listing mkdir path Create remote directory put local-path [remote-path] Upload file

  48. Secure copy - scp • Using SCPFast, easy method to copy single files from your Unix system to a remote Unix system.

  49. Retrieving a file using SCP • To retrieve a file from a remote Unix system, the syntax is: scp username@server:file local-file • username= username on the remote system • server= the name of the remote Unix system • file= the file to retrieve from the remote system • local-file= the location you wish to save the file to on your local Unix system

More Related