38 KiB
ð ÄeÅ¡tina â English â Español â Italiano â æ¥æ¬èª â íêµìŽ â Português â Ð ÑÑÑкОй â SlovenÅ¡Äina â УкÑаÑÐœÑÑка â äžæ â ç¹é«äžæ
åæã®ã³ããã ee4b00bc396087d27231f60512aeb77b19ce734e
The Art of Command Line
- ã¡ã¿æ å ±
- åºæ¬
- æ¥åžžçã«äœ¿ããã®
- ãã¡ã€ã«ãšããŒã¿ã®åŠç
- ã·ã¹ãã ã®ãããã°
- ã¯ã³ã©ã€ããŒ
- ç®ç«ããªãã䟿å©ãªãã®
- OS Xçšã®ãã®
- ãããªããªãœãŒã¹
- å 責äºé
ã³ãã³ãã©ã€ã³ã§æµããããã«æäœãã§ãããšããããšã¯ã軜ãèŠããããä»äººããç解ãããªãã¹ãã«ã ãšã¿ãªãããããšãããã ãããããããã®ã¹ãã«ã¯ãæããã«ãããåãããããã¯åããããšã³ãžãã¢ãšããŠã®ããªãã®æè»æ§ãçç£æ§ãæ¹åããŠããããã®ã ãããã§ã¯ãLinuxã§ã³ãã³ãã©ã€ã³ã䜿ãäžã§äŸ¿å©ã ãšæã£ãã¡ã¢ãTipsã®æ°ã ãæããŠã¿ãããããã®ã¯åºç€çã ããéåžžã«è©³ãããã®ãæŽç·Žããããã®ãææ§ãªãã®ãããããã®ããŒãžã¯ãããªã«é·ããã®ã§ã¯ãªãããããã«æžããŠããããšã®å šãŠã䜿ã£ããæãåºãããšãã§ããã°ãããªã詳ãããªããã ããã
ãã®ããã¥ã¡ã³ãã¯å€ãã®å·çè ãšç¿»èš³è ã«ããææã§ãããããã«æžããŠããããšã®å€ãã¯ãå ã Quoraã«æžãããŠãããã®ãå€ãããããåªãã人ãã¡ãããã«æ¹åæ¡ãåºãããšãã§ããGitHubã«çœ®ãã®ãããã®ã§ã¯ãšæã£ããééãããã£ãšããããæ¹ããããšããç¹ãããã°ãissueãç»é²ãããpull requestãéã£ãŠã»ããïŒ(ãã¡ãããã¡ã¿æ å ±ã®é ãæ¢åã®pull requestsãissuesããŸã確èªããã)
ã¡ã¿æ å ±
察象 :
- ãã®ã¬ã€ãã¯ãåå¿è åãã§ãçµéšè åãã§ããããå¹ åºã(æžããŠããããšã¯å šãŠéèŠ)ããã€æ確ã§(å€ãã®ã±ãŒã¹ã«å¯ŸããŠå ·äœçãªäŸãä»ãã)ããããŠç°¡æœ(ä»ã®å Žæã§èŠã€ãããããããªéèŠã§ãªãããšãè±ç·ããããšã¯çã)ã§ããããšããŽãŒã«ã«ããŠãããåé ç®ã¯ãå€ãã®å Žé¢ã«ãããŠå¿ é ã§ããããä»ã®æ¹æ³ã«æ¯ã¹ãŠåçã«æéãç¯çŽããŠãããã ããã
- OS Xçšã®ãã®ãé€ããLinuxåãã®å 容ãšãªã£ãŠããããã®å€ãã¯åçš®Linuxããã³MacOS(ãããã¯Cygwin)ã§ã䜿ããã ããã
- ã€ã³ã¿ã©ã¯ãã£ããªBashã䜿ãããšãæ³å®ããŠããããå€ãã®é ç®ã¯ä»ã®ã·ã§ã«ãBashã®ã¹ã¯ãªããã§ã䜿ããã ããã
泚æ :
- 1ããŒãžå
ã«åããããã«ãå
容ã«ã¯æé»çã«æžãããŠããããšããããããã§åãããããç¥ã£ããã³ãã³ããåããã°ã詳现ãã©ããã§èª¿ã¹ãããããããã¯ã§ããã ãããæ°ããããã°ã©ã ãã€ã³ã¹ããŒã«ããã«ã¯ã
apt-get
/yum
/dnf
/pacman
/pip
/brew
(ã©ããé©ãããã®)ã䜿ããã - ã³ãã³ãããªãã·ã§ã³ããã€ããå解ããŠç解ããæå©ãã«ãExplainshellã䜿ããã
åºæ¬
-
åºæ¬çãªBashãåŠãŒããå®éã®ãšããã
man bash
ã¯çµæ§ç°¡åã«ç解ã§ããããããªã«é·ããªãã®ã§ãããã§äžéãã®ããšã¯åããããã以å€ã®ã·ã§ã«ãããããBashã¯åŒ·åã ããåžžã«äœ¿çšå¯èœã§ãããšããå©ç¹ããã(èªåã®PCã«å ¥ããŠããŸã£ããšèšã£ãŠzshãfishãªã©ã ããåŠãã§ããŸããšãæ¢åã®ãµãŒãã觊ããªããŠã¯ãªããªãæãªã©ã«å¶çŽãåºãŠããŸã)ã -
ããã¹ããšãã£ã¿ã®ã©ããæäœ1ã€ã«ç¿çããããã¿ãŒããã«å ã§é©åœã«ãã®ãæžãã«ããã£ãŠä»ã«å šã代æ¿åããªããšããç¹ã§ãçæ³çã«ã¯Vim(
vi
)ãããã ãã(éåžžã¯Emacsãé«æ©èœãªIDEãææ°ã®ãã£ããããšãã£ã¿ãã¡ã€ã³ã«äœ¿ã£ãŠãããšããŠã)ã -
man
ã§ã®ããã¥ã¡ã³ãã®èªã¿æ¹ãç¥ãã(ç¥ããããã®ããã«æžããšãman man
ã§ã»ã¯ã·ã§ã³çªå·ãåãããäŸãã°1ã¯ãäžè¬çãªãã³ãã³ãã5ã¯ãã¡ã€ã«ããã®ãäœæ³ã8ã¯ç®¡çã«ã€ããŠãšãã£ãå ·å)ãapropos
ã§manããŒãžãæ¢ãããã³ãã³ãã«ãã£ãŠã¯å®è¡å¯èœãã¡ã€ã«ã§ã¯ãªãBashã®ãã«ãã€ã³ã³ãã³ãã§ããããšãç解ããhelp
ãhelp -d
ã§ãã«ããèŠãããããšãç¥ããã -
>
ã<
ã|
ã䜿ã£ããã€ãã«ããå ¥åºåã®ãªãã€ã¬ã¯ã·ã§ã³ãåŠãŒãã>
ã¯åºåãã¡ã€ã«ãäžæžãã>>
ã¯è¿œèšãšãªããstdout(æšæºåºå)ãšstderr(æšæºãšã©ãŒåºå)ãåŠãŒãã -
*
(ãŸãã¯?
ã[
...]
)ã䜿ã£ããã¡ã€ã«ã°ããå±éãã¯ã©ãŒããŒã·ã§ã³ãããã«ã¯ã©ãŒã"
ãšã·ã³ã°ã«ã¯ã©ãŒã'
ã®éããåŠãŒã(詳ããã¯ãã®åŸã®å€æ°å±éã®é ãåç §)ã -
&
ãctrl-zãctrl-cãjobs
ãfg
ãbg
ãkill
ãªã©ãBashã®ãžã§ã管çã«ã€ããŠè©³ãããªããã -
ssh
ã«ã€ããŠç¥ããšãšãã«ãssh-agent
ãssh-add
ã䜿ã£ããã¹ã¯ãŒããªãã®èªèšŒã®åºæ¬ã«ã€ããŠç解ãããã -
ãã¡ã€ã«ç®¡çã«ã€ããŠã
ls
ãls -l
(ç¹ã«ãls -l
ã®ååãäœãæå³ãããç解)ãless
ãhead
ãtail
ãtail -f
(ãŸãã¯less +F
)ãln
ãšln -s
(ããŒããªã³ã¯ãšãœãããªã³ã¯ã®éããšããããã®å©ç¹ã®ç解)ãchown
ãšchmod
ãdu
(ãã£ã¹ã¯äœ¿çšéãŸãšããç°¡åã«èŠããªãdu -hs *
)ããã¡ã€ã«ã·ã¹ãã 管çã«ã€ããŠã¯ãdf
ãmount
ãfdisk
ãmkfs
ãlsblk
ãinodeã«ã€ããŠã¯ãls -i
(ãŸãã¯df -i
)ã -
åºæ¬çãªãããã¯ãŒã¯ç®¡çã«ã€ããŠã
ip
ãããã¯ifconfig
ãdig
ã -
æ£èŠè¡šçŸã«ã€ããŠè©³ããç¥ããã
grep
ãegrep
ã®è²ã ãªãã©ã°ãåãããŠã-i
ã-o
ã-v
ã-A
ã-B
ã-C
ãšãã£ããªãã·ã§ã³ã¯ç¥ã£ãŠãããŠæã¯ãªãã -
apt-get
ãyum
ãdnf
ãpacman
(ãã£ã¹ããªãã¥ãŒã·ã§ã³ã«ãã£ãŠéã)ãšãã£ãã³ãã³ãã§ããã±ãŒãžãæ¢ãããã€ã³ã¹ããŒã«ããæ¹æ³ãåŠãŒããPythonããŒã¹ã®ã³ãã³ãã©ã€ã³ããŒã«ãã€ã³ã¹ããŒã«ããã®ã«ãpip
ãå¿ èŠã (åŸã«åºãŠããããã€ãã®ã³ãã³ãã¯pip
ã§ã€ã³ã¹ããŒã«ããã®ãäžçªç°¡å)ã
æ¥åžžçã«äœ¿ããã®
-
Bashã§ã¯ãåŒæ°ãè£å®ããŸãã¯å©çšå¯èœãªã³ãã³ããåæããã®ã«ã¿ãã䜿ããã³ãã³ãå±¥æŽããæ€çŽ¢ããã®ã«ctrl-rã䜿ãã(æ€çŽ¢ããŒãå ¥åããåŸãctrl-rãç¹°ãè¿ãå ¥åããããšã§æ¬¡ãã次ãžãšæ€çŽ¢çµæãéãããšãã§ãããEnterã§èŠã€ãã£ãã³ãã³ãã®å®è¡ãšãªããEnterã§ã¯ãªãå³ã«ãŒãœã«ããŒãæŒããå Žåã¯èŠã€ãã£ãã³ãã³ããå ¥åãããç¶æ ã«ãªãã)
-
Bashã§ã¯ãæåŸã®åèªãåé€ããã®ã«ã¯ctrl-wãè¡é ãŸã§å šãŠåé€ããã«ã¯ctrl-uã䜿ããåèªããšã«ç§»åããã«ã¯alt-bãŸãã¯alt-fãè¡é ã«ç§»åããã«ã¯ctrl-aãè¡æ«ã«ç§»åããã«ã¯ctrl-eãè¡æ«ãŸã§åé€ããã«ã¯ctrl-kãç»é¢ã®ã¯ãªã¢ã¯ctrl-lã§ãããBashã«ãããããã©ã«ãã®ããŒå²ãåœãŠãå šãŠèŠãã«ã¯
man readline
ãåç §ãããããåºãŠãããäŸãã°ã**alt-.**ã¯åã®åŒæ°ãé çªã«è¡šç€ºãã**alt-***ã¯ã°ãããå±éããã -
vi颚ã®ããŒå²ãåœãŠã奜ããªãã
set -o vi
ãå®è¡ãããã(å ã«æ»ããããšãã¯set -o emacs
) -
é·ãã³ãã³ããç·šéãããšãã«ããšãã£ã¿ãèšå®ããåŸã§(äŸãã°
export EDITOR=vim
)ãctrl-x ctrl-eã«ãã£ãŠç·šéäžã®ã³ãã³ããè€æ°è¡ã®ç·šéã®ããã«æå®ãããšãã£ã¿ã§éããããvi颚ã®å Žåã¯ãescape-vã -
æè¿å®è¡ããã³ãã³ãã確èªãããªã
history
ãctrl-rã**alt-.**ã§çšã¯è¶³ããã ãããã!$
(çŽåã®åŒæ°)ã!!
(çŽåã®ã³ãã³ã)ãšãã£ãçç¥åœ¢ãããããããã -
åã®ã¯ãŒãã³ã°ãã£ã¬ã¯ããªã«æ»ããªã
cd -
-
éäžãŸã§ã³ãã³ããå ¥åããããã©å¿å€ããããæã¯ãalt-#ãæã€ãšè¡é ã«
#
ãæ¿å ¥ãããã³ã¡ã³ããšããŠå ¥åããã(ctrl-aã#ãenterã§ãåã)ãããã¯åŸã§ã³ãã³ãå±¥æŽããæ€çŽ¢ã§ããã -
xargs
(ãŸãã¯parallel
)ã䜿ãããéåžžã«åŒ·åãè¡ããšã«ããã€ã®ã¢ã€ãã ãå®è¡ããã(-L
)ãã䞊å床(-P
)ãå¶åŸ¡ã§ãããæ£ããå®è¡ããããå®ãã§ãªããªãããŸãxargs echo
ããŠã¿ãã°ããã-I{}
ã䟿å©ãäŸãã°ä»¥äžã®éãã
find . -name '*.py' | xargs grep some_function
cat hosts | xargs -I{} ssh root@{} hostname
-
pstree -p
ã¯ããã»ã¹ããªãŒã衚瀺ããã®ã«äŸ¿å©ã -
pgrep
ãpkill
ã§ãããã»ã¹åã§æ€çŽ¢ãããã·ã°ãã«ãéãã(-f
ã䟿å©)ã -
ããã»ã¹ã«éããè²ã ãªã·ã°ãã«ãç¥ã£ãŠããããäŸãã°ãããã»ã¹ããµã¹ãã³ãããã«ã¯
kill -STOP [pid]
ã䜿ããå šçš®é¡èŠããªããman 7 signal
ã -
ããã¯ã°ã©ãŠã³ãããã»ã¹ããã£ãšå®è¡ãç¶ããããªã
nohup
ãããã¯disown
ã䜿ããã -
netstat -lntp
ãss -plat
ã§ãã©ããªããã»ã¹ããªãã¹ã³ããŠããã確èªããã(UDPãªã-u
ãä»ãã)ã -
éãããŠãããœã±ããããã¡ã€ã«ãèŠãã«ã¯
lsof
ãåç §ã -
uptime
ãw
ã«ãã£ãŠã·ã¹ãã ã®çšŒåæéã調ã¹ãããã -
alias
ã«ãã£ãŠããå©çšããã³ãã³ãã®ãšã€ãªã¢ã¹(ã·ã§ãŒãã«ãã)ãäœæã§ãããäŸãã°ãalias ll='ls -latr'
ã§ã¯æ°ãããšã€ãªã¢ã¹ã§ããll
ãäœæããã. -
Bashã¹ã¯ãªããã§ã¯ã
set -x
ã§ãããã°åºåãåºãã(set -v
ã¯ãå®è¡ãããã³ãã³ããå€æ°åãã³ã¡ã³ããªã©ããã®ãŸãŸåºåãã)ãç¹å¥ãªçç±ããªãéãå³æ Œã¢ãŒã(strict mode)ã䜿ããset -e
ã§ãšã©ãŒæ(0以å€ã®çµäºã³ãŒãæ)ã«åŒ·å¶çµäºããããã«ãset -u
ã«ãã£ãŠæªå®çŸ©ã®å€æ°ã®å©çšãæ€ç¥ããã€ãã®ãšã©ãŒãå³æ Œã«æ±ãããã«set -o pipefail
ã䜿ãã(ããã¯ã¡ãã£ãšåŸ®åŠãã)ãããè€éãªã¹ã¯ãªãããªããEXITãŸãã¯ERRã·ã°ãã«ã«å¯ŸããŠtrap
ã䜿ããã䜿ãå Žé¢ãšããŠã¯ä»¥äžã®å Žåã®ããã«ãšã©ãŒãæ€ç¥ããŠã¡ãã»ãŒãžãåºåãããšã:
set -euo pipefail
trap "echo 'error: Script failed: see failed command above'" ERR
- Bashã¹ã¯ãªããã§ã¯ãã³ãã³ãã®ã°ã«ãŒããäœãã®ã«ãµãã·ã§ã«(äžžæ¬åŒ§ã§å²ãŸããéšå)ã䟿å©ãäžæçã«ã¯ãŒãã³ã°ãã£ã¬ã¯ããªã移åãããšããããããäŸã
# ã«ã¬ã³ããã£ã¬ã¯ããªã§äœãå®è¡
(cd /some/other/dir && other-command)
# å
ã®ãã£ã¬ã¯ããªã§äœæ¥ç¶è¡
-
Bashã§ã¯ãããããã®å€æ°å±éã®çš®é¡ãããããšãèŠããŠããããå€æ°ãååšããããã§ãã¯ãããªãã
${name:?error message}
ãäŸãã°ãBashã¹ã¯ãªããã1ã€ã®åŒæ°ãåãå¿ èŠããããªããinput_file=${1:?usage: $0 input_file}
ãšã ãæžãã°ãããç®è¡åŒã®å±éã¯ãi=$(( (i + 1) % 5 ))
ãã·ãŒã±ã³ã¹ã¯{1..10}
ãæååã®ããªãã³ã°ã¯${var%suffix}
ãš${var#prefix}
ãäŸãã°var=foo.pdf
ã®æãecho ${var%.pdf}.txt
ãšãããšfoo.txt
ãåºåã«ã -
{
...}
ã䜿ã£ãäžæ¬åŒ§å±éã«ãã£ãŠã䌌ããããªã³ãã³ããè€æ°åå ¥åããªããŠæžããäŸãã°ãmv foo.{txt,pdf} some-dir
(äž¡æ¹ã®ãã¡ã€ã«ã移åããã),cp somefile{,.bak}
(cp somefile somefile.bak
ãšå±éããã)ãmkdir -p test-{a,b,c}/subtest-{1,2,3}
(ãã¹ãŠã®å¯èœãªçµã¿åããã§ãã£ã¬ã¯ããªãäœããã). -
ã³ãã³ãã®åºåã
<(some command)
ã®ããã«ããŠãã¡ã€ã«ã®ããã«æ±ãããäŸãã°ãããŒã«ã«ãšãªã¢ãŒãã®ã®/etc/hosts
ãæ¯èŒãããªã以äžã®ããã«ãªãã
diff /etc/hosts <(ssh somehost cat /etc/hosts)
-
cat <<EOF ...
ã®ãããªãBashã®ããã¢ããã¥ã¡ã³ãããç解ãããã -
Bashã§ã¯ã
some-command >logfile 2>&1
ãŸãã¯some-command &>logfile
ã§æšæºåºåãšæšæºãšã©ãŒåºåã®äž¡æ¹ããªãã€ã¬ã¯ãã§ãããã³ãã³ããæšæºå ¥åã«å¯ŸããŠãã¡ã€ã«ãã³ãã«ãéãã£ã±ãªãã«ããããã°ã€ã³ããŠããã¿ãŒããã«ã«ã²ãã¥ããŠããããã</dev/null
ããã®ãããç¿æ £ã -
16é²ãš10é²ã®ASCIIããŒãã«ãèŠãã®ã«
man ascii
ã䜿ãããäžè¬çãªãšã³ã³ãŒãã«é¢ããæ å ±ã¯ãman unicode
ãman utf-8
ãman latin1
ã䟿å©ã -
ã¹ã¯ãªãŒã³ã®åå²ã«
screen
ãtmux
ã䜿ãããç¹ã«ããªã¢ãŒãã®SSHã»ãã·ã§ã³ããã¿ãããããã¢ã¿ãããçŽãããããã®ã«æå¹ãbyobu
ã¯screenãtmuxã®æ å ±ãããå€ãæäŸããŠããã管çã容æã«ãªããã»ãã·ã§ã³æ°žç¶åã ãã®ç°¡åãªãã®ãªãdtach
ã -
SSHã§
-L
ãããã¯-D
(ãŸãã«-R
)ã䜿ã£ãããŒããã³ãã«ã®ããæ¹ãèŠããŠãããšäŸ¿å©ãäŸãã°ãªã¢ãŒãã®ãµãŒããããŠã§ããµã€ãã«ã¢ã¯ã»ã¹ããæãªã©ã -
SSHã®èšå®ãå°ãã§ãæé©åããŠãããšäŸ¿å©ãäŸãã°ä»¥äžã®èšå®ã ãšããããã¯ãŒã¯ç°å¢ã«ããæ¥ç¶æãåé¿ããå§çž®ã䜿çšã(垯åã®çŽ°ãåç·ã䜿ã£ãscpãªã©ã§äŸ¿å©)ãããŒã«ã«ã®å¶åŸ¡ãã¡ã€ã«ãæå®ããŠåäžãµãŒããšã®ãã£ãã«ãå€éåããã
TCPKeepAlive=yes
ServerAliveInterval=15
ServerAliveCountMax=6
Compression=yes
ControlMaster auto
ControlPath /tmp/%r@%h:%p
ControlPersist yes
-
ãã以å€ã®SSHãªãã·ã§ã³ã¯ã»ãã¥ãªãã£äžã®åé¡ãããå¯èœæ§ããããããæå¹ã«ããã«ã¯ããµããããããšããã¹ãããšã«æå®ããããä¿¡é Œã§ãããããã¯ãŒã¯å ã§ã®ã¿äœ¿çšãããªã©æ³šæãå¿ èŠã
StrictHostKeyChecking=no
ãForwardAgent=yes
ãªã©ã -
mosh
ã¯UDPã䜿ã£ãsshã®ä»£æ¿ã§ã(ãµãŒããŒåŽã§ã®èšå®ã¯å¿ èŠã§ããã) æç¶çãªæ¥ç¶æã«äŸ¿å©ã -
8é²æ°è¡šçŸã®ãã¡ã€ã«ããŒããã·ã§ã³ã¯ãã·ã¹ãã èšå®ã®éã«äŸ¿å©ã ã
ls
ã®çµæã«ãåºãŠãããééããããã以äžã®ããã«ããŠååŸã§ããã
stat -c '%A %a %n' /etc/timezone
-
äœããã®ã³ãã³ãã®åºåãããã€ã³ã¿ã©ã¯ãã£ãã«å€ãéžæãããå Žåã¯ã
percol
ãŸãã¯fzf
ã䜿ããã -
(gitã䜿ããªã©)äœããã®ã³ãã³ãã®åºåãããã¡ã€ã«ã«é¢ããããåããããå Žåã¯ã
fpp
(PathPicker)ã䜿ããã -
ã«ã¬ã³ããã£ã¬ã¯ããª(ãšãµããã£ã¬ã¯ããª)å šäœãããããã¯ãŒã¯å ã«å ¬éãããWebãµãŒãã«ãããªãã
python -m SimpleHTTPServer 7777
(ããŒã7777ã§å ¬éãPython 2ã®å Žå)ãããã¯python -m http.server 7777
(Python 3ã®å Žå)ã -
ç¹æš©ã¬ãã«ã§ã³ãã³ããå®è¡ãããšããrootã§ã®å®è¡ã«ã¯
sudo
ãä»ã®ãŠãŒã¶ã®å Žåã¯sudo -u
ãå©çšãsu
ãŸãã¯sudo bash
ã§ãã·ã§ã«ããã®ãŠãŒã¶ã§èµ·åãããsu -
ã§rootãŸãã¯ä»ã®ãŠãŒã¶ã§æ°ãã«ãã°ã€ã³ããç¶æ ãã·ãã¥ã¬ãŒããããã
ãã¡ã€ã«ãšããŒã¿ã®åŠç
-
ã«ã¬ã³ããã£ã¬ã¯ããªä»¥äžã®ãã¡ã€ã«ããã¡ã€ã«åã§æ¢ããããªãã
find . -iname '*something*'
ãå Žæãæå®ããã«ãã¡ã€ã«åã§æ€çŽ¢ããããªããlocate something
ãã€ããã(ãã ãupdatedb
ã¯æè¿äœããããã¡ã€ã«ã¯ã€ã³ããã¯ã¹ããŠããªãã§ãããããšã«æ³šæ)ã -
ãœãŒã¹ãããŒã¿ãã¡ã€ã«ã®(
grep -r
ãããé«åºŠãª)äžè¬çãªæ€çŽ¢ã«ã¯ãag
ã䜿ããã -
HTMLãããã¹ãã«å€æãããªãã
lynx -dump -stdin
ã -
MarkdownãHTMLãªã©æ§ã ãªçš®é¡ã®ããã¥ã¡ã³ãã®å€æã«ã¯ã
pandoc
ãè©ŠããŠã¿ããšããã -
XMLãæ±ããªããŠã¯ãªããªããªãã
xmlstartlet
ã¯å€ããããããŒã«ã ã -
JSONã«ã¯
jq
ã䜿ããã -
YAMLã«ã¯
shyaml
ãã -
ExcelãCSVãã¡ã€ã«ã«ã¯ãcsvkitã§
in2csv
ãcsvcut
ãcsvjoin
ãcsvgrep
ãªã©ã䜿ããããã«ãªãã -
Amazon S3ã«ã¯ã
s3cmd
ã䟿å©ã§ãs4cmd
ã¯ããã«é«éãAWSé¢é£ã®åŠçã«ã¯Amazonå ¬åŒã®aws
ãšæ¹åçã®saws
ãæ¬ ãããªãã -
sort
ãuniq
ãããã«uniqã®-u
ã-d
ãªãã·ã§ã³ãç¥ã£ãŠããããåŸã«åºãŠããã¯ã³ã©ã€ããŒãåç §ãcomm
ã確èªããŠãããã -
è€æ°ã®ããã¹ããã¡ã€ã«ãæäœããã®ã«ã¯ã
cut
ãšpaste
ãjoin
ã¯ç¥ã£ãŠããããcut
ã¯ã¿ããªäœ¿ã£ãŠããããjoin
ã¯å¿ããããŠããã -
wc
ãç解ããæ¹è¡(-l
)ãæå(-m
)ãåèª(-w
)ããã€ã(-c
)ããããã®æ°ãæ¹ãç¥ã£ãŠãããã -
æšæºå ¥åããã¡ã€ã«ãšæšæºåºåã®äž¡æ¹ã«åºã
tee
ãç解ããããls -al | tee file.txt
ã®ããã«äœ¿ãã -
ãã±ãŒã«ã¯ããœãŒãã®é åº(ç §åé åº)ãããã©ãŒãã³ã¹ãªã©ãããããã®ã³ãã³ãã©ã€ã³ããŒã«ã«åŸ®åŠãªãšããã§åœ±é¿ããããšãèŠããŠããããå€ãã®Linuxãã£ã¹ããªãã¥ãŒã·ã§ã³ã§ã¯ã
LANG
ãä»ã®ãã±ãŒã«å€æ°ã¯US Englishã®ãããªããŒã«ã«ãªèšå®ã«ãªã£ãŠããããã±ãŒã«ãå€æŽãããšãœãŒãé åºãå€ããããšã«æ³šæãããããŸããåœéå(i18n)察å¿ã®ã«ãŒãã³ã¯ãœãŒãããã®ä»ã®åŠçãäœåãé ãå®è¡ããããã«ãªãç¹ãç¥ã£ãŠããããå Žå(èšå®ã®åŠçãäžææ§ãèŠã€ããåŠçãªã©)ã«ãã£ãŠã¯ãexport LC_ALL=C
ãšããŠããŸãé ãi18n察å¿ã®åŠçãå®å šã«ç¡èŠããŠããŸãããšãå¯èœã ã -
åçŽãªããŒã¿å å·¥ã®ããã«
awk
ãšsed
ã®åºç€ã身ã«ã€ããããäŸãã°ãããã¹ããã¡ã€ã«ã®3ã«ã©ã ç®ã®åèšãåºããªããawk '{ x += $3 } END { print x }'
ãããã¯ãPythonã§åãããšããããã3åéããã€3åã®1ã®é·ãã§æžããã -
1ã€ãããã¯è€æ°ã®ãã¡ã€ã«å ã®æååãçŽæ¥çœ®ãæããŠããŸãã«ã¯ã
perl -pi.bak -e 's/old-string/new-string/g' my-files-*.txt
- è€æ°ã®ãã¡ã€ã«åã®å€æŽããã¡ã€ã«å
ã®æ€çŽ¢ã眮æã«ã¯ã
repren
ã䜿ã£ãŠã¿ããã(å Žåã«ãã£ãŠã¯rename
ã³ãã³ãã§ãè€æ°ã®ãã¡ã€ã«åå€æŽãã§ãããããã¹ãŠã®Linuxãã£ã¹ããªãã¥ãŒã·ã§ã³ã§æåãåãã§ããããã§ã¯ãªãã®ã§æ³šæãå¿ èŠã)
# foo -> barãžãšãã¡ã€ã«åããã£ã¬ã¯ããªåããã¡ã€ã«ã®äžèº«ãå€æŽãã:
repren --full --preserve-case --from foo --to bar .
# ããã¯ã¢ãããã¡ã€ã«ãå
ã«æ»ã whatever.bak -> whatever:
repren --renames --from '(.*)\.bak' --to '\1' *.bak
# äžèšãšåããã®ãrenameã䜿ã£ãŠ:
rename 's/\.bak$//' *.bak
- ããã¥ã¢ã«ããŒãžã«ããããã«
rsync
ã¯éåžžã«é«éã§äžèœãªãã¡ã€ã«ã³ããŒã®éå ·ã§ããããã·ãŒã³éã®ãã¡ã€ã«ãåæãããããšã§ããç¥ãããŠããããããŒã«ã«ã®å Žåã§ãåæ§ã«æçšã§ããããŸãã倧éã®ãã¡ã€ã«ãåé€ããé«éãªæ¹æ³ãšããŠãå©çšã§ãã:
mkdir empty && rsync -r --delete empty/ some-dir && rmdir some-dir
-
ãã¡ã€ã«ããã©ã³ãã ãªè¡ãæãåºãã«ã¯
shuf
-
sort
ã®ãªãã·ã§ã³ãç解ããããæ°å€ã«å¯ŸããŠã¯-n
ã䜿ãã人éã«ãšã£ãŠèªã¿ããã圢åŒã®æ°å€ã®å Žå(äŸãã°ãdu -h
ã®åºå)ã¯-h
ã䜿ãããããŒãã©ã®ããã«åŠçãããã®ã(-t
ã-k
)ãç¥ãããç¹ã«ãæåã®åã ãã§ãœãŒãããã«ã¯-k1,1
ãšæžãå¿ èŠãããã-k1
ã ãšå šè¡ãèŠãŠãœãŒãããããšããç¹ã«æ³šæã -
stableãª(å®å®ãã)ãœãŒã(
sort -s
)ã¯äŸ¿å©ãäŸãã°ãå§ãã«1åç®ã§ãœãŒããããããã2åç®ã§ãœãŒããããªããsort -k1,1 | sort -s -k2,2
ãšããã°ããã -
Bashã®ã³ãã³ãã©ã€ã³äžã§ã¿ããè¡šçŸããå¿ èŠãããå Žåãctrl-v **[Tab]**ãå ¥åããã
$'\t'
(ã³ãããããªãåŸè ã®æ¹ããããã)ã -
ãœãŒã¹ã³ãŒãã«ããããåœãŠãåºæ¬ã®ããŒã«ã¯
diff
ãšpatch
ãdiff
ã暪䞊ã³ã®sdiff
ã®çµ±èšæ å ±ãèŠããªãdiffstat
ãåç §ããããdiff -r
ã ãšããã£ã¬ã¯ããªå šäœã«å¯ŸããŠå®è¡ããããå€æŽç¹ã®æŠèŠãèŠããªãdiff -r tree1 tree2 | diffstat
ãvimdiff
ã§ã¯ãã¡ã€ã«ã®æ¯èŒãšç·šéãå¯èœã -
ãã€ããªãã¡ã€ã«ãªããåçŽãª16é²ãã³ããèŠãã®ã«
hd
ããã€ããªãšãã£ã¿ã«ã¯bvi
ã -
åãããã€ããªãã¡ã€ã«ã«é¢ããŠãããã¹ããæœåºããããªã
strings
(ãšgrep
ãªã©ã®çµã¿åãã)ã -
ãã€ããªã®diff(ãã«ã¿å§çž®)ãªãã
xdelta3
ã -
ããã¹ããšã³ã³ãŒãã£ã³ã°ã®å€æã¯
iconv
ã䜿ããããããã¯ããé«åºŠãªããŒã«ãšããŠuconv
ãããããã¡ãã¯Unicodeã®é«åºŠãªåŠçãå¯èœãäŸãã°ä»¥äžã®ã³ãã³ãã§ã¯å°æåã«å€æãã¢ã¯ã»ã³ãèšå·ãåãé€ã(å±éããŠããåé€)ã
uconv -f utf-8 -t utf-8 -x '::Any-Lower; ::Any-NFD; [:Nonspacing Mark:] >; ::Any-NFC; ' < input.txt > output.txt
-
ãã¡ã€ã«ãåå²ãããªã
split
(ãµã€ãºã§åå²)ãšcsplit
(ãã¿ãŒã³ã§åå²)ã -
æ¥ä»ãæéã®è¡šçŸãæ±ãã«ã¯ã
dateutils
ã«ããããã«ãdateadd
ãdatediff
ãstrptime
ãªã©ã䜿ããŸãããã -
å§çž®ãã¡ã€ã«ã®æäœã¯
zless
ãzmore
ãzcat
ãzgrep
ã
ã·ã¹ãã ã®ãããã°
-
Webã®ãããã°ãªã
curl
ãcurl -l
ã䟿å©ã§ãwget
ãåæ§ãããã¢ãã³ãªã®ã¯httpie
ã -
CPUããã£ã¹ã¯ã®ã¹ããŒã¿ã¹ãç¥ãã«ã¯ãæšæºçãªããŒã«ã¯
top
(ãŸãã¯ãããè¯ãhtop
)ãiostat
ãiotop
ãiostat -mxz 15
ã䜿ã£ãŠãåºæ¬çãªCPUã®æ å ±ãããŒãã£ãã·ã§ã³åäœã§ã®ãã£ã¹ã¯ã®è©³çŽ°æ å ±ãããã©ãŒãã³ã¹ã«ã€ããŠèª¿ã¹ãŸãããã -
ãããã¯ãŒã¯ã®ç¶æ ã®ç£èŠã«ã¯ã
netstat
ãss
ã -
ææ©ãã·ã¹ãã ã§äœãèµ·ããŠããã®ãã調ã¹ãã«ã¯ã
dstat
ã䟿å©ããã詳ããèŠãã«ã¯ãglances
ã -
ã¡ã¢ãªã®ã¹ããŒã¿ã¹ãç¥ãã«ã¯ã
free
ãããã¯vmstat
ãå®è¡ãããã®åºåã®æå³ãç解ããããç¹ã«ã"cached"ã®å€ã¯Linuxã«ãŒãã«ã«ãã¡ã€ã«ãã£ãã·ã¥ãšããŠä¿æãããŠããã¡ã¢ãªéã§ããã"free"ã®å€ãèŠãéã«èæ ®ãã¹ãã§ããããšã«æ³šæãããã -
Javaã®ã·ã¹ãã ã®ãããã°ã¯ãŸãéãå°ã£ããšãããããããOracleãããã¯ä»ã®JVMã«ãå ±éããŠããã·ã³ãã«ãªããªãã¯ã¯ã
kill -3 <pid>
ã§ãã«ã¹ã¿ãã¯ãã¬ãŒã¹ãšããŒãã®æŠèŠãæšæºåºåãããã¯ãã°ã«ãã³ãããã(äžä»£å¥GCã®è©³çŽ°ãåèçšåºŠã ãå«ãŸããŠãã)ãJDKã®jps
ãjstat
ãjstack
ãjmap
ã䟿å©ã§ãSJK toolsã¯ããé«åºŠãªããŒã«ã§ããã -
æ¹è¯çtracerouteãšããŠ
mtr
ã䜿ã£ãŠãããã¯ãŒã¯ã®åé¡ã調æ»ãããã -
ãã£ã¹ã¯ããã£ã±ãã«ãªã£ãŠããçç±ã調ã¹ãã«ã¯ã
ncdu
ã䜿ããšdu -sh *
ããæéãç¯çŽã§ããã -
垯åã䜿ã£ãŠããã®ãã©ã®ãœã±ãããããã»ã¹ãªã®ããèŠã€ããã«ã¯ã
iftop
ãããã¯nethogs
ãè©Šããã -
ab
(Apacheã«ä»å±)ã¯ãWebãµãŒãã®ããã©ãŒãã³ã¹ããã£ãããã§ãã¯ããã®ã«äŸ¿å©ãããè€éãªãã¹ãã«ã¯siege
ãè©Šããã -
ãã確å®ãªãããã¯ãŒã¯ã®ãããã°ã¯
wireshark
ãtshark
ãngrep
ã -
strace
ãšltrace
ã«ã€ããŠç¥ã£ãŠããããããã°ã©ã ã®å®è¡ã«å€±æããããã³ã°ãããã¯ã©ãã·ã¥ãããããŠããã®çç±ãåãããªãããããã¯ããã©ãŒãã³ã¹ã«é¢ããäžè¬çæ å ±ãç¥ããããªãããã®ããŒã«ã圹ç«ã€ã¯ãã ããããã¡ã€ãªã³ã°ã®ãªãã·ã§ã³(-c
)ãèµ·åäžã®ããã»ã¹ã«ã¢ã¿ããããæ©èœ(-p
)ãèŠããŠãããã -
å ±æã©ã€ãã©ãªããã§ãã¯ãããªã
ldd
ãèŠããŠãããã -
èµ·åäžã®ããã»ã¹ã«
gdb
ã§æ¥ç¶ãããã®ã¹ã¿ãã¯ãã¬ãŒã¹ãåãæ¹æ³ãç¥ããã -
/proc
以äžã®ãã¡ã€ã«ã䜿ãããä»èµ·ãã£ãŠããåé¡ããããã°ããã®ã«ã¯çŽ æŽããã䟿å©ã ãäŸãã°ã/proc/cpuinfo
ã/proc/meminfo
ã/proc/cmdline
ã/proc/xxx/cwd
ã/proc/xxx/ece
ã/proc/xxx/fd/
ã/proc/xxx/smaps
(ããã§ãxxx
ã¯ããã»ã¹IDãŸãã¯PIDãæå³ãã)ã -
éå»ã«äœãåé¡ãèµ·ããããšã®åå ãæ¢ããªãã
sar
ããšãŠã䟿å©ãCPUãã¡ã¢ãªããããã¯ãŒã¯ãªã©ã®éå»ã®çµ±èšæ å ±ãèŠãããã -
ããã«æ·±ãã·ã¹ãã ãšããã©ãŒãã³ã¹ã®åæã«ã¯ã
stap
(SystemTap)ãperf
ãsysdig
ã -
ã©ã®OSãå©çšããŠãããã
uname
ãuname -a
(Unixã«ãŒãã«æ å ±)ã§ç¢ºèªããããã©ã®ãã£ã¹ããªãã¥ãŒã·ã§ã³ã䜿ã£ãŠãããã¯lsb_release -a
(ãã£ã¹ããªãã¥ãŒã·ã§ã³æ å ±)ã -
äœããã€ããšéãããããªããš(倧æµããŒããŠã§ã¢ããã©ã€ãé¢é£ã®åé¡ã )ãèµ·ããŠãããã
dmesg
ãå®è¡ãããã
ã¯ã³ã©ã€ããŒ
ã³ãã³ãããŸãšããŠäœ¿ãäŸãããã€ãã
sort
ãuniq
ã䜿ã£ãŠããã¹ããã¡ã€ã«ã®å ±ééšåãçµåãå·®ç°ãæ±ããæã«ç¹ã«äŸ¿å©ãªã®ã以äžã®ããæ¹ãa
ãšb
ã¯ããããå 容ã«éè€ã®ãªãããã¹ããã¡ã€ã«ãšããããã®æ¹æ³ã¯é«éã§ãæ°GBçšåºŠãŸã§ã®ä»»æã®ãã¡ã€ã«ãµã€ãºã§åäœãã(/tmp
ãå°ããªã«ãŒãããŒãã£ã·ã§ã³ã«ããå Žåã¯-T
ãªãã·ã§ã³ãã€ããå¿ èŠããããããœãŒãã¯ã¡ã¢ãªå ã§è¡ããããšã¯éããªã)ãäžè¿°ã®LC_ALL
ãšsort
ã®-u
ãªãã·ã§ã³ãåç §ã®ããšã
cat a b | sort | uniq > c # cã¯aãšbã®åéå
cat a b | sort | uniq -d > c # cã¯aãšbã®å
±ééšå
cat a b b | sort | uniq -u > c # cã¯aãšbã®å·®ç°
-
grep . *
(åè¡ã«ãã¡ã€ã«åãä»ã)ããhead -100 *
(ãã¡ã€ã«æ¯ã«ããããŒãä»ã)ã䜿ã£ãŠæ軜ã«ãã£ã¬ã¯ããªå ã®å šãŠã®ãã¡ã€ã«ã®äžèº«ã確èªã§ãããèšå®ãã¡ã€ã«ãå«ãŸãããããª/sys
ã/proc
ã/etc/
ã«å¯ŸããŠéåžžã«äŸ¿å©ã§ããã -
ããã¹ããã¡ã€ã«ã®3åç®ãå šãŠè¶³ãåãããã«ã¯ä»¥äžã§(Pythonã§åãããšãããã«æ¯ã¹ãŠ3åéã3åã®1ã®é·ãã§æžãã)ã
awk '{ x += $3 } END { print x }' myfile
- ãã¡ã€ã«ããªãŒã®ãµã€ãºãããŒã¿ã確èªããããªãã以äžã¯ååž°çãª
ls -l
ãšåãã ãls -lR
ããèŠãããã
find . -type f -ls
- WebãµãŒãã®ãã°ã®ãããªããã¹ããã¡ã€ã«ããããåè¡ã«ã¯äŸãã°URLã®äžã«åºãŠãã
acct_id
ã®ãããªç¹å®ã®å€ãçŸãããšããããacct_id
ãäœåãªã¯ãšã¹ããããŠããããéèšããã«ã¯ã
cat access.log | egrep -o 'acct_id=[0-9]+' | cut -d= -f2 | sort | uniq -c | sort -rn
-
ç¶ç¶çã«å€æŽãç£èŠããå Žå
watch
ã䜿ããäŸãã°ããã£ã¬ã¯ããªã®ãã¡ã€ã«ã®å€æŽã確èªããã«ã¯watch -d -n 2 'ls -rtlh | tail'
ãšãªããwifièšå®ãªã©ã®ãããã¯ãŒã¯èšå®é¢ä¿ã®ãã©ãã«ã·ã¥ãŒãã£ã³ã°ã§ã¯watch -d -n 2 ifconfig
ã -
ãã®ããã¥ã¡ã³ãããã©ã³ãã ã«é ç®ãæãåºãã«ã¯ä»¥äžã®é¢æ°ãå®è¡ããã(MarkdownãããŒã¹ããã¢ã€ãã ãæœåºãã)ã
function taocl() {
curl -s https://raw.githubusercontent.com/jlevy/the-art-of-command-line/master/README.md |
pandoc -f markdown -t html |
xmlstarlet fo --html --dropdtd |
xmlstarlet sel -t -v "(html/body/ul/li[count(p)>0])[$RANDOM mod last()+1]" |
xmlstarlet unesc | fmt -80
}
ç®ç«ããªãã䟿å©ãªãã®
-
expr
: ç®è¡æŒç®ãè«çæŒç®ããŸãã¯æ£èŠè¡šçŸã®è©äŸ¡ãå®è¡ -
m4
: ã·ã³ãã«ãªãã¯ãããã»ããµ -
yes
: æååããããã衚瀺 -
cal
: ããæãã®ã«ã¬ã³ã㌠-
env
: ã³ãã³ããå®è¡(ã¹ã¯ãªããå ã§éå®ãã) -
printenv
: ç°å¢å€æ°ã衚瀺ãã(ãããã°ãã¹ã¯ãªããå ã§ã®äœ¿çšã«äŸ¿å©) -
look
: æååã§å§ãŸãè±åèª(ãŸãã¯ãã¡ã€ã«å ã®è¡)ãèŠã€ãã -
cut
ãpaste
ãjoin
: ããŒã¿ã®æäœ -
fmt
: ããã¹ãã®æ®µèœããã©ãŒããããã -
pr
: ããã¹ããããŒãžãšã«ã©ã ã«ãã©ãŒããããã -
fold
: ããã¹ãã®è¡ãåå² -
column
: ããã¹ããã«ã©ã ãããã¯ããŒãã«ã«ãã©ãŒããã -
expand
ãšunexpand
: ã¿ããšã¹ããŒã¹ã®çžäºå€æ -
nl
: è¡æ°ã衚瀺 -
seq
: æ°åã衚瀺 -
bc
: èšç®æ© -
factor
: æŽæ°ãå æ°å解 -
gpg
: ãã¡ã€ã«ã®æå·åãšçœ²å -
toe
: terminfoã®ãšã³ããªã®ããŒãã«ã衚瀺 -
nc
: ãããã¯ãŒã¯ã®ãããã°ãšããŒã¿è»¢é -
socat
: ãœã±ãããªã¬ãŒãšTCPããŒãã®ãã©ã¯ãŒã(netcat
ãšåç) -
slurm
: ãããã¯ãŒã¯ãã©ãã£ãã¯ã®å¯èŠå -
dd
: ããŒã¿ããã¡ã€ã«ãããã¯ããã€ã¹éã§ç§»å -
file
: ãã¡ã€ã«ã®çš®é¡ãç¹å® -
tree
: ãã£ã¬ã¯ããªãšãµããã£ã¬ã¯ããªãããªãŒã§è¡šç€ºãls
ã«äŒŒãŠãããååž°çã«åã -
stat
: ãã¡ã€ã«ã®æ å ± -
time
: ã³ãã³ããå®è¡ããŠåŠçæéãèšæž¬ -
timeout
: ã³ãã³ããå®è¡ããæå®æéçµéåŸã«ããã»ã¹ãåæ¢ãã -
lockfile
: ã»ããã©ãã¡ã€ã«ãçæãããããã¯rm -f
ã®ã¿ã§åé€å¯èœã -
logrotate
: ãã°ãããŒããŒããå§çž®ãã¡ãŒã«éä¿¡ -
watch
: ã³ãã³ããç¹°ãè¿ãå®è¡ãããå€æŽéšåã®åŒ·èª¿è¡šç€ºãã§ããã -
tac
: ãã¡ã€ã«ãéãã衚瀺 -
shuf
: ãã¡ã€ã«ããã©ã³ãã ã«éžãã è¡ã衚瀺 -
comm
: ãœãŒãæžã¿ãã¡ã€ã«ã®è¡ãæ¯èŒ -
pv
: ãã€ãçµç±ã§ããŒã¿ã®é²è¡ç¶æ³ãã¢ãã¿ãªã³ã° -
sponge
: æžã蟌ã¿åã«å šãŠã®å ¥åãèªã¿èŸŒããäŸãã°ãgrep -v something some-file | sponge some-file
ã®ããã«ãå ¥åãšåããã¡ã€ã«ã«æžã蟌ãéã«äŸ¿å©ã -
hd
ãhexdump
ãxxd
ãbiew
ãbvi
: ãã€ããªãã¡ã€ã«ã®ãã³ããšç·šé -
strings
: ãã€ããªãã¡ã€ã«ããããã¹ããæœåº -
tr
: æåã®çœ®ãæããšæäœ -
iconv
ãããã¯uconv
: æåãšã³ã³ãŒãã£ã³ã°ã®å€æ -
split
ãšcsplit
: ãã¡ã€ã«ãåå² -
units
: åäœã®å€æãšèšç®ã2é±éãããã®ããã³(蚳泚 : é·ãã®åäœ)ãããŸã°ããããšã®ãã¥ãŠã£ãããŸã§(/usr/share/units/definitions.units
ãåç §ã®ããš) -
apg
: ã©ã³ãã ãªãã¹ã¯ãŒããçæ -
7z
: å§çž®çã®é«ããã¡ã€ã«å§çž® -
ldd
: åçã©ã€ãã©ãªã®æ å ± -
nm
: ãªããžã§ã¯ããã¡ã€ã«ããã·ã³ãã«ã衚瀺 -
ab
: WebãµãŒãã®ãã³ããŒããŒã¯ -
strace
: ã·ã¹ãã ã³ãŒã«ã®ãããã° -
mtr
: ãããã¯ãŒã¯ãããã°ã®ããã®ããé«æ©èœãªtraceroute -
cssh
: ããžã¥ã¢ã«ãªäžŠåã·ã§ã« -
rsync
: ãã¡ã€ã«ããã©ã«ããSSHçµç±ãŸãã¯ããŒã«ã«ãã¡ã€ã«ã·ã¹ãã å ã§åæ -
wireshark
ãštshark
: ãã±ãããã£ããã£ãšãããã¯ãŒã¯ãããã®ã³ã° -
ngrep
: ãããã¯ãŒã¯å±€ã®grep -
host
ãšdig
: DNSåå解決 -
lsof
:ããã»ã¹ã®ãã¡ã€ã«ãã£ã¹ã¯ãªãã¿ãšãœã±ããæ å ± -
dstat
: 䟿å©ãªã·ã¹ãã æ å ± -
glances
: é«ã¬ãã«ã«è€æ°ã®ãµãã·ã¹ãã ã®æŠèŠãææ¡ -
iostat
: ãã£ã¹ã¯ã®äœ¿çšç¶æ³ -
mpstat
: CPUã®äœ¿çšç¶æ³ -
vmstat
: ã¡ã¢ãªã®äœ¿çšç¶æ³ -
htop
: topã®æ¹è¯ç -
last
: ãã°ã€ã³å±¥æŽ -
w
: 誰ããã°ã€ã³ããŠããã -
id
: ãŠãŒã¶ãã°ã«ãŒãã®æ å ± -
sar
: ã·ã¹ãã çµ±èšæ å ±ã®å±¥æŽ -
iftop
ãŸãã¯nethogs
: ãœã±ãããããã¯ããã»ã¹ããšã®ãããã¯ãŒã¯äœ¿çšé -
ss
: ãœã±ããã®çµ±èšæ å ± -
dmesg
: èµ·åæãšã·ã¹ãã ã®ãšã©ãŒã¡ãã»ãŒãž -
sysctl
: Linuxã«ãŒãã«ãã©ã¡ãŒã¿ã®ç¢ºèªããã³èšå® -
hdparm
: SATA/ATAãã£ã¹ã¯ã®æäœãããã©ãŒãã³ã¹ç¢ºèª -
lsb_release
: Linuxãã£ã¹ããªãã¥ãŒã·ã§ã³æ å ± -
lsblk
: ãããã¯ããã€ã¹ã®äžèŠ§ããã£ã¹ã¯ãšãã£ã¹ã¯ããŒãã£ã·ã§ã³ã®ããªãŒãã¥ãŒ -
lshw
ãlscpu
ãlspci
ãlsusb
ãdmidecode
: CPUãBIOSãRAIDãã°ã©ãã£ãã¯ããã®ä»ããã€ã¹ãªã©ã®ããŒããŠã§ã¢æ å ± -
lsmod
ãmodinfo
: ã«ãŒãã«ã®ã¢ãžã¥ãŒã«ãªã¹ããšã¢ãžã¥ãŒã«æ å ± -
fortune
ãddate
ãsl
: ããŒãããŒãããã¯èžæ°æ©é¢è»ãZippyã®åŒçšå¥ãã䟿å©ãã ãšæããã©ããã«ãã
OS Xçšã®ãã®
ãããã¯MacOSçšã®é ç®ã§ãã
-
ããã±ãŒãžç®¡çã¯
brew
(Homebrew)ãport
(MacPorts)ã䜿ããäžèšã®å€ãã®ã³ãã³ããMacOSã«ã€ã³ã¹ããŒã«ã§ããã -
ã³ãã³ãã®åºåãã¯ãªããããŒãã«ã³ããŒãã
pbcopy
ãšã¯ãªããããŒãããåºåããpbpaste
ã -
OptionããŒãaltããŒãšããŠMac OSã®ã¿ãŒããã«ã§äœ¿ã(äžè¿°ã®alt-bãalt-fãªã©ã䜿ãå Žå)ã«ã¯ãç°å¢èšå® -> èšå® -> ããŒããŒã ã§ã"ã¡ã¿ããŒãšããŠoptionããŒã䜿çš"ãéžæã
-
ãã¹ã¯ãããã¢ããªã±ãŒã·ã§ã³ã§ãã¡ã€ã«ãéãã«ã¯ã
open
ãopen -a /Applications/Whatever.app
ã -
Spotlight:
mdfind
ã§ãã¡ã€ã«ãæ€çŽ¢ããã¡ã¿ããŒã¿(ç»åãã¡ã€ã«ã®EXIFã®æ å ±ãªã©)ãmdls
ã§è¡šç€ºã -
Mac OSã¯BSD UnixããŒã¹ã§ãããããå€ãã®ã³ãã³ã(äŸãã°ã
ps
ãls
ãtail
ãawk
ãsed
)ã§ã¯ãUnix System VãšGNUããŒã«ã®éãã«åœ±é¿ãããŠãLinuxã®ãã®ãšæ¯ã¹ãŠåŸ®åŠãªéããå€ãå«ãŸããŠãããéãããããã«ã€ããŠã¯ãããã¥ã¢ã«ããŒãžã®ã¿ã€ãã«ã«"BSD General Commands Manual"ãšæžãããŠãããã©ããã§å€æã§ãããå Žåã«ãã£ãŠã¯ãGNUããŒãžã§ã³ãã€ã³ã¹ããŒã«å¯èœã§ãã(äŸãã°ãgawk
ãgsed
ã§ãGNUã®awkãšsedã«å¯Ÿå¿)ãã¯ãã¹ãã©ãããã©ãŒã ã®bashã¹ã¯ãªãããæžãå Žåã«ã¯ããã®ãããªã³ãã³ãã¯é¿ãã(Pythonãperl
ã®å©çšãæ€èš)ãååãªãã¹ããå¿ èŠã§ããã -
Mac OSã®ãªãªãŒã¹æ å ±ãååŸããã«ã¯ã
sw_vers
ã
ãããªããªãœãŒã¹
- awesome-shell: ã·ã§ã«ã®ããŒã«ããªãœãŒã¹ã®ãŸãšã
- awesome-osx-command-line: ãã詳ããMac OSã®ã³ãã³ãã©ã€ã³ã¬ã€ã
- Strict mode: ããããã·ã§ã«ã¹ã¯ãªãããæžãããã«
- shellcheck: ã·ã§ã«ã¹ã¯ãªãã(æ¬æ¥ãbash/sh/zshçš)ã®éç解æããŒã«
- Filenames and Pathnames in Shell: ã·ã§ã«ã¹ã¯ãªããã§ãã¡ã€ã«åãæ£ããæ±ãããã«
å 責äºé
ããäžéšã®äŸå€ã¯ãããŸãããã³ãŒãã¯èª°ã§ãèªããããã«æžãããŠãããåã«ã¯è²¬ä»»ã䌎ããBashã§ã§ãããããšãã£ãŠããããã¹ãå¿ èŠããããšããæå³ã§ã¯ãªãïŒ ;)
ã©ã€ã»ã³ã¹
ãã®ããã¥ã¡ã³ãã¯Creative Commons Attribution-ShareAlike 4.0 International Liceneã§ã©ã€ã»ã³ã¹ãããã