シェル チートシート
検索・印刷できる Bash/シェルのリファレンス:ナビゲーション、ファイル、パイプ、変数、ループ、条件分岐、便利なワンライナー。無料。
Navigation
8pwd
Print the working directory
ls -la
List all files with details
cd /path
Change directory
cd -
Go to the previous directory
cd ~
Go to the home directory
tree -L 2
Show directory tree (2 levels)
pushd / popd
Push and pop the directory stack
ls -lhS
List by size, human-readable
Files & directories
10touch file.txt
Create an empty file
mkdir -p a/b/c
Create nested directories
cp -r src dest
Copy recursively
mv old new
Move or rename
rm -rf dir
Remove recursively (careful!)
ln -s target link
Create a symbolic link
cat file.txt
Print file contents
head -n 20 / tail -n 20
First / last 20 lines
tail -f log.txt
Follow a file as it grows
less file.txt
Page through a file
Search & find
8grep 'pattern' file
Search for a pattern in a file
grep -rin 'text' .
Recursive, case-insensitive, numbered
find . -name '*.php'
Find files by name
find . -type f -mtime -1
Files modified in the last day
find . -size +10M
Files larger than 10 MB
which node
Locate an executable
locate file.txt
Find by indexed database
grep -v 'skip' file
Invert match (exclude lines)
Text processing
9wc -l file
Count lines
sort file | uniq -c
Sort then count duplicates
cut -d',' -f1 file
Extract a CSV column
awk '{print $1}' file
Print the first field
sed 's/old/new/g' file
Substitute text
tr 'a-z' 'A-Z'
Translate characters
diff a.txt b.txt
Compare two files
tee out.txt
Write to a file and stdout
xargs -I{} cmd {}
Build commands from input
Pipes & redirection
9a | b
Pipe output of a into b
cmd > file
Redirect stdout (overwrite)
cmd >> file
Redirect stdout (append)
cmd 2> err.log
Redirect stderr
cmd > out 2>&1
Redirect both streams
cmd < input.txt
Read stdin from a file
cmd1 && cmd2
Run cmd2 only if cmd1 succeeds
cmd1 || cmd2
Run cmd2 only if cmd1 fails
cmd &
Run in the background
Permissions & ownership
8chmod 755 file
Set rwx for owner, rx for others
chmod +x script.sh
Make a file executable
chmod -R 644 dir
Recursive permission change
chown user:group file
Change owner and group
umask 022
Default permission mask
sudo cmd
Run a command as root
stat file
Show file metadata
ls -l file
View permission bits
Processes & system
9ps aux
List running processes
top / htop
Live process monitor
kill -9 PID
Force-kill a process
pkill -f name
Kill processes by name
jobs / fg / bg
Manage background jobs
df -h
Disk space usage
du -sh dir
Size of a directory
free -h
Memory usage
uname -a
System and kernel info
Variables & expansion
9NAME='value'
Set a variable (no spaces)
echo \"$NAME\"
Use a variable
export PATH=\"$PATH:/x\"
Export to child processes
$(command)
Command substitution
${VAR:-default}
Default if unset
$1 $2 $@
Script positional arguments
$?
Exit status of the last command
read -p 'Name: ' x
Read user input
echo {1..5}
Brace expansion
Scripting
9#!/usr/bin/env bash
Shebang line
set -euo pipefail
Safer strict mode
if [ -f file ]; then ...; fi
Conditional on a file test
[ \"$a\" = \"$b\" ]
String comparison
for f in *.txt; do ...; done
Loop over files
while read line; do ...; done < file
Read a file line by line
case \"$x\" in a) ...;; esac
Multi-way branch
function greet() { echo hi; }
Define a function
trap cleanup EXIT
Run a handler on exit
「:q」に一致する項目はありません。
シェル チートシートについて
このBash・シェルチートシートは、コマンドラインの基本操作からスクリプティングまでを網羅しています。ナビゲーション、ファイルとディレクトリ、検索、テキスト処理、パイプとリダイレクト、権限と所有権、プロセスとシステム情報、変数と展開、シェルスクリプトの構文まで扱います。
ls、cp、grep、find、chmod、psといった日常的なコマンドを、それらを使いこなすためのフラグとともに掲載し、単一のコマンドをワンライナーに変える、パイプ・リダイレクト・展開の構文も網羅しています。スクリプティングのセクションは、年に数回しか書かないループ・条件分岐・関数の構文を思い出させてくれます。
すべてが無料でクライアントサイドの1ページに収まっています。検索で行をリアルタイムに絞り込み、固定表示の目次でセクション間を移動でき、クリック1つで任意のコマンドをコピーでき、印刷ボタンでデスク用のターミナルリファレンスが手に入ります。
シェル チートシートの使い方
- ナビゲーションやファイル&ディレクトリからパイプ&リダイレクト、スクリプティングまで、各セクションを閲覧します。
- grepやchmodのようなコマンド名を検索ボックスに入力すると、シートが即座に絞り込まれます。
- 固定サイドバーからテキスト処理などのセクションへジャンプします。
- コマンドまたはそのコピーアイコンをクリックしてコピーし、ターミナルに貼り付けます。
- オフラインのBashコマンドリファレンスとしてページを印刷します。
よくある質問
このシートはBashおよびPOSIX系シェル向けに書かれているため、Linux・macOS上のbash、zshなど類似のシェルでほぼそのまま使えます。
両方です。ファイル、検索、テキスト処理、プロセスに関するコマンドに加え、変数と展開、そしてループ・条件分岐など、スクリプト間で忘れがちな構文を扱う専用セクションがあります。
できます。コマンドまたはその行のコピーアイコンをクリックすると、クリップボードに保存され、ターミナルにすぐ貼り付けられます。
実行前には必ず内容を確認してください。特にrm、権限、リダイレクトが絡むものは注意が必要です。各行にはコマンドが正確に何をするかの1行説明が付いています。
はい、完全に無料です。アカウント登録も利用制限もないクライアントサイドのリファレンスページです。
人気の検索
linux コマンド チートシート
bash チートシート
シェル コマンド一覧
grep find 使い方
bash スクリプト リファレンス
chmod 権限 チートシート
bash パイプ リダイレクト
ターミナル コマンド一覧
お困りですか?
このツールで問題が見つかりましたか?チームにお知らせください。