gzip解壓縮
1.先將檔名改為.gz
 mv initrd-2.6.18-92.el5.img initrd-2.6.18-92.el5.gz
2.gzip -d       # -d --decompress 
 gzip -d initrd-2.6.18-92.el5.gz

file initrd-2.6.18-92.el5
initrd-2.6.18-92.el5: ASCII cpio archive (SVR4 with no CRC)

===========================================================

cpio 解壓縮
cpio -ivcdu < initrd-2.6.18-92.el5

cpio - copy files to and from archives

‘-c’   Identical  to “-H newc”, use the new (SVR4) portable format.  
    If  you wish the old portable (ASCII) archive format, use  
                “-H  odc” instead.

‘-d, --make-directories’
             Create leading directories where needed.

‘-i, --extract’
              Run in copy-in mode.  see “Copy-in mode”.

‘-u, --unconditional’
              Replace  all  files,  without asking whether to replace existing
              newer files with older files.

‘-v, --verbose’冗長的
              List the files processed, or with ‘-t’, give an  ‘ls  -l’  style
              table  of contents listing.  In a verbose table of contents of a
              ustar archive, user and group names in the archive that  do  not
              exist  on the local system are replaced by the names that corre-
              spond locally to the numeric UID and GID stored in the  archive.

===========================================================

 

查看硬碟使用容量

# df -Th

Filesystem                           Type         Size  Used     Avail   Use%  Mounted on

/dev/mapper/centos-root       xfs          6.7G   4.6G    2.1G    69%    /

devtmpfs                          devtmpfs     906M     0     906M     0%    /dev

tmpfs                                   tmpfs       921M   88K   920M     1%     /dev/shm

tmpfs                                   tmpfs       921M  8.7M   912M    1%     /run

tmpfs                                    tmpfs      921M     0      921M    0%     /sys/fs/cgroup

/dev/sda1                                xfs       497M  157M  341M    32%    /boot

tmpfs                                    tmpfs     185M   8.0K    184M    1%    /run/user/0

-h, --  human-readable (自動選擇KB,MB,GB顯示)    
          print sizes in human readable format (e.g., 1K 234M 2G)/

-T, --   print file system Type


列出目錄使用的容量
# du -sh /*
 -s, --summarize
   display only a total for each argument


0             /bin
131M      /boot
816K      /dev
39M       /etc
5.7M      /home
0           /lib
0           /lib64
0           /media
0          /mnt
20M     /opt
du: cannot access ‘/proc/4761/task/4761/fd/4’: No such file or directory
du: cannot access ‘/proc/4761/task/4761/fdinfo/4’: No such file or directory
du: cannot access ‘/proc/4761/fd/4’: No such file or directory
du: cannot access ‘/proc/4761/fdinfo/4’: No such file or directory
0            /proc
5.3M     /root
8.8M     /run
0           /sbin
0           /srv
0           /sys
216K     /tmp
3.3G     /usr
1.3G     /var

====================================================

hdparm 測試讀取速度

 -t   Perform device read timings

 -T   Perform cache read timings

 

[root@localhost ~]# hdparm -t /dev/sda

/dev/sda:

 Timing buffered disk reads: 612 MB in  3.00 seconds = 203.94 MB/sec

 

[root@localhost ~]# hdparm -t --direct /dev/sda

/dev/sda:

 Timing O_DIRECT disk reads: 684 MB in  3.04 seconds = 225.30 MB/sec

 

[root@localhost ~]# hdparm -T /dev/sda

/dev/sda:

 Timing cached reads:   9900 MB in  2.00 seconds = 4954.13 MB/sec

 

[root@localhost ~]# hdparm -T --direct /dev/sda

/dev/sda:

 Timing O_DIRECT cached reads:   102 MB in  2.03 seconds =  50.33 MB/sec

====================================================

查看記憶體指令 free

free 指令可以看實體記憶體和 Swap 的使用情況

-h human readable output (automatic unit scaling)

-s update every [delay] seconds

 

[root@localhost ~]# free -hs 5
[root@localhost ~]# watch -n 5 'free -h'  (
比較清楚)

 

             total       used       free     shared    buffers     cached

Mem:          996M       366M       629M       3.6M       8.3M        65M

-/+ buffers/cache:       292M       703M

Swap:         815M         0B       815M

 

====================================================

RAM Disk

[root@localhost ~]# mkdir /tmp/tmpfs

[root@localhost ~]# mount -t tmpfs -o size=50M tmpfs /tmp/tmpfs/

-t, --types vfstype

-o, --options opts

 

# df -TH

Filesystem           Type    Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root

                     ext4    7.0G  4.3G  2.4G  64% /

tmpfs                tmpfs   523M  308k  523M   1% /dev/shm

/dev/sda1            ext4    500M   39M  435M   9% /boot

tmpfs                tmpfs    53M     0   53M   0% /tmp/tmpfs

 

寫入測試

# dd count=50 bs=1M if=/dev/zero of=/tmp/tmpfs/test.img

50+0 records in

50+0 records out

52428800 bytes (52 MB) copied, 0.0617388 s, 849 MB/s

 

# dd count=12500 bs=4k if=/dev/zero of=/tmp/tmpfs/test.img

12500+0 records in

12500+0 records out

51200000 bytes (51 MB) copied, 0.0744877 s, 687 MB/s

 

dd count=2k bs=1M if=/tmp/ramdisk/test2g.img of=/dev/null

 

讀取測試

# dd count=50 bs=1M if=/tmp/tmpfs/test.img of=/dev/null

48+1 records in

48+1 records out

51200000 bytes (51 MB) copied, 0.0272163 s, 1.9 GB/s

 

# dd count=12500 bs=4k if=/tmp/tmpfs/test2g.img of=/dev/null

12500+0 records in

12500+0 records out

51200000 bytes (51 MB) copied, 0.030945 s, 1.7 GB/s

=======================================

adminX 發表在 痞客邦 留言(0) 人氣()

  • Mar 17 Sat 2018 16:43
  • Python

def fib(n):
    if n==0 :
        return 0
    
    elif n==1 or n==2 :
        return 1
    
    else :
        return (fib(n-2)+fib(n-1))


n=int(input("Input the number of fib: "))

for i in range(n) :
    print(fib(i))    

=========================

adminX 發表在 痞客邦 留言(0) 人氣()

  • Dec 10 Sun 2017 22:40
  • Video

 

Magical Europe - 4K Timelapse 歐洲30國縮時攝影

https://www.youtube.com/watch?time_continue=92&v=AjcxPd6Oag8

 

下載4k   ClipCoverter
http://www.clipconverter.cc/

adminX 發表在 痞客邦 留言(0) 人氣()

   各品牌的測試模式代碼如下:

   核對IMEI *#06#

  • hTC*#*#3424#*#*
  • Sony*#*#7378423#*#*
  • Samsung*#0*#
  • LG*#546368#*___#___為手機型號,可在系統設定>關於手機>硬體資訊中找到)
  • Motolora*#*#4363#*#* *#*#2486#*#*

    在通話功能中輸入代碼,就可進入測試模式

    轉貼網址 http://3c.ltn.com.tw/news/24392

======================================================================================

SONY手機拍完照,預設只能由相簿瀏覽

=> 停用相簿=>拍照=>就可以選擇用什麼程式瀏覽了

  • 聯發科晶片手機:*#*#3646633#*#*

adminX 發表在 痞客邦 留言(0) 人氣()

  • May 20 Sat 2017 23:32
  • Code

============== C++ 寫入檔案===============

#include<iostream>
#include<fstream>
using namespace std;
 
int main(){

    //開檔
    char filename[]="link.txt";
    fstream fp;
    fp.open(filename, ios::out);
     
      for (int i=1;i<20;i++)
    {
    fp<<"http://test.com/"<<i<<".ppt"<<endl; //寫入檔案
    }


    fp.close();  //關檔
    system("pause");
    return 0;
}

文章標籤

adminX 發表在 痞客邦 留言(0) 人氣()

parted /dev/sdb mklabel loop    partition 清空

adminX 發表在 痞客邦 留言(0) 人氣()

  • Jan 31 Tue 2017 20:34
  • 轉貼

cut,sed,awk 字串處理

轉貼 http://jarkin.blogspot.tw/search/label/Shell%20Scritp

cut 教學:

  cut -b 10- filename //刪除該列的前10個字元
  cut -d(分界字元) filename //指定欄位的分界字元



sed 教學:
  sed -e '3d' //刪除第3列
  sed -e '2,5d' //刪除第2~5列
  sed -e '4,$d' //刪除第4列,但第4列是最後一列;錢字號『 $ 』代表最後一行!
  sed -e "/${var}/"d //在shell中,用變數代替
  sed 's/^...//' //刪除該列的前3個字元
  sed 's/...$//' //刪除該列的最後3個字元
  sed '/Hello/d' dataf3 //刪除Hello該列
  sed -i “s/\r//”FILENAME //刪除檔案中的^M字元
 
  sed 's/要被取代的字串/新的字串/g'
  ex: sed 's/*//g' //將「*」符用空白字元取代



awk教學:
  awk 'NR!=3 {print $0}' //刪除第3列
  awk '!(NR>=2 && NR<=5){print $0}' //刪除第2~5列



綜合:
  捉取第一列的「:」前的資料
  awk 'NR==1' aaa.a | cut -f 1 -d :

  捉取第一列的「:」前的資料並計算個數
  awk 'NR==1' aaa.a | cut -f 1 -d : | wc -m
 
  cat test.sh | awk -F = '/Sub 1/ {print NR}' //抓test.sh的Sub 1所在的列數


  抓取Channel方法
  iwconfig ra0 2>/dev/null | grep Channel | awk '{print $2}' | cut -b 9-
 
=========================================================

檢查檔案是否存在

if [ -f "檔案路徑" ]; then
    echo "檔案存在!!"
else
    echo "檔案不存在!!"
fi

or
if [ ! -f "檔案路徑" ]; then 
 
=========================================================

Get DHCP Assignment Default Gateway

Shell Code:
    route -n | grep 'UG[ \t]' | awk '{print $2}'


Shell Code: 
    route -n | grep '^0\.0\.\0\.0[ \t]\+[1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]\+[ \t]\+0\.0\.0\.0[ \t]\+[^ \t]*G[^ \t]*[ \t]' | awk '{print $2}'
=========================================================

Linux 一些系統訊息
 

整理一些linux系統一些常用的系統信息查看命令.
有些在freebsd下也能用…
# uname -a # 查看內核/操作系統/CPU信息
# head -n 1 /etc/issue # 查看操作系統版本
# cat /proc/cpuinfo # 查看CPU信息
# hostname # 查看計算機名
# lspci -tv # 列出所有PCI設備
# lsusb -tv # 列出所有USB設備
# lsmod # 列出加載的內核模塊
# env # 查看環境變量資源
# free -m # 查看內存使用量和交換區使用量
# df -h # 查看各分區使用情況
# du -sh <目錄名> # 查看指定目錄的大小
# grep MemTotal /proc/meminfo # 查看內存總量
# grep MemFree /proc/meminfo # 查看空閒內存量
# uptime # 查看系統運行時間、用戶數、負載
# cat /proc/loadavg # 查看系統負載磁盤和分區
# mount | column -t # 查看掛接的分區狀態
# fdisk -l # 查看所有分區
# swapon -s # 查看所有交換分區
# hdparm -i /dev/hda # 查看磁盤參數(僅適用於IDE設備)
# dmesg | grep IDE # 查看啟動時IDE設備檢測狀況網絡
# ifconfig # 查看所有網絡接口的屬性
# iptables -L # 查看防火牆設置
# route -n # 查看路由表
# netstat -lntp # 查看所有監聽端口
# netstat -antp # 查看所有已經建立的連接
# netstat -s # 查看網絡統計信息進程
# ps -ef # 查看所有進程
# top # 實時顯示進程狀態用戶
# w # 查看活動用戶
# id <用戶名> # 查看指定用戶信息
# last # 查看用戶登錄日誌
# cut -d: -f1 /etc/passwd # 查看系統所有用戶
# cut -d: -f1 /etc/group # 查看系統所有組
# crontab -l # 查看當前用戶的計劃任務服務
# chkconfig –list # 列出所有系統服務
# chkconfig –list | grep on # 列出所有啟動的系統服務程序
# rpm -qa # 查看所有安裝的軟件包
# cat /proc/cpuinfo :查看CPU相關參數
# cat /proc/partitions :查看硬盤和分區
# cat /proc/meminfo :查看內存信息
# cat /proc/version :查看版本,類似uname -r
# cat /proc/ioports :查看設備io端口
# cat /proc/interrupts :查看中斷
# cat /proc/pci :查看pci設備的信息
# cat /proc/swaps :查看所有swap分區的信息

=========================================================

 

 
 
文章標籤

adminX 發表在 痞客邦 留言(2) 人氣()

  • Nov 11 Fri 2016 06:20
  • Temp

Google Chrome的擴充功能怎麼備份

到路徑C:\Documents and Settings\使用者名稱\Local Settings\Application Data\Google\Chrome\User Data\ 

備份整個Default資料夾[裡面有書籤和擴充套件] 
還原時就放回原路徑即可

adminX 發表在 痞客邦 留言(0) 人氣()

Audacity 可對音效(包括FLAC) 作fade in處理 和頻譜測試

 

adminX 發表在 痞客邦 留言(0) 人氣()

下載Google影片中的字幕,並轉成srt

用SubtitleWorkshop 修正字幕無法對應

1.取得正確對應的英文字幕
2.用SubtitleWorkshop 開啟中文字幕
3.按Ctrl+B
4.將中文字幕的第一行和最後一行對改成和英文版一樣

 

 

MP3剪輯工具  mp3DirectCut 2.21
檔案大小:200KB (免安裝版)
可刪除中間片段:選取段落後按Ctrl+X(剪下)

Scan Setting

掃描後,如果正面出現陰影髒汙很嚴重,可用背面掃描再掃一次正面(第一頁朝上擺放)
但是掃描的順序需要用MyRename重新更改,先將檔名由大到小排序,再更改為奇數跳頁
因為更改時會出現檔名重複無法更改的問題,所以位數要設為3 (Scan0001=>Scan001)

HP Printer 掃描Double A B4 

1.200dpi 
2.jpg
3.掃描設定

丹青文件管理 設定

scan_setting.png

寒冰霸權更新到1.27a後 ,出現遺失MSVCR120.dll的問題

Visual Studio 2013 的 Visual C++ 可轉散發套件

PotPlayer 1.6 影片雙開字幕

word打勾符號

 

FLAC ,APE ,MP3 轉檔 (XRECODE)

MP3 LAME

CUE Edit

  TRACK 01 AUDIO     ------------------------  音軌序號01
       INDEX 01 00:00:00    -------------------  第一首的開始時間, 格式 00(分):00(秒):00(百分秒)
  TRACK 02 AUDIO     ------------------------  音軌序號02
        INDEX 00 04:55:00    ------------------- 上一首歌結束的時間
        INDEX 01 04:56:00    ------------------- 這首歌開始的時間

 

 

adminX 發表在 痞客邦 留言(0) 人氣()

1 23