Introduction to Unix-like System
Macaca Li
National Taiwan University
2014/02/24
Who am I
B97902018/R01922001 Experience:
NASA TA (101-1, 101-2) DSA TA (100-2)
Machine Learning TA (100-1, 102-1) Poor at: Systems and Architectures How to learn UNIX?
Experience Google
What is 217 Workstation Lab
http://wslab.csie.ntu.edu.tw/
How many OS you know
What is UNIX
Compliant with and certified according to the Single UNIX Specification
First developed in 1969, including Ken Thompson
Dennis Ritchie Brian Kernighan Douglas McIlroy Michael Lesk Joe Ossanna
Multitasking and multi-user OS Unix-like System
Dennis Ritchie
All computer science students should know him
Unix-like
BSDs Linux Mac OS Solaris Minix SunOS
Linux-Kernel
Accessing hardwares
Provides the functions you would learn from OS-related courses Can shed the parts you don’t need - Android
Distributions
Built on the kernel with many applications
Ubuntu, Debian, Fedora, CentOS, Redhat, SUSE, ... etc
(a) Ubuntu (b) Debian
(c) Fedora (d) SUSE
Why use UNIX
Stability Performance Security Price
”Given enough eyeballs, all bugs are shallow.” - Linus Question
Is UNIX a panacea ?
Logging to 217 workstation
All in http://wslab.csie.ntu.edu.tw/ssh/
Path
. ..
∼
Absolute path
Basic Commands
File cd ls mkdir rm mv cp find pwd
Man
Manual rather than guys ex: man ls man man (-k)
Text cat more less tail head grep diff sort wc cut -d -f vim
Others whoami who ps aux top kill alias tar awk sed
Vim
Insert: i
Command: Esc Save: :w Exit: :q vimtutor
Redirect the input and output
<
>
>>
Demos
Combos - Pipe
Combine multiple commands with I/O redirection Example - list /bin
ls -al /bin | more
Exercise
How to find the arguments for recursive copying?
How many processes are running How many users are logging Ans: who | cut -d -f1 | uniq | wc -l Who are logging in ascending order
File Permissions
What is this
File Permissions I
r: read w: write x: execute
rwx rwx rwx (User Group Others)
File Permissions II
Regualr File Permissions r: read
w: write x: execute
Directory Permissions r: read (ls)
w: write (cp, mv, ...) x: execute (cd)
Shell Script
Combine more commands with more flexibilities Scenerio1
You need to do a sequence of commands such as mkdir test1
touch ./test1/doc1 touch ./test1/doc2 mkdir test2
touch ./test1/doc3 for 10 times ...
Scenerio2
Basic Structure
Learning by Examples