or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
高等 UNIX 程式設計 – 黃俊穎
http://people.cs.nctu.edu.tw/~chuang/courses/unixprog
unix107
up19peppa
Syllbus
Overview & env
touch ./-aaa
>
<
|
man [section] command
man -k command
: 找到有哪些 sectionecho $?
: 上一個 process 的 return value||
: 如果前面 return true,就不用執行後面的&&
: 如果前面 return true,才執行後面的Tools
Compiler
-S
: 生成 .s (assembly)-c
: 只編譯,不 link-l
: link library-I
: add include path-L
: add lib pathnm
: 可以解析 object file 的指令(list symbols)make, Makefile
-C
: 修改工作目錄-f
: 指定檔案 (就不一定要叫做 Makefile 了)-j
: 同時編譯$@
: target 名稱$<
: 第一個 prerequisite$?
: 比 target 新的 prerequisite$^
: 所有 prerequisite (會移除重複)$+
:$^
但不移除重複.c.o:
: .c 檔轉成 .o 檔%.o: %.c
.c.o
缺點GDB
-g
: compile 時產生 debug synble,不用不影響 gdb 指令,但是會看不到 source codelist
: 列出 sourse coderun
: always run from begins/step
: 跳一行,但會跳進 function call (if esixt)n/next
: 跳一行ni/nexti
: next instruction (asm level)p/print
: print source codec/continue
: 跳到下一個 break pointb/break
layout {ams|regs|src}
bt/backtrace
: 查看 call stackx/FMT <address>
: 用 MFT 方式查看記憶體位址fin/finish
: 從 call stack 中跳回上一層ulimit
File IO & Standard IO
a>b
: 將 FD a 重導向 FD b> file
: 通常不寫就是將 FD 1(stdout) 重導向 file|
: pipe()/var/spool/cron/FIFO
: Sequential accessgcc –D_LARGEFILE64_SOURCE –D_LARGEFILE_SOURCE –D_FILE_OFFSET_BITS=64
ls -s
: 看 write bytestrip
: re-format block write,有機會整理壓縮寫入 block sizeFile IO other issue
/proc/[pid]/fd/
: 看 process 有維護的 fdStandard IO
最大的差別,stdio 有 buffer,他不會每次 call 都做 system call,而是只有在 buffer 被填滿時才 system call 寫入
b
\n
時,再去跑一次 kernel callt
,會讓這個 io 一行一行吃fwrite(pt, sizeof(double), 2, fp)
char *tmpnam(char *ptr)
/tmp/fileXXXXXX
開出暫存檔tmpfile(void)
File & Dir
/
跟null
外,都可以用/etc/passwd
設定int stat(const char *path, struct stat *buf);
int fstat(int fd, struct stat *buf);
int lstat(const char *path, struct stat *buf);
File information
/etc/passwd
//etc/groups
int access(const char *path, int mode);
: 確認權限mode_t umask(mode_t cmask);
: mask 掉權限umask 0
-> 預設所有權限都開void rewinddir(DIR *dir)
off_t telldir(DIR *dir)
void seekdir(DIR *dir, off_t offset)
dev_t
device numberst_dev
st_rdev
mknod
or auto generated when dev registerhdaN?
、sdaN?
、scdN
、ttyN
、ttySN
、pts/N
、null
、zero
、random
sysinfo