考試考到上個禮拜的
mirror site鏡像站
在不同地方設置伺服器分散下載源,對使用者來說很方便
十七十八章
找檔案Searching For Files
● locate – Find files by name用名字找
● find – Search for files in a directory hierarchy找特定的資料夾下所有檔案
We will also look at a command that is often used with file-search commands to process
the resulting list of files:
●xargs – Build and execute command lines from standard input從標準輸入(鍵盤)執行所有命令
In addition, we will introduce a couple of commands to assist us in our explorations:
● touch – Change file times改變存檔的時間
● stat – Display file or file system status顯示檔案系統狀態
找在bin/目錄下所有以zip開頭的程式
mate@mydebian8:~$ locate bin/zip
/usr/bin/zipdetails
/usr/bin/zipgrep
/usr/bin/zipinfo
mate@mydebian8:~$ locate zip | grep bin
/bin/bunzip2
/bin/bzip2
/bin/bzip2recover
/bin/gunzip
/bin/gzip
/usr/bin/funzip
/usr/bin/gpg-zip
/usr/bin/preunzip
/usr/bin/prezip
/usr/bin/prezip-bin
/usr/bin/unzip
/usr/bin/unzipsfx
/usr/bin/zipdetails
/usr/bin/zipgrep
/usr/bin/zipinfo
/usr/lib/klibc/bin/gunzip
/usr/lib/klibc/bin/gzip
/usr/share/man/man1/prezip-bin.1.gz
find ~ | wc -l 計算運行中的程式有哪些
find ~ -type d | wc -l (d只能搜尋目錄)
find ~ -type f -name "\*.JPG" -size +1M | wc -l (f普通文件、 "*.JPG"以jpg格式存檔的、size +1M大小大於1M
實際上他是去找一個資料庫
perm權限0600 0700
6-rw可讀寫
擁有者有什麼權限
群組 擁有者給予的權限或超級管理員給的權限
其他人
Owner Group World
rwx rwx rwx
檔案類型
-一般檔案
d目錄
l連結
用八進位表示的時候從000到111
000用十進位表示就是0
111用十進位表示就是7
0600使用者可以讀寫
0700
要確定是否一個目錄中的所有文件與子目錄擁有安全權限
(查看權限不是0600跟不是0700的目錄)
mate@mydebian8:~$ find ~ \(-type f -not -perm 0600 \) -or \(type d -not -perm 0700\)
find: paths must precede expression: (type
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
and交集
or聯集
not差集
()優先執行
224頁
有效地搜尋檔案是只要搜尋一次就好的
一次搜尋兩組東西
touch本用在更新檔案
但若本來沒有那個檔案他就會用在新增檔案
mate@mydebian8:~$ mkdir -p playground/dir-{001..100}
mate@mydebian8:~$ touch playground/dir-{001..100}/file-{A..Z}
mate@mydebian8:~$ find playground -type f -name 'file-A'
playground/dir-089/file-A
playground/dir-056/file-A
playground/dir-054/file-A
playground/dir-060/file-A
playground/dir-073/file-A
playground/dir-006/file-A
playground/dir-080/file-A
playground/dir-088/file-A
playground/dir-025/file-A
playground/dir-011/file-A
playground/dir-083/file-A
playground/dir-064/file-A
playground/dir-096/file-A
playground/dir-093/file-A
playground/dir-023/file-A
playground/dir-009/file-A
playground/dir-018/file-A
playground/dir-020/file-A
playground/dir-008/file-A
playground/dir-031/file-A
playground/dir-028/file-A
playground/dir-005/file-A
playground/dir-058/file-A
playground/dir-012/file-A
playground/dir-010/file-A
playground/dir-016/file-A
playground/dir-030/file-A
playground/dir-076/file-A
playground/dir-043/file-A
playground/dir-065/file-A
playground/dir-015/file-A
playground/dir-066/file-A
playground/dir-084/file-A
playground/dir-069/file-A
playground/dir-092/file-A
playground/dir-027/file-A
playground/dir-042/file-A
playground/dir-048/file-A
playground/dir-039/file-A
playground/dir-079/file-A
playground/dir-002/file-A
playground/dir-086/file-A
playground/dir-022/file-A
playground/dir-068/file-A
playground/dir-053/file-A
playground/dir-072/file-A
playground/dir-035/file-A
playground/dir-097/file-A
playground/dir-074/file-A
playground/dir-041/file-A
playground/dir-013/file-A
playground/dir-099/file-A
playground/dir-032/file-A
playground/dir-003/file-A
playground/dir-094/file-A
playground/dir-004/file-A
playground/dir-029/file-A
playground/dir-087/file-A
playground/dir-100/file-A
playground/dir-052/file-A
playground/dir-055/file-A
playground/dir-082/file-A
playground/dir-095/file-A
playground/dir-063/file-A
playground/dir-081/file-A
playground/dir-040/file-A
playground/dir-075/file-A
playground/dir-090/file-A
playground/dir-062/file-A
playground/dir-026/file-A
playground/dir-021/file-A
playground/dir-061/file-A
playground/dir-050/file-A
playground/dir-078/file-A
playground/dir-033/file-A
playground/dir-070/file-A
playground/dir-051/file-A
playground/dir-057/file-A
playground/dir-046/file-A
playground/dir-059/file-A
playground/dir-037/file-A
playground/dir-014/file-A
playground/dir-098/file-A
playground/dir-047/file-A
playground/dir-034/file-A
playground/dir-038/file-A
playground/dir-091/file-A
playground/dir-007/file-A
playground/dir-077/file-A
playground/dir-044/file-A
playground/dir-049/file-A
playground/dir-067/file-A
playground/dir-045/file-A
playground/dir-085/file-A
playground/dir-001/file-A
playground/dir-019/file-A
playground/dir-071/file-A
playground/dir-017/file-A
playground/dir-036/file-A
playground/dir-024/file-A
在家目錄建一個playground目錄
裡面建立次目錄編號從-001到-100
在次目錄建檔案名稱file-a到z
第十八章
●gzip – Compress or expand files
● bzip2 – A block sorting file compressor
The archiving programs:
● tar – Tape archiving utility
● zip – Package and compress files
And the file synchronization program:
●
rsync – Remote file and directory synchronization
建立檔案跟備份
壓縮檔案
壓縮一群檔案
同步rsync
壓縮檔案比較輕便好傳
你有一個圖檔其大小是100*100
每一個點用3個byte就是紅藍綠
這樣算起來就是100*100*3=3萬的byte
就用一個演算法去描述這個檔案(壓縮)
每個byte都是777
就不會存到3萬大概100個byte就可以解決了
mp4 mp3壓縮的時候把人聽不到的部份都砍掉了
先產生一個檔案
看他長度是多少
在壓縮
看他長度是多少
在解壓縮
看他長度是多少
mate@mydebian8:~$ ls -l /etc > foo.txt
mate@mydebian8:~$ ls -l foo.*
-rw-r--r-- 1 mate mate 14304 6月 9 08:53 foo.txt
mate@mydebian8:~$ gzip foo.txt
mate@mydebian8:~$ ls -l foo.*
-rw-r--r-- 1 mate mate 2759 6月 9 08:53 foo.txt.gz
mate@mydebian8:~$ gunzip foo.txt
mate@mydebian8:~$ ls -l foo.*
-rw-r--r-- 1 mate mate 14304 6月 9 08:53 foo.txt
mate@mydebian8:~$ ls -l /etc > foo.txt
mate@mydebian8:~$ ls -l foo.txt
-rw-r--r-- 1 mate mate 14304 6月 9 08:56 foo.txt
mate@mydebian8:~$ bzip2 foo.txt
mate@mydebian8:~$ ls -l foo.txt.bz2
-rw-r--r-- 1 mate mate 2477 6月 9 08:56 foo.txt.bz2
mate@mydebian8:~$ bunzip2 foo.txt.bz2
進入超級管理員身份
mate@mydebian8:~$ su
密碼:
更新檔案資料庫
root@mydebian8:/home/mate# apt-get update
安裝rsync
root@mydebian8:/home/mate# apt-get install rsync
mate@mydebian8:~$ rm -rf foo/*
mate@mydebian8:~$ rsync -av playground foo
sending incremental file list
created directory foo
playground/
playground/dir-001/
playground/dir-001/file-A
playground/dir-001/file-B
playground/dir-001/file-C
playground/dir-001/file-D
playground/dir-001/file-E
playground/dir-001/file-F
playground/dir-001/file-G
playground/dir-001/file-H
playground/dir-001/file-I
playground/dir-001/file-J
playground/dir-001/file-K
playground/dir-001/file-L
playground/dir-001/file-M
playground/dir-001/file-N
playground/dir-001/file-O
playground/dir-001/file-P
playground/dir-001/file-Q
playground/dir-001/file-R
playground/dir-001/file-S
playground/dir-001/file-T
playground/dir-001/file-U
playground/dir-001/file-V
playground/dir-001/file-W
playground/dir-001/file-X
playground/dir-001/file-Y
playground/dir-001/file-Z
playground/dir-002/
playground/dir-002/file-A
playground/dir-002/file-B
playground/dir-002/file-C
playground/dir-002/file-D
playground/dir-002/file-E
playground/dir-002/file-F
playground/dir-002/file-G
playground/dir-002/file-H
playground/dir-002/file-I
playground/dir-002/file-J
playground/dir-002/file-K
playground/dir-002/file-L
playground/dir-002/file-M
playground/dir-002/file-N
playground/dir-002/file-O
playground/dir-002/file-P
playground/dir-002/file-Q
playground/dir-002/file-R
playground/dir-002/file-S
playground/dir-002/file-T
playground/dir-002/file-U
playground/dir-002/file-V
playground/dir-002/file-W
playground/dir-002/file-X
playground/dir-002/file-Y
playground/dir-002/file-Z
playground/dir-003/
playground/dir-003/file-A
playground/dir-003/file-B
playground/dir-003/file-C
playground/dir-003/file-D
playground/dir-003/file-E
playground/dir-003/file-F
playground/dir-003/file-G
playground/dir-003/file-H
playground/dir-003/file-I
playground/dir-003/file-J
playground/dir-003/file-K
playground/dir-003/file-L
playground/dir-003/file-M
playground/dir-003/file-N
playground/dir-003/file-O
playground/dir-003/file-P
playground/dir-003/file-Q
playground/dir-003/file-R
playground/dir-003/file-S
playground/dir-003/file-T
playground/dir-003/file-U
playground/dir-003/file-V
playground/dir-003/file-W
playground/dir-003/file-X
playground/dir-003/file-Y
playground/dir-003/file-Z
playground/dir-004/
playground/dir-004/file-A
playground/dir-004/file-B
playground/dir-004/file-C
playground/dir-004/file-D
playground/dir-004/file-E
playground/dir-004/file-F
playground/dir-004/file-G
playground/dir-004/file-H
playground/dir-004/file-I
playground/dir-004/file-J
playground/dir-004/file-K
playground/dir-004/file-L
playground/dir-004/file-M
playground/dir-004/file-N
playground/dir-004/file-O
playground/dir-004/file-P
playground/dir-004/file-Q
playground/dir-004/file-R
playground/dir-004/file-S
playground/dir-004/file-T
playground/dir-004/file-U
略
playground/dir-100/file-X
playground/dir-100/file-Y
playground/dir-100/file-Z
sent 138,129 bytes received 49,878 bytes 376,014.00 bytes/sec
total size is 0 speedup is 0.00
mate@mydebian8:~$ touch playground/dir-099/file-Z
mate@mydebian8:~$ rsync -av playground foo
sending incremental file list
playground/dir-099/file-Z
sent 36,463 bytes received 158 bytes 73,242.00 bytes/sec
total size is 0 speedup is 0.00
開新帳號
mate@mydebian8:~$ su
密碼:
root@mydebian8:/home/mate# adduser TINGJIE
adduser: Please enter a username matching the regular expression configured
via the NAME_REGEX configuration variable. Use the `--force-badname'
option to relax this check or reconfigure NAME_REGEX.
root@mydebian8:/home/mate# adduser tingjie
Adding user `tingjie' ...
Adding new group `tingjie' (1004) ...
Adding new user `tingjie' (1004) with group `tingjie' ...
Creating home directory `/home/tingjie' ...
Copying files from `/etc/skel' ...
輸入新的 UNIX 密碼:
再次輸入新的 UNIX 密碼:
passwd:密碼已成功地變更
正在改變 tingjie 的使用者訊息
請輸入新值,或直接按 ENTER 鍵以使用預設值
全名 []: tingjie
房間號碼 []:
工作電話 []:
住家電話 []:
其它 []:
Is the information correct? [Y/n] y
root@mydebian8:/home/mate#
沒有留言:
張貼留言