Useful Commands: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
| (10 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
https://www.diskpart.com/articles/delete-hidden-partition-on-usb-drive-7201.html | |||
= File System = | = File System = | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 4: | Line 6: | ||
|- | |- | ||
| (查) 變彩色,加上後綴,目錄以 / 結尾,連結以 @ 結尾 | | (查) 變彩色,加上後綴,目錄以 / 結尾,連結以 @ 結尾 | ||
| < | | <syntaxhighlight lang="bash">ls -FG</syntaxhighlight> | ||
|- | |- | ||
| (查) 在目前的目錄下搜尋所有隱藏檔,'''注意要有單引號''' | | (查) 在目前的目錄下搜尋所有隱藏檔,'''注意要有單引號''' | ||
| < | | <syntaxhighlight lang="bash">find . -name '.*'</syntaxhighlight> | ||
|- | |- | ||
| 刪除檔名 - 或是 -- 開頭的檔案 | | delete dist directory recursively except README.md and itself. | ||
| < | | <syntaxhighlight lang="bash">find dist -not -path dist -not -path dist/README.md -delete</syntaxhighlight> | ||
|- | |||
| 刪除檔名 - 或是 -- 開頭的檔案 | |||
| <syntaxhighlight lang="bash">rm -- -X --exclude-from</syntaxhighlight> | |||
|- | |- | ||
| 變更檔案時間為<br/>2013 年 9 月 1 號 00:00:00 | | 變更檔案時間為<br/>2013 年 9 月 1 號 00:00:00 | ||
| < | | <syntaxhighlight lang="bash">touch -t 201309010000 檔案名稱</syntaxhighlight> | ||
|- | |- | ||
| Linux 環境產生 Ramdisk (無法指定大小) | | Linux 環境產生 Ramdisk (無法指定大小) | ||
| < | | <syntaxhighlight lang="bash">mount -t ramfs ramfs /usr/local/ramdisk</syntaxhighlight> | ||
|- | |- | ||
| Linux/BSD 環境產生 Ramdisk (配置 128M) | | Linux/BSD 環境產生 Ramdisk (配置 128M) | ||
| < | | <syntaxhighlight lang="bash">mount -t tmpfs -o size=128m tmpfs /usr/local/ramdisk</syntaxhighlight> | ||
|- | |||
| Test I/O performance of 1G write with 4K block | |||
| <syntaxhighlight lang="bash">dd if=/dev/zero of=100k.bin bs=4k count=262144</syntaxhighlight> | |||
|- | |- | ||
| 產生 100K 的檔案 | | 產生 100K 的檔案 | ||
| < | | <syntaxhighlight lang="bash">dd if=/dev/zero of=100k.bin bs=1k count=100</syntaxhighlight> | ||
|- | |- | ||
| 產生 10M 的檔案<br/>空間將會塞爆時,不會有警告訊息 | | 產生 10M 的檔案<br/>空間將會塞爆時,不會有警告訊息 | ||
| < | | <syntaxhighlight lang="bash">dd if=/dev/zero of=10m.bin bs=1m count=10</syntaxhighlight> | ||
|- | |- | ||
| 故意消耗系統記憶體 (RAM+SWAP) | | 故意消耗系統記憶體 (RAM+SWAP) | ||
| < | | <syntaxhighlight lang="bash"> | ||
mkdir /usr/local/ramdisk | mkdir /usr/local/ramdisk | ||
mount -t tmpfs -o size=2G tmpfs /usr/local/ramdisk | mount -t tmpfs -o size=2G tmpfs /usr/local/ramdisk | ||
dd if=/dev/zero of=/usr/local/ramdisk/fill.bin bs=1m count=2048 | dd if=/dev/zero of=/usr/local/ramdisk/fill.bin bs=1m count=2048 | ||
</ | </syntaxhighlight> | ||
|} | |} | ||
| Line 40: | Line 48: | ||
|- | |- | ||
| Samba (Linux) || | | Samba (Linux) || | ||
< | <syntaxhighlight lang="bash"> | ||
sudo mount -t smbfs {remote} {local} -o \ | sudo mount -t smbfs {remote} {local} -o \ | ||
iocharset=utf8, \ | iocharset=utf8, \ | ||
| Line 46: | Line 54: | ||
uid=`id -u {local user}`, \ | uid=`id -u {local user}`, \ | ||
gid=`id -u {local group}` | gid=`id -u {local group}` | ||
</ | </syntaxhighlight> | ||
|- | |- | ||
| Samba (MacOS) || | | Samba (MacOS) || | ||
< | <syntaxhighlight lang="bash"> | ||
mount_smbfs //'{group};{user}':{password}@{remote}/{shared dir} {local dir} | mount_smbfs //'{group};{user}':{password}@{remote}/{shared dir} {local dir} | ||
smbutil view //Guest@192.168.91.65 | smbutil view //Guest@192.168.91.65 | ||
smbutil view //'WORKGROUP;Administrator':12345@192.168.1.2 # for Windows 2K3 | smbutil view //'WORKGROUP;Administrator':12345@192.168.1.2 # for Windows 2K3 | ||
</ | </syntaxhighlight> | ||
|- | |- | ||
| Samba (FreeBSD) || | | Samba (FreeBSD) || | ||
< | <syntaxhighlight lang="bash"> | ||
mount -t smbfs -o '-N' //raymondwu@RaymondWu-PC/TikaSamples /var/tika/samples # Using ~/.nsmbrc | mount -t smbfs -o '-N' //raymondwu@RaymondWu-PC/TikaSamples /var/tika/samples # Using ~/.nsmbrc | ||
mount_smbfs -I 192.168.91.65 //raymondwu@RaymondWu-PC/TikaSamples /var/tika/samples | mount_smbfs -I 192.168.91.65 //raymondwu@RaymondWu-PC/TikaSamples /var/tika/samples | ||
smbutil view -I 192.168.91.65 //raymondwu@RaymondWu-PC | smbutil view -I 192.168.91.65 //raymondwu@RaymondWu-PC | ||
</ | </syntaxhighlight> | ||
|} | |} | ||
| Line 68: | Line 76: | ||
|- | |- | ||
| zip || | | zip || | ||
< | <syntaxhighlight lang="bash"> | ||
zip -r front-end.zip index.html static/ | zip -r front-end.zip index.html static/ | ||
unzip -l front-end.zip | unzip -l front-end.zip | ||
unzip -p front-end.zip index.html | unzip -p front-end.zip index.html | ||
</ | </syntaxhighlight> | ||
|- | |- | ||
| tar || | | tar || | ||
< | <syntaxhighlight lang="bash"> | ||
tar --exclude=".*" -zcvf ~/solr-4.3.0.tgz solr-4.3.0 | tar --exclude=".*" -zcvf ~/solr-4.3.0.tgz solr-4.3.0 | ||
tar -C /usr/local --exclude '.*' -zcvf tika-1.4-pxx.tgz tika | tar -C /usr/local --exclude '.*' -zcvf tika-1.4-pxx.tgz tika | ||
</ | </syntaxhighlight> | ||
|- | |- | ||
| gzip || | | gzip || | ||
< | <syntaxhighlight lang="bash"> | ||
gzip -k taiwan-taco.map | gzip -k taiwan-taco.map | ||
gzip -l taiwan-taco.map.gz | gzip -l taiwan-taco.map.gz | ||
compressed uncompressed ratio uncompressed_name | compressed uncompressed ratio uncompressed_name | ||
25400590 38204880 33.5% taiwan-taco.map | 25400590 38204880 33.5% taiwan-taco.map | ||
</ | </syntaxhighlight> | ||
|- | |- | ||
| xz || | | xz || | ||
< | <syntaxhighlight lang="bash"> | ||
xz -zk hd-20190227.csv | xz -zk hd-20190227.csv | ||
xz -vt hd-20190227.csv.xz | xz -vt hd-20190227.csv.xz | ||
hd-20190227.csv.xz (1/1) | hd-20190227.csv.xz (1/1) | ||
100 % 344.1 KiB / 1,458.1 KiB = 0.236 | 100 % 344.1 KiB / 1,458.1 KiB = 0.236 | ||
</ | </syntaxhighlight> | ||
|- | |- | ||
| dd || | | dd || | ||
< | <syntaxhighlight lang="bash"> | ||
# Make an ISO image. | # Make an ISO image. | ||
df -h | df -h | ||
| Line 105: | Line 113: | ||
Win7.iso: ISO 9660 CD-ROM filesystem data 'GRMCULFRER_TW_DVD ' (bootable) | Win7.iso: ISO 9660 CD-ROM filesystem data 'GRMCULFRER_TW_DVD ' (bootable) | ||
kill -USR1 {pid of dd} | kill -USR1 {pid of dd} | ||
</ | </syntaxhighlight> | ||
|} | |} | ||
= Other Topics = | = Other Topics = | ||
* [[Useful Commands/Hardware|Hardware]] | |||
* [[Useful Commands/File Processing|File Processing]] | * [[Useful Commands/File Processing|File Processing]] | ||
* [[Useful Commands/Text Processing|Text Processing]] | * [[Useful Commands/Text Processing|Text Processing]] | ||
| Line 119: | Line 128: | ||
* [[Useful Commands/System Status|System Status]] | * [[Useful Commands/System Status|System Status]] | ||
* [[Useful Commands/Arithmetic|Arithemetic]] | * [[Useful Commands/Arithmetic|Arithemetic]] | ||
* [[Useful Commands/Security|Security]] | * [[Useful Commands/Security|Security]]: ssh, socat | ||
* [[Useful Commands/MacOS only|MacOS only]] | * [[Useful Commands/MacOS only|MacOS only]] | ||
* [[Useful Commands/Windows only|Windows only]] | |||
Latest revision as of 20:13, 3 April 2025
https://www.diskpart.com/articles/delete-hidden-partition-on-usb-drive-7201.html
File System
| 情境 | 指令 |
|---|---|
| (查) 變彩色,加上後綴,目錄以 / 結尾,連結以 @ 結尾 | ls -FG
|
| (查) 在目前的目錄下搜尋所有隱藏檔,注意要有單引號 | find . -name '.*'
|
| delete dist directory recursively except README.md and itself. | find dist -not -path dist -not -path dist/README.md -delete
|
| 刪除檔名 - 或是 -- 開頭的檔案 | rm -- -X --exclude-from
|
| 變更檔案時間為 2013 年 9 月 1 號 00:00:00 |
touch -t 201309010000 檔案名稱
|
| Linux 環境產生 Ramdisk (無法指定大小) | mount -t ramfs ramfs /usr/local/ramdisk
|
| Linux/BSD 環境產生 Ramdisk (配置 128M) | mount -t tmpfs -o size=128m tmpfs /usr/local/ramdisk
|
| Test I/O performance of 1G write with 4K block | dd if=/dev/zero of=100k.bin bs=4k count=262144
|
| 產生 100K 的檔案 | dd if=/dev/zero of=100k.bin bs=1k count=100
|
| 產生 10M 的檔案 空間將會塞爆時,不會有警告訊息 |
dd if=/dev/zero of=10m.bin bs=1m count=10
|
| 故意消耗系統記憶體 (RAM+SWAP) | mkdir /usr/local/ramdisk
mount -t tmpfs -o size=2G tmpfs /usr/local/ramdisk
dd if=/dev/zero of=/usr/local/ramdisk/fill.bin bs=1m count=2048
|
Remote File System
| Tool | Example |
|---|---|
| Samba (Linux) |
sudo mount -t smbfs {remote} {local} -o \
iocharset=utf8, \
user={user}%{password}, \
uid=`id -u {local user}`, \
gid=`id -u {local group}`
|
| Samba (MacOS) |
mount_smbfs //'{group};{user}':{password}@{remote}/{shared dir} {local dir}
smbutil view //Guest@192.168.91.65
smbutil view //'WORKGROUP;Administrator':12345@192.168.1.2 # for Windows 2K3
|
| Samba (FreeBSD) |
mount -t smbfs -o '-N' //raymondwu@RaymondWu-PC/TikaSamples /var/tika/samples # Using ~/.nsmbrc
mount_smbfs -I 192.168.91.65 //raymondwu@RaymondWu-PC/TikaSamples /var/tika/samples
smbutil view -I 192.168.91.65 //raymondwu@RaymondWu-PC
|
Compression
| Tool | Example |
|---|---|
| zip |
zip -r front-end.zip index.html static/
unzip -l front-end.zip
unzip -p front-end.zip index.html
|
| tar |
tar --exclude=".*" -zcvf ~/solr-4.3.0.tgz solr-4.3.0
tar -C /usr/local --exclude '.*' -zcvf tika-1.4-pxx.tgz tika
|
| gzip |
gzip -k taiwan-taco.map
gzip -l taiwan-taco.map.gz
compressed uncompressed ratio uncompressed_name
25400590 38204880 33.5% taiwan-taco.map
|
| xz |
xz -zk hd-20190227.csv
xz -vt hd-20190227.csv.xz
hd-20190227.csv.xz (1/1)
100 % 344.1 KiB / 1,458.1 KiB = 0.236
|
| dd |
# Make an ISO image.
df -h
umount /dev/disk2
dd if=/dev/disk2 of=Win7.iso bs=2048 count=1000
file Win7.iso
Win7.iso: ISO 9660 CD-ROM filesystem data 'GRMCULFRER_TW_DVD ' (bootable)
kill -USR1 {pid of dd}
|