Date post: | 31-Dec-2015 |
Category: |
Documents |
Upload: | catherine-brown |
View: | 217 times |
Download: | 1 times |
1
Chapter 2 UNIX for Users
2
Contents
Basic things in Unix
- login, logout, password, online manual
- X-window
- file system
- commands for files and directories
- file attributes
- editor
3
Login and Logout
Login account you already have one account in cs.sookmyung.ac.kr
Login telnet X-window
Logout Ctrl-D logout
4
Login
Systems you can use cs.sookmyung.ac.kr cslinux1.sookmyung.ac.kr cslinux2.sookmyung.ac.kr
Telnet telnet cs.sookmyung.ac.kr
Modem Hyperterminal, 새롬데이터맨 : 710-9251 전화접속 네트워킹 : 3789-5656
telnet, ftp, netscape, …
5
X-window
X-window developed at MIT
window system based on client/server model
standard window system for UNIX and Linux
X-window 의 종류 X11 by MIT
OpenWin on Sun Solaris, HP/UX, IBM AIX, ...
XFree86 on Linux
6
Login to X-window
On Unix or Linux Console login and startx on Linux openwin on Solaris
On Window PC Xmanager on PC http://www.netsarang.co.kr
7
X-window 의 윈도우 매니저
윈도우 매니저의 역할
스크린에 나타나는 윈도우를 조정하고 관리한다 .
윈도우 확대 , 축소 , 이동 , 아이콘으로 변환 등
윈도우 매니저 종류 CDE on Sun Solaris, IBM AIX, HP/UX, ...
KDE on Linux http://www.kde.org
GNOME on Linux http://www.gnome.org
Twm, Mwm, Fvwm, Window Maker … on Linux
http://www.windowmaker.org
8
윈도우 매니저 GNOME
Panel panel applet 과 menu 들을 포함한다 .
Panel applets 은 판넬 내의 작은 프로그램
예 : the clock applet
Main Menu Button Window 98 의 시작 버튼과 같은 역할
Desktop 프로그램
데이터
디렉토리
9
윈도우 매니저 GNOME
파일 관리자 (File Manager)
이동 , 실행
복사 , 이름 변경 , 삭제 등
- 마우스 오른쪽 버튼을 이용
참조 http://www.gnome.org/users-guide/index.html
10
X-window 의 동작 과정
X server
X client
X client
X client
TerminalScreen
Mouse Keyboard
Display
11
X-window 의 동작 과정
Display
consists of a terminal screen, a keyboard, and a mouse
X server
handles all the input and output of data at the display
one X server to each display
보통 X-window 는 X server 를 의미함 .
12
X-window 의 동작 과정
.X client
디스플레이의 사용자와 대화하는 X 응용 프로그램
X client 의 예
- xterm, xclock, netscape, ….
출력을 X server 에 요청
X server 로부터 입력을 받음
- 마우스 클릭 , 윈도우 이동 , 키보드 누름 , …
13
X-window 의 특징
Client/Server 기반 윈도우 시스템
X server 와 X client
네트워크 기반 윈도우 시스템
X server 와 X client 가 같은 호스트 혹은
다른 호스트에 위치할 수 있다 .
14
Running Commands
Shell a command line interpreter on UNIX Bourne shell, Korn shell, C shell
date [yymmddhhmm [.ss] display or set current date and time
Online manual man [chapter] word man -k keyword
$man -k mode
$man chmod
$man 2 chmod
15
Special Characters
Special characters
$ stty all
erase kill werase rprnt flush lnext susp
intr quit stop eof
Terminating a process
- Control-C
- standard way to interrupt the foreground job
Pausing output
- Control-S/Control-Q
16
Special Characters
End-of-input- Control-D
passwd- to set or change your password
- at least six letters, should not a word from a dictionary
17
File System
Directory hierarchy- tree structure
- root directory
bin usr dev home
chang
18
File System
Home directory– shell starts in your home directory when you login– assigned by the system administrator
Current working directory- a directory where your shell is currently working
- home directory, when you login
- How to change cwd ?
Moving to a directory- cd [directoryName]
19
Pathname
Absolute path name– specify a file or directory by a pathname from the root directory /– /home/chang
Relative path name
- specify a file or directory by a pathname relative to the cwd
. : current directory
.. : parent directory
20
Commands for files
Listing the contents of a directory
ls -adglsFR {fileName}* {directoryName}*
-a : hidden files starting with .
-l : long listing including permission, owner,
modification time
-d : directory not files
-g : file's group
-s : size
-F : file type ( *, /)
-R : recursively
21
Commands for files
Listing a file
cat -n {fileName}*
more -f [+lineNumber] {fileName}*
page -f [+lineNumber] {fileName}*
head -n {fileName}*
tail -n {fileName}*
22
Commands for files
Renaming a file- mv -i oldFileName newFileName
- mv -i {fileName}* directoryName
- mv -i oldDirectoryName newDirectoryName
Making a directory- mkdir [-p] newDirectoryName
- creates a new directory
23
Commands for files
Copying a file
cp -ir {fileName}* directoryName
cp -i oldFileName newFileName
Deleting a file or directory
rmdir {directoryName}+
rm -fir {fileName}
24
Commands for files
Printing a file
lpr -m [-Pprinter] [-#copies] {fileName}*
Counting the words in a file
wc -lwc {fileName}*
25
File attributes
file name– the number of physical blocks
file modification time- the the time that the file was last modified
file owner/group- the owner of the file
– every process has an owner, which is the login user id
– whenever a process creates a file, the file's owner is set to the process's owner
26
File attributes
file type
character file type- regular filed directory fileb buffered special file like a disk
drivec unbuffered special file like a
terminall symbolic linkp pipes socket
27
File attributes
permission mode
user group others
rwx rwx rwx
28
Changing files
Changing a file's permissions
chmod -R permission {fileName}+
owner group othersrwx rwx rwx111 111 1117 7 7
$chmod 750 .
$chmod 644 filename
29
Changing files
Changing a file's owner
chown -R UserId {fileName}+
change the ownership of files
$chown chang filename
Changing groups
chgrp -R GrpId {fileName}+
change the group of files
30
Determining terminal's type
Terminal type
- vi or emacs need to know your terminal type !
- Set shell envirionment variable $TERM to your terminal type
(csh) %setenv TERM ansi
%tset
(sh) $set TERM=ansi
$tset
– Setting terminal type in shell's startup file
.cshrc (csh) .profile (sh)
31
Changing terminal's characteristics
• Changing metacharacter setting
– The default metacharacter settings may be overriden
– stty -a {option}* {metacharacterString <value>}*
erase, kill, lnext susp, intr, stop, eof
$ stty erase ^b
32
Editor vi
A standard editor in UNIX%vi filename
Two modes– command mode
initial mode, editing commands
– text entry mode
enter text you'd like to enter
33
Editor vi
How to enter text entry mode
– By typing i, a, o, O, or R in command mode
• i Text is inserted in front of the cursor
• a Text is added after the cursor
• o/O Text is added after/before the current
line
• R Text is replaced (overwritten)
– You can not move around the screen using the cursor keys
in text entry mode
– Back to command mode by typing Esc
34
Command mode
C u r s o r M o v e m e n t
- r i g h t , l e f t , u p , d o w n : )( ,)( ,)( ),( kjhl
- s t a r t o r e n d o f l i n e : ^ , $
- b a c k o r f o r w a r d o n e w o r d : b , w
- d o w n o r u p o n e s c r e e n
C o n t r o l - F , C o n t r o l - B
- d o w n o r u p h a l f s c r e e n
C o n t r o l - D , C o n t r o l - U
- T o l i n e n n
: n n < E n t e r >
35
Command mode
Deleting Text
Item to delete Key sequence
character x, nx
word dw, ndw
line dd, or ndd
to end of current line D
block of lines :<range>d<Enter>
36
Command mode
Replacing Text
Item toreplace
Key sequence
character r, and type a character
word cw, and type the replacement text followed by Esc
line cc, and type the replacement text followed by Esc
37
Command mode
Pasting Text
Action Key sequence
Copy(yank) n lines intopaste buffer
n Shift y
:<range>y<Enter>
Insert(put) paste buffterafter current line
Shift p
:pu<Enter>
Insert paste buffer afterline nn.
:nnpu<Enter>
38
Command mode
Searching
Action Key sequence
Search forward /string < Enter>
Search backward ?string < Enter>
Repeat last search n
39
Command mode
Search/Replace
Action Key sequence
Replace the first string1on each line with string2
:<range> s/string1/string2/<Enter>
Replace every string1with string2
:<range> s/string1/string2/g<Enter>
40
Command mode
Saving/Loading Files
Action Key sequence
Save file as <name> :w <name><Enter>
Save file with current name :w<Enter>
Edit file <name> instead ofcurrent file
:e <name><Enter>
Edt next file on initialcommand line
:n<Enter>
41
Command mode
Miscellaneous
Action Key sequence
Redraw screen Control-L
Execute command andreturn to vi
:!<command><Enter>
Quit if work is saved :q<Enter>
Quit vi and discardunsaved work
:q!<Enter>
42
Electronic Mail
Elm– a popular mail system in UNIX
– sending mail
% elm [email protected]
(1) automatically vi is invoked and edit a mail
(2) quit by typing :wq and send by typing <Enter>
– reading mail
% elm
graphical user interface : move cursor and type return
43
Electronic Mail
mail – mail -H [-f fileName] {address}*
– sending mail
% mail [email protected]
% mail [email protected] < filename
– reading mail
44
Electronic Mail
Netscape mailer
– 윈도우에서 사용하는 netscape mailer 와 동일하게 사용 가능