Useful Commands
Jump to navigation
Jump to search
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}
|