introduction to unix l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Introduction to UNIX PowerPoint Presentation
Download Presentation
Introduction to UNIX

Loading in 2 Seconds...

play fullscreen
1 / 20

Introduction to UNIX - PowerPoint PPT Presentation


  • 292 Views
  • Uploaded on

Introduction to UNIX. Ke Liu http://www.cs.binghamton.edu/~kliu/cs350/ Kliu1@binghamton.edu. Topics. Logging in. Unix Shells and useful shell commands. File System in Unix. Program, Process and Process control. Inter-process communication. Compiling and debugging C programs. Editors.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Introduction to UNIX' - Olivia


Download Now 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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
introduction to unix

Introduction to UNIX

Ke Liu

http://www.cs.binghamton.edu/~kliu/cs350/

Kliu1@binghamton.edu

topics
Topics.
  • Logging in.
  • Unix Shells and useful shell commands.
  • File System in Unix.
  • Program, Process and Process control.
  • Inter-process communication.
  • Compiling and debugging C programs.
  • Editors.
slide3
UNIX
  • UNIX is multi-user and multi-tasking operating system.
  • Multi-tasking: Multiple processes can run concurrently.
  • Example, different users can read mails, copy files, and print all at once.
logging in
Logging In
  • Enter login name and password !
  • System password file: /etc/passwd (usually).
  • You can change password using the command: passwd.
shell
Shell
  • After a successful login, the shell program is run. The default shell of bingsuns: tcsh
  • bingsun2% ps

PID TTY TIME CMD

2159 pts/2 0:00 tcsh

  • Shell is a command line interpreter that reads user commands and executes them.
unix shells
Unix Shells
  • Common Shells: Bourne shell, the C shell, and the Korn shell.
  • The shell on bingsuns is tcsh (tc shell).
  • Users can switch between shells, using the commands bash, csh, ksh, sh.
  • Control D (^d) to return back to original shell, or just use the command: exit.
some shell commands
Some shell commands
  • Most Important command: man (manual pages).
  • Help: unix commands, C functions.
  • Usage: man <command/function>
  • Try “man man” !
  • Example:

man ls, man passwd, man printf.

some shell commands cont
Some shell commands (cont’)
  • pwd: working directory (/u0/users/2/kliu1).
  • ls: list contents of directory
  • mkdir <dir-name>: make directory
  • rmdir <dir-name>: remove an empty directory
  • rm –r <dir-name>: remove a directory with all the contents
  • cd <directory>: change directory, ~/ means your home directory
  • cp <source> <target>: copy command.
some shell commands cont9
Some shell commands (cont’)
  • chmod <mode> <filename>: change mode of a file/directory
  • ls –l <directory or filename>: long list with details
  • 9 permission bits: d r w x r w x r w x
  • 3 categories: user/group/all.
  • Permissions: read/write/execute (r/w/x).
  • E.g.: mode= 644 means r w _ r_ _ r _ _

command: chmod 644 <filename>

  • first 3 bits for user. Next group. Next all others.
some shell commands cont10
Some shell commands (cont’)
  • rm <option> <filename>: remove files

e.g.: rm –fr directory/filename

  • mv <old> <new>: change the name of a file
  • Pipes: Connect the stdout of one command with the stdin of another command

e.g.: ls -l | more or ls –l | less

file system
File System
  • Hierarchical arrangement of files and directories.
  • Top level: root or /

e.g.: cd /

  • . Current directory, .. One level higher directory

e.g.: cd . No change for it is current directory

or cd .. Change to parent directory.

file system cont
File System (cont’)
  • Pathname: absolute and relative.
  • Absolute pathname: /u0/users/2/kliu1
  • Relative pathname: abc.
editors
Editors.
  • Different editors: emacs, pico, vi
  • emacs <filename>
  • pico <filename>
  • vi <filename>
the easiest editor pico or nano
The easiest editor: pico or nano
  • pico <filename>
  • Full screen editor
  • Help on the bottom of the screen
  • The nano is an extension to the pico
basic operations in pico
Basic operations in pico
  • Ctrl + v : to move page down
  • Ctrl + y : to move page up
  • Ctrl + o : to save the current buffer
  • Ctrl + x : to exit with or without saving
  • Ctrl + g : to get help
  • Ctrl + r : to open a file
  • Ctrl + w : to find a string in the current buffer
  • Ctrl + c : to get the current position in the buffer
program process
Program & Process
  • Program is an executable file that resides on the disk.
  • Process is an executing instance of a program.
  • A Unix process is identified by a unique non-negative integer called the process ID.
  • Check process status using the “ps” command.
foreground background processes
Foreground/background processes
  • A program run using the ampersand operator “&” creates a background process.
  • E.g.:

bingsun2% back &

  • otherwise it creates a foreground process.
  • E.g.:

bingsun2% back

foreground background processes18
Foreground/background processes
  • Only 1 foreground process for each session. Multiple background processes.
  • Where are background processes used?
  • All system daemons, long user processes, etc.

e.g. printer-daemon process or mailer-daemon process.

  • These processes are always running in background.
  • Pine is foreground process.
process status
Process Status

bingsun2% back &

[1] 16488 the process id assigned by system

bingsun2% ps

PID TTY TIME CMD

1973 pts/39 0:01 tcsh

16488 pts/39 0:00 back

how to stop a process
How to stop a process?
  • Foreground processes can generally be stopped by pressing CONTROL C (^C).
  • Background processes can be stopped using the kill command.
  • Usage: kill SIGNAL <process id list>
  • kill -9 <process id list> (-9 means no blocked)

Or kill <process id list>.

  • If a foreground process is not stopping by ^C, you can open another session and use the kill command.