KZKY memo

自分用メモ.

linux コマンド一言メモ.

  • truncate
    • ファイルのサイズを縮小、拡大
  • lsof
    • すべてのオープンファイルを表示
  • lshw
    • ハードウェアの情報を表示
  • lspci
    • PCI buses の情報とそれらにくっついているデバイス情報を表示
  • strings
    • プリントできる文字列(少なくとも4字)取り出す 
  • openssl
    • e.g. openssl s_client -connect ip-addr -state (443port のチェック)
  • snmpwalk
    • MIB(management information base)デーブルの情報を取得
  • rpcinfo
    • remote call procedure
  • showmount
    • nfs のマウント チェック
  • cannastat
    • canna サービス チェック
  • netcat(nc)
    • 特定のポートをリッスンさせることが可能なツール
  • last
    • ログイン履歴 (/var/log/wtmp) を表示
  • lastlog
    • 最終的にログインした履歴を表示
  • lastb
    • bad ログイン履歴(/var/log/btmp)を表示
  • w
    • 現在のログインユーザの情報(var/log/utmp を表示)
  • stat
    • ファイル,ディレクトリの状態のチェック
  • ls いろいろ
  • atimeを表示
$ ls -lu
  • mtimeを表示
$ ls -l
  • ctimeを表示
$ ls -lc
  • ls *(@)
    • 属性指定 e.g. (X), (/), (r|w|x), (U), (u[usr_name]),(^):否定(zshのみ)
  • mac-robber
    • MACタイムの取得
  • mactime
    • mac-robberで作成したMACタイムの解析
  • cksum
    • the same as the above
  • sha1sum
    • the same as the above
  • grep -v
    • inverted output
  • sed -e '/pattern/d'
    • delete lines in which pattern appers, and show the other lines
  • perl -p -e "s/xxx/yyy/g" filename
    • a counterpart of sed
  • sed -e 's/pattern/replacement/g'
  • sed -e '行番号s/パターン1/パターン2/'
  • sed -e '開始行,終了行s/パターン1/パターン2/'
    • 1 : 1行目のみ
    • 1,10 : 1~10行目
    • 2,$ : 2~最終行
    • 1,/^l/ : 1行目~l で始まる行まで
    • /^l/ : l で始まる行だけ
    • ! : 否定
  • sed -n 10,15p
    • output 10~15 line
  • whois
    • domain 情報の問い合わせ whois -h whois.jp keio.ac.jp (43 port (JPNICハンドルでも検索可能))
  • pstree
    • display tree of processes ( -ap option often used )
  • tree
    • display directories and files tree from current directory
  • vmstat
    • vertual memory stats (-d でdisk status), information about processe, memory, paging, block, IO, traps, disk, cpu
  • vmstat 5 2
    • 5秒間各で2回チェック
  • mpstat -P ALL
    • processor stats
  • iostat
    • hd, cpu の状態を表示
  • netstat -tan
    • tcp, all, numeric
  • renice n_priority -p n_process
    • nice値の変更 (-20~19: high <- low) (ps l でみれるNIと表示される )
  • paste
    • 行単位でマージを行う
  • cut
    • 各行から選択した部分を取り出す
  • cut -c10-15
    • character base
  • cut -d: -f4 /etc/passwd
  • sort sample.txt | uniq
  • sort sample.txt | unqi -c
    • count duplicate word
  • uniqで積集合
$ cat f1 f2 | sort | uniq -d
  • uniqで和集合
$ cat f1 f2 | sort | uniq
  • uniqで差集合
$ cat f1 f2 | sort | uniq -u 
  • tr -d abd
    • delete a character abd
  • du -s path
    • path以下にあるファイル、ディレクトリの容量
  • mkisofs
    • iso fileの作成
  • cdrecord -v -dev=(/dev/xxx(dmesg で調べる)) -speed=2 -data (yyy.iso) (-dummy (for test))
    • iso file をCDに焼く
  • showmount
    • show mount information for NFS server
  • usermod
    • user info の変更 (-u, -g: userid, groupid respectively)
  • usermod -G wheel user_name
    • user_nameをwheelに追加
  • ifconfig mtu 1452
    • mtu の変更
  • telinit runlevel
    • runlevelの変更
  • echo aaa > /dev/tty_n
    • tty_nにaaaと入力
  • paste -d deliminator file_1 file_2 ...
    • ファイルを行単位で結合
  • split -l 500 -d file_name prefix_name
    • ファイルを-l 行ごとにnumeric suffixで分割
  • cat -n fname
    • 行番号をつけて表示
  • nl filename
    • ラインナンバを付け加えてファイルを表示
  • od -c filename
    • dump files in ocatal and other format
  • od -vAn -N4 -tu4 < /dev/urandom
    • 乱数の表示
  • echo $RANDOM
    • 0 ~ 32767の乱数
  • mkpasswd
    • ランダムな文字列を生成する
  • xfontsel
    • フォント結合して表示するグラフィカルプログラム
  • fc-list
    • list available fonts for applications
  • rename hoge hogehoge hoge*
    • hoge*のhoge をhogehogeにする
  • free
    • cat /proc/meminfo の簡易版.メモリとスワップのみ表示
  • ulimit
    • プロセス数、オープンファイル数、コアダンプのサイズの上限を見たり、設定したり
  • stty
    • termial line settingsの変更と確認
  • kdb
    • kernel debuger
  • ld
    • gcc, g++, ccの最後にオブジェクトファイル、アーカイブデータのリンクに使われる
  • strace
    • system call and signal trace
  • ltrace
    • library trace
  • ptrace
    • process trace
  • rm *~filename
    • filename 以外のファイルを削除する(~以降は補完が効かない)(zsh)
  • rm *~*.cc
    • *.cc 以外のすべてのファイルを削除する(zsh)
  • cpulimit -p xxx -l 50
    • process xxxのcpu使用率を50%にする(プロセスごと)
  • sh hoge.sh 2>&1 | tee fname.out
    • エラー出力もファイルに出力
  • ffmpeg
    • コマンドラインで動画編集
$ ffmpeg -ss 1 -vframes 1 -i in.flv -f image2 out.jpg
$ ffmpeg -ss 10 -vframes 50 -i 4233-1r.rm -f image2 %d.jpeg 
$ ffmpeg -i filename -f image2 %d.jpeg
  • time command
    • 実行時間を計測
  • at [options] time
    • 指定した時刻にコマンドを1度実行する
  • ipcs
    • provides information on the ipc facilities
  • mktexlsr
  • kill -l
    • SIGxxxのxxxのリストを表示
  • kill -17(SIGCHLD) zp_id
    • zombieプロセスの終了
    • だめならば、親を終了させる
    • initが親になるので、waitを定期的に実行しているinitがゾンビプロセスを刈り取る
  • fdisk
    • partition table の操作
  • fuser -muv file
    • fileを開いているユーザプロセスの表示
  • crash
    • kernel coredump の解析, 動作中カーネルの解析 (live system)
  • nm
    • list symbols from object files
  • chroot newroot [command, ...]
    • newroot をroot にして、プログラムを実行, 一種のjail
  • jail newroot host-name ip-addr ...
  • id
    • uidとidの表示
  • hexdump
    • 16進数ダンプ.odでも同じようなことができる
  • ldd
    • print shared library dependencies
  • whereis
    • コマンドとmanページがどこにあるのかを表示.
$ whereis ls
  • manpath
    • manual が置かれているディレクトリを表示
  • ibus-setup
    • ubuntsuでIMEのセットアップ画面を機動. dashboardから検索でも可
  • zathura
    • 軽量pdf viewer
  • aspell
    • texのspell checker
$ aspell --lang=en -c filename.tex
  • curl
    • wgetみたいなもの.Mac ではcurlコマンドを使用
  • watch
    • 一定間隔(second)でコマンドを実行.
$ watch -n 5 "ls ./ | tail"