Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

UNIX : Characteristics

- Software Tools
- Portability
- Flexibility
- Power
- Multiuser & Multitasking
- Elegance
- Network Orientation
UNIX : Structures
- Hardware
- UNIX Kernel
- Shell
- User Program
UNIX Basic Command

man
เปนคําสั่งคูมือ(manual) หรือขอความชวยเหลือ(help)
$ man
ออกจากคําสั่งนี้ พิมพ q
หมายเหตุ ปรกติคาํ สั่งใชอกั ษรตัวเล็ก
ls
เปนคําสั่งแสดงขอมูลไดเรกทอรี่ หรือ ไฟล โดยมี
พารามิเตอรความหมายดังนี้
• names : ชื่อของไดเลคทอรี่ หรือ ไฟล
• -a : แสดงรายชือ่ ไฟล หรือ ไดเลคทอรี่ รวมทั้ง
ที่ปกติไมแสดง
• -d : แสดงรูปแบบยาว ไมแสดงขอมูลที่เก็บ
• -l : แสดงรูปแบบยาว ของไดเลคทอรี่ และ
ไฟล
Ls (ตอ)
• -m : แสดงรายชือ่ ไฟลทางขวาง แยกจากกัน
ดวยเครื่องหมาย ,
• -r : แสดงรายชือ่ ไฟล เรียงตามลําดับตรงขาม
กับปกติ
• -t : แสดงรายชือ่ ไฟล เรียงตามลําดับเวลาที่
สรางลาสุดกอน
ตัวอยางการใชคําสั่ง
$ ls -a
$ ls -lr
เมื่อใชคําสั่ง ls -l จะปรากฏผลดังตัวอยางนี้
• drwxr-xr-x test1
1234567890
• -rwxr-xr-x test2
1234567890
ตําแหนงที่ 1 = d แสดงวาเปน Directory
- แสดงวาเปนไฟล (ordinary
file)
b,c,p แสดงวาเปนไฟลพิเศษ
(Special files)
ตําแหนงที่
234 แสดงโหมด (mode) การทํางานของผูใช
567 แสดงโหมด (mode) การทํางานของผูใช
คนอื่นที่อยูในกลุม(Group)เดียวกัน
890 แสดงโหมด (mode) การทํางานของผูใช
คนอื่นที่อยูในกลุม(Group)อื่น
เครื่องหมาย r = อาน(read) w = เขียน (write)
x = ปฏิบัติงาน (execute)
pwd
เปนคําสั่งแสดงไดเลคทรอรี่ที่กําลังใชงานอยู
ตัวอยาง
$ pwd
/home/user/letters
แสดงวาอยูภายใตไดเลคทรอรี่ letters ที่อยูใน
user และ home ตามลําดับ
Directory
• mkdir dirname : คําสั่งสรางไดเลคทรอรี่ ตามดวย
ชื่อไดเลคทรอรี่ทตี่ องการสราง
• rmdir dirname : คําสั่งลบไดเลคทรอรี่ ตามดวยชื่อ
ไดเลคทรอรี่ทตี่ องการลบ
• cd dirname : เปลี่ยนไปอยูในไดเลคทรอรี่ที่
ตองการ
ตัวอยางเชน
$ mkdir letter
$ ls
letter mail
$ cd letter
$ ls
$ cd ..
$ cd letter
$ cd
$ cd /
ตัวอยาง(ตอ)
$ ls
letter mail
$ rmdir letter
$ ls
mail
cp
คําสั่งคัดลอกไฟล
ในการคัดลอก จะตองระบุชื่อไฟลที่ตองการ จุดหมาย
ปลายทาง ซึ่งอาจเปนไดเลคทรอรี่ ไดเลคทรอรี่และ
ไฟล หรือ ไฟลในไดเลคทรอรี่ปจ จุบัน
ตัวอยางเชน
$ cp doc doc.bak
pico
คําสั่งสรางไฟลเอกสารใน UNIX จะมีลักษณะคลาย
edit ใน ดอส
$ pico
rm
คําสั่งลบไฟล มีพารามิเตอรดังนี้
f : ลบทุกไฟลโดยไมถามผูใช
i : ลบทุกไฟลโดยกอนจะลบจะถามผูใชทุก
ครั้ง
r : ลบไฟลรวมทั้งไดเลคทรอรี่
move
คําสั่งยายไฟล หรือ เปลี่ยนชื่อไฟล
f : ยายโดยไมมีเงื่อนไข
i : ติดตอกับผูใชเพื่อปองกันการเขียนทับ
ตัวอยางเชน
$ mv file1 target : ยายไฟล file1 ไปยังไดเลคทรอรี่
target
date
Displays current date and time or sets the date.
• mmddHHMM : Sets date to month(mm), day(DD),
hour(HH), and minute (MM)
• +format : Displays the date according to
supplied format
• เชน
$ date 01021215
calendar
cal : Prints a calendar of the current month
• month : pints a calendar for the specified month
• year : prints a calendar for the specified year
• เชน
$ cal
$ cal 2006
$ cal 6 2006
ping
Ping host : Send a request to respond to
system host on the network
• timeout : Give the number of seconds to
wait before timing out
• -r : Sends request directly to host,
bypassing normal routine tables
$ ping 10.4.28.12 หยุด ^Z หรือ ^C
who
• tell that who else is working on the computer.
The command provide one line of output. The
first field is the user’s logname; the second, the
terminal ID number; the third, the date and time
that the person logged
finger
• provides you with more complete information
about the users who are logged on.
• If finger is given a user’s name as an argrument, it
will print out information on that user regardless
of whether he or she is logged in. Unless, it gives
information who are currently log on
$ finger s3805202
Talk, write and wall
• Talk : announces to the other user that you
wish to chat
• write : write a quick note to someone
• wall : write to all user
• view a file with cat
view a file with cat
• to view a file. cat (Concatenate) takes any files
you specify and displays them on the screen.
$ cat test1
$ cat -v output (non-printing ASCII character))
Redirection
• Redirection เชน
$ cat myfile > myfile.bak ( copy the contents of
myfile to myfile.bak)
$ cat myfile >> data (append the
contents of file myfile to the end of data)
$ cat myfile1 myfile2 myfile3 > myfile
(copies myfile1 myfile2 myfile3 into new
file myfile)
• Using wild card (*)
$ cat myfile* > myfile
(same as previous command)
When using wildcards, make sure that the wildcard
pattern matches the files you want.
$ ls sect*
section1 section2 section3
$ cat *1 *2 > temp
Piping
• ทําคําสั่งตอเนือ่ งกัน เชน
$ ls - l | more
pine
• ใชในการรับสง e-mail
• มีเมนูตางๆ เชน
- COMPOSE MESSAGE ใชในการสรางและสง e-mail
- FOLDER LIST ใชในการเลือก folder เพื่อดูขอมูล
File transfer Protocol (ftp)
Copying files to and from remote machines

ftp 192.168.1.80
ftp ftp@ftp.mcafee.com
ftp> dir
Copying file using ftp
ftp> binary
ftp>ascii
ftp>get filename
200 Port command successful
ftp>put filename
ftp>mget *.*
ftp>mput *.*
telnet
to log in to a system running some other operating
system or different version of the UNIX system
$ telnet 198.162.1.80
$ telnet chiangmai.ac.th
สัญลักษณ ที่ใชแสดงอารมณ
• :-) ;-) :-( :-I :-> >:-> >;->
• (-: %-) :*) [:] 8-) B:-) ::-)
• B-) 8:-) :-)-8 :-{) :-{} {:-) }:-)
• :-[ ,:-) |-I |-o :-Q :-? o:-)
• :-S :-D :-X C=:-) *<:-) :-o
• 8-o *:o) :-9 %-6 [:-)
• ทดสอบสรางแฟม
.plan ซึ่งใชคูกบั คําสั่ง finger - l

• ทดสอบสรางแฟม
.signature ซึ่งใชรวมกับการสง e-mail จาก pine

You might also like