完全に自分用
ファイル / ディレクトリ管理
whatis: 正規表現でコマンドを検索
$ whatis -w "*user" adduser (8) - 新規ユーザの作成・新規ユーザのデフォルト情報の更新 fuser (1) - identify processes using files or sockets fuser (1p) - list process IDs of all processes that have one or more files open pam_localuser (8) - require users to be listed in /etc/passwd runuser (1) - run a command with substitute user and group ID
apropos: コマンド名と説明からコマンドや設定ファイルを検索
$ apropos yum find-repos-of-install (1) - report which Yum repository a package was installed from repo-rss (1) - generates an RSS feed from one or more Yum repositories repoclosure (1) - display a list of unresolved dependencies for a yum repository repodiff (1) - list differences between two or more Yum repositories repoquery (1) - query information from Yum repositories reposync (1) - synchronize yum repositories to a local directory verifytree (1) - verify that a local yum repository is consistent yum (8) - Yellowdog Updater Modified yum-builddep (1) - install missing dependencies for building an RPM package yum-complete-transaction (8) - attempt to complete failed or aborted Yum transactions yum-config-manager (1) - manage yum configuration options and yum repositories yum-debug-dump (1) - write system RPM configuration to a debug-dump file yum-debug-restore (1) - replay Yum transactions captured in a debug-dump file yum-groups-manager (1) - create and edit yum's group metadata yum-langpacks (8) - Plugin for yum yum-shell (8) - Yellowdog Updater Modified shell yum-utils (1) - tools for manipulating repositories and extended package management yum.conf (5) - Configuration file for yum(8). yumdb (8) - query and alter the Yum database yumdownloader (1) - download RPM packages from Yum repositories
install: cp + chown + chroot
$ touch hello $ ls hello -rw-r--r-- 1 xxx staff 0B 6 7 12:58 hello $ sudo install -m 622 -o root -g staff hello /tmp/hello $ ls /tmp/hello -rw--w--w- 1 root staff 0B 6 7 12:59 /tmp/hello
chattr / lsattr
UNIXで用意されているファイル制御システムとは別に、ファイルシステム(ext2/3/4/xfs)で実現されるファイル属性。
- 追加のみ許可
- 常時圧縮
- 削除しても復旧可能 など
split: ファイルを分割する
$ uuencode -m - < /usr/local/bin/aws > aws.uuencode $ split aws.uuencode $ wc -l x* | less 1000 xaa 1000 xab 1000 xac 1000 xad 1000 xae 1000 xaf 1000 xag
truncate: ファイルを指定の長さに切り詰める
uuencode / uudecode: バイナリをテキストに変換/復元する
pushd / popd / dirs: ディレクトリをスタックに追加/削除/移動する
convmv : ファイル名の文字コードを変換する
ユーザ管理
gpasswd: グループのパスワード管理
・グループの非メンバがそのグループを管理する場合(グループへユーザを追加するなど) ・グループへログインする場合。ログインするとそのグループがプライマリグループとなる。(ただしグループに所属していない場合)
ユーザパスワードとグループパスワードの違い | CentOS
テキスト処理
rev: 文字を逆にする
$ rev <(echo hello) olleh
iconv / nfk: ファイルの文字コードを変換
cmp: ファイルをバイトごとに比較する
col: 改行コードをフィルタする
- 標準入力からの改行文字を削除する
- manを印刷 / scriptの出力整理に使える
colrm: 指定した桁を削除する
$ echo 123456789 | colrm 3 5
shuf: 出力をシャッフルする
$ echo -e "a\nb\nc" | shuf c b a $ echo -e "a\nb\nc" | shuf c b a
$ shuf -i 1-5 -n 5 5 1 2 4 3
paste: 複数ファイルの行をマージする
join: 2つの入力ファイルから共通フィールドを結合する
ネットワーク
host: DNSを利用してホスト名の検索を行う
$ host google.com Status: 0 google.com has address 172.217.174.110 google.com has IPv6 address 2404:6800:4004:809::200e google.com mail is handled by 30 alt2.aspmx.l.google.com. google.com mail is handled by 20 alt1.aspmx.l.google.com. google.com mail is handled by 50 alt4.aspmx.l.google.com. google.com mail is handled by 40 alt3.aspmx.l.google.com. google.com mail is handled by 10 aspmx.l.google.com.
ssh-copy-id: ssh公開鍵を外部に送信する
ssh-copy-id -i ~/.ssh/id_rsa.pub -n