1 / 40

Session 2 Processes and Threads Hands-on Unix Commands

Session 2 Processes and Threads Hands-on Unix Commands. Session 2. Getting Started With UNIX. Getting Started. By the end of this unit, you will be able to: Login and logoff Enter commands Get help with commands. Logging In. login: rmcknight Password: Welcome to UNIX! $ date

melita
Download Presentation

Session 2 Processes and Threads Hands-on Unix Commands

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. Nassau Community CollegeITE153 – Operating Systems Session 2Processes and Threads Hands-on Unix Commands

  2. Nassau Community CollegeITE153 – Operating Systems Session 2 Getting Started With UNIX

  3. Nassau Community CollegeITE153 – Operating Systems Getting Started By the end of this unit, you will be able to: Login and logoff Enter commands Get help with commands

  4. Nassau Community CollegeITE153 – Operating Systems Logging In login: rmcknight Password: Welcome to UNIX! $ date Mon Dec 30 14:33:42 2002 $ <ctrl-d> login:

  5. Nassau Community CollegeITE153 – Operating Systems UNIX Command A command is the name of a UNIX utility program Commands are typed after the shellprompt followed by <enter> The shell command interpreter finds and executes the command file

  6. Nassau Community CollegeITE153 – Operating Systems Comand Line Format command [- options] [arguments] <enter> separated by white space options vary the results of the command arguments can be a filename or a text string Not all commands have options and/or arguments Examples: $ ls $ ls -l $ ls -l myfile

  7. Nassau Community CollegeITE153 – Operating Systems Help With Commands Command reference system manual reference book On-line manual $ man ls General Format: Command Name Brief Description Command Format Detailed Description Option Information Examples See Also

  8. Nassau Community CollegeITE153 – Operating Systems The man Command To search for a command: $ man ls To search for a keyword, use the -k option $ man -k list

  9. Nassau Community CollegeITE153 – Operating Systems Simple Command Examples who banner df cal passwd

  10. Nassau Community CollegeITE153 – Operating Systems Hands-on

  11. Nassau Community CollegeITE153 – Operating Systems Session 2 Unix File System

  12. Nassau Community CollegeITE153 – Operating Systems The Unix File System By the end of this unit, you will be able to: Discuss various types of files List standard UNIX directories Identify and use pathnames Explain the significance of your home directory Change directory Display your current directory List directory contents

  13. Nassau Community CollegeITE153 – Operating Systems Directories and Files UNIX systems support different types of files: ordinary directory special block special character special fifo special sockets symbolic links

  14. Nassau Community CollegeITE153 – Operating Systems File System Structure

  15. Nassau Community CollegeITE153 – Operating Systems Standard Directories

  16. Nassau Community CollegeITE153 – Operating Systems Your Home Directory Where UNIX puts you when you log in. You are the owner of this directory. Also called your ‘login directory’

  17. Nassau Community CollegeITE153 – Operating Systems Getting Around the System In order to move around the filesystem, you need to know about three basic concepts: 1) Pathnames 2) The change directory command 3) UNIX is case sensitive ‘fileA’ is different from ‘filea’ ‘STUFF’ is different from ‘stuff’

  18. Nassau Community CollegeITE153 – Operating Systems Pathnames There are two types of pathnames: Full or Absolute Pathname -The complete path from the root directory /home/richard/myfiles/travel Relative Pathname -Dependent on your current location in the file system. This is called your ‘current directory’. myfiles/travel

  19. Nassau Community CollegeITE153 – Operating Systems <Hands-on>

  20. Nassau Community CollegeITE153 – Operating Systems Pathname Practice

  21. Nassau Community CollegeITE153 – Operating Systems Change Directory To change your current directory you need to use: The cdcommand A pathname to the new directory Examples: $ cd /home/richard/myfiles/travel $ cd myfiles/travel cd without any options...returns you to your home directory

  22. Nassau Community CollegeITE153 – Operating Systems Special Director Names Every directory has a parent directory (except for /)- The notation is two dots (..) The notation for the current directory is one dot (.)

  23. Nassau Community CollegeITE153 – Operating Systems Other Directory Commands pwd Print workingdirectory ls List directory contents ls has many options

  24. Nassau Community CollegeITE153 – Operating Systems The pwd Command Displays the absolute pathname to your current directory Examples: $ pwd /home/richard/myfiles/travel $ cd .. $ pwd /home/richard/myfiles

  25. Nassau Community CollegeITE153 – Operating Systems The ls Command ls with no options or arguments, lists the contents of the current directory $ ls myfiles fileA fileB ls uses pathnames as arguments $ ls myfiles/travel 2001 2002 fileC fileD

  26. Nassau Community CollegeITE153 – Operating Systems Options to ls The ls command has many options. A few are listed here: -F places a / after the directory name -R recursive list -a shows hidden files

  27. Nassau Community CollegeITE153 – Operating Systems ls Examples Using the -F option: $ ls - F personal/ fileC Using the -R option: $ ls -R personal fileC personal: stocks stocks:

  28. Nassau Community CollegeITE153 – Operating Systems ls and Hidden Files There are two types of hidden files: Files used by the system Files created by the user ls with the -a option will display hidden files along with other files in the specified or current directory. $ ls -a .exrc .profile .resume expenses

  29. Nassau Community CollegeITE153 – Operating Systems </Hands-on>

  30. Nassau Community CollegeITE153 – Operating Systems Session 2 Unix Processes

  31. Nassau Community CollegeITE153 – Operating Systems UNIC Processes By the end of this unit, you will be able to: Describe and define a UNIX process Use the ps command to get information about running processes Run a process in the background Stop a process Move processes into the foreground or background Use the nohup command to continue to run a process after logging out

  32. Nassau Community CollegeITE153 – Operating Systems Process Overview A process is an executing command. A process: Is assigned a unique ID number Has a parent process Can create child processes UNIX creates a root process during start-up Process ID number 1

  33. Nassau Community CollegeITE153 – Operating Systems Process Commands & Symbols ps & kill jobs (bg, fg) nohup

  34. Nassau Community CollegeITE153 – Operating Systems The ps Command Display process status Provides information about: User and process IDs Start time Run time Command name Options include: - e every - f full - l long - u users

  35. Nassau Community CollegeITE153 – Operating Systems Background Process The & (ampersand) symbol at the end of the command line, will run a process in the background. $ find / -type f -exec chmod 640 {} \; & [1] 510 Benefits You can execute another new command Useful for running long processes

  36. Nassau Community CollegeITE153 – Operating Systems The kill Command killterminates a process running in the background $ ps -f UID PID PPID C STIME TTY TIME COMMAND rMcK 356 1 1 10:56 pty03 0:06 ksh rMcK 922 356 7 11:20 pty03 0:02 find rMcK 988 356 8 11:22 pty03 0:00 ps -f $ kill 922

  37. Nassau Community CollegeITE153 – Operating Systems The nohup Command Logging out terminates all child processes Precede the command line with nohup to keep a background process running $ nohup find / -type f -exec chmod 640 {} \; & nohup is not requiredwith csh

  38. Nassau Community CollegeITE153 – Operating Systems Hands-on

  39. Nassau Community CollegeITE153 – Operating Systems Important URLs • http://www.math.utah.edu/lab/unix/unix-commands.htmlDo this at your leisure • http://en.wikipedia.org/wiki/List_of_Unix_utilitiesList of UNIX utilities • Unix Administration booksSome useful tools • http://www.matcmp.ncc.edu/~costavj/This is where our slides are! 39

  40. Nassau Community CollegeITE153 – Operating Systems Homework Review the slides Practices the commands Compare them to Wndows

More Related