400 likes | 511 Views
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
E N D
Nassau Community CollegeITE153 – Operating Systems Session 2Processes and Threads Hands-on Unix Commands
Nassau Community CollegeITE153 – Operating Systems Session 2 Getting Started With UNIX
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
Nassau Community CollegeITE153 – Operating Systems Logging In login: rmcknight Password: Welcome to UNIX! $ date Mon Dec 30 14:33:42 2002 $ <ctrl-d> login:
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
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
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
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
Nassau Community CollegeITE153 – Operating Systems Simple Command Examples who banner df cal passwd
Nassau Community CollegeITE153 – Operating Systems Session 2 Unix File System
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
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
Nassau Community CollegeITE153 – Operating Systems File System Structure
Nassau Community CollegeITE153 – Operating Systems Standard Directories
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’
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’
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
Nassau Community CollegeITE153 – Operating Systems <Hands-on>
Nassau Community CollegeITE153 – Operating Systems Pathname Practice
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
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 (.)
Nassau Community CollegeITE153 – Operating Systems Other Directory Commands pwd Print workingdirectory ls List directory contents ls has many options
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
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
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
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:
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
Nassau Community CollegeITE153 – Operating Systems </Hands-on>
Nassau Community CollegeITE153 – Operating Systems Session 2 Unix Processes
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
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
Nassau Community CollegeITE153 – Operating Systems Process Commands & Symbols ps & kill jobs (bg, fg) nohup
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
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
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
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
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
Nassau Community CollegeITE153 – Operating Systems Homework Review the slides Practices the commands Compare them to Wndows