| コマンド | 例 | 内容 |
|---|---|---|
| adduser | ||
| apt | ||
| awk | ||
| bc | echo “1+2+3” | bc | |
| cal | ||
| cat | cat file.txt | concatenate files and print on the standard output |
| cd | ||
| chmod | change file mode bits | |
| chown | change file owner and group | |
| clear | ||
| cmp | ||
| cp | ||
| curl | transfer a URL | |
| df | report file system disk space usage | |
| diff | ||
| echo | echo “Hello World!” > file.txt | ファイルを新規作成する |
| exit | ||
| find | search for files in a directory hierarchy | |
| finger | ユーザーの情報を表示する | |
| free | Display amount of free and used memory in the system | |
| grep | ||
| head | ||
| history | ||
| hostname | ホスト名を表示する | |
| htop | interactive process viewer | |
| ifconfig | 非推奨。代わりにipを使うこと | |
| ip addr | ip addr ip link ip -s link | |
| iptables ip6tables | administration tool for IPv4/IPv6 packet filtering and NAT | |
| kill | ||
| less | opposite of more | |
| ln | リンクを作成する | |
| ls | ||
| lscpu | display information about the CPU architecture | |
| man | ||
| mkdir | ||
| more | file perusal filter for crt viewing | |
| mv | ||
| nano | nano file.txt | |
| neofetch | ||
| netstat | 代わりにssを使うこと | |
| passwd | ||
| ping | ||
| pkill | ||
| printenv | 環境変数を出力する | |
| ps | report a snapshot of the current processes | |
| pwd | print working directory | |
| reboot | ||
| resolvectl status | ||
| rm | ||
| rsync | rsync -r /path/to/local_source/ user@remote:/path/to/remote_destination/ rsync -r user@remote:/path/to/remote_source/ /path/to/local_destination/ | ファイルやディレクトリを転送する (ディレクトリを転送する場合は-rオプションが必要) |
| scp | 非推奨 | |
| sed | stream editor for filtering and transforming text | |
| sftp | sftp <hostname> lls lcd put <local_file> ls cd get <remote_file> | サーバーとの間でファイルを送受信する |
| shred | shred file.txt | ファイルを完全に削除する |
| shutdown | shutdown -h now | 代わりにsystemctl poweroffを使うこと |
| sort | ||
| ss | TCP/UDPのポート開放状態を確認 ss -nltu | another utility to investigate sockets |
| ssh | ssh <hostname> | OpenSSH remote login client |
| su | ||
| sudo | ||
| systemctl | systemctl poweroff systemctl reboot systemctl suspend | Control the systemd system and service manager |
| tail | ||
| tee | cat <<EOF | sudo tee -a /etc/hosts 192.168.0.100 company.com EOF | read from standard input and write to standard output and files sudoでファイルに書き込む場合などに使う -aは追記 |
| top | ||
| touch | change file timestamps | |
| traceroute | ||
| ufw | sudo ufw status sudo ufw enable sudo ufw reload sudo ufw app list sudo ufw allow ‘Nginx Full’ TCP/UDPポート開放 sudo ufw allow 80 sudo ufw reload UDPポート開放 sudo ufw allow 80/udp sudo ufw reload SSH接続用ポート開放 sudo ufw allow 22 ポート削除 sudo ufw status sudo ufw delete <ステータス一覧上の番号> | (Uncomplicated Firewall) program for managing a netfilter firewall 内部ではiptablesが使われている |
| uname | すべての情報を表示 uname -a | print system information |
| unzip | ||
| useradd | ||
| vim | vim file.txt | |
| wget | The non-interactive network downloader | |
| whatis | ||
| whereis | ||
| which | ||
| whoami | ||
| zip |
リダイレクト/パイプ
| > | 出力をリダイレクト(上書き)。1>と同義 |
| >> | 出力をリダイレクト(追記) |
| 2> | 標準エラー出力をリダイレクト |
| 2>&1 | 標準エラー出力を標準出力にリダイレクト |
| < | 入力をリダイレクト。0<と同義 |
| cat <<EOF> fruits.txt apple grape orange EOF | ヒアドキュメント(上書き)。>ではなく>>とすると追記 |
| cmd1 | cmd2 | cmd1の標準出力をcmd2の標準入力に渡す |
| cmd1 |& cmd2 | cmd1の標準出力と標準エラー出力をcmd2の標準入力に渡す |