command snippet
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
* command snippet [#fdef793e]
#contents
** Windows [#d80b2e97]
→[[command snippet/windows]]
** user [#user]
*** ユーザとグループの一覧 [#rafe9a0c]
cat /etc/passwd
cat /etc/group
*** sudo ができる管理ユーザの追加の例 [#b41e60e7]
sudo useradd -G adm,sudo USERNAME
*** パスワードの設定 [#q0de9365]
sudo passwd USERNAME
かんたん。
sudo usermod -p PASSWORD_ENCRYPTED USERNAME
自動化にはいい。PASSWORD_ENCRYPTED は
openssl passwd
を実行し、プロンプトに沿ってパスワードを入れると出力でき...
以下は passwd と同じ動き:
sudo usermod -p `openssl passwd` USERNAME
*** ユーザのログイン名を変更し、ホームディレクトリを引っ...
sudo usermod -l CHANGE_TO -d /home/CHANGE_TO -m CHANGE_F...
-l でログイン名変更、-d でホームディレクトリ変更、-m でホ...
たぶん当然だけど CHANGE_FROM ユーザでこれを実行すべきでは...
** 今のセッションのコマンド履歴を忘れる [#l7e8322c]
unset HISTFILE
** 文字列のハッシュ値を取得する [#gbaa248b]
echo -n 'loremipsum' | sha256sum
** disk free [#df]
df -h
'-h' は 61917736 を 60G とかになおしてくれる。
** parted [#parted]
パーティションの一覧表示
parted -l
未使用スペースを含めて表示
parted
(parted) print free
** tar+gzip [#tar]
*** ディレクトリの圧縮 [#j6db2f31]
tar -cvzf tgzFILE DIRCompressTo
*** ディレクトリの展開 [#gf16d085]
tar -xvzf tgzFILE
** git [#git]
*** force pushed branch の pull [#i059c697]
git pull --rebase
*** 直前の commit のハッシュを出力 [#n905f855]
git rev-parse HEAD
# b90383d07388fe8513e59a6deb1a2391146c6561
git rev-parse --short @
# b90383d07
git rev-parse --short @~2
# hash from 2 commits ago
git rev-parse --short main
# hash of latest commit on main
*** 直前の commit の author の修正 [#nf32094b]
git commit --amend --author="mgmn <mgmnjp@example.com>" ...
*** 直前の amend commit を取り消す (変更を維持) [#e7e9ff19]
git reset --soft HEAD@{1}
`git reflog` した結果の `{n}` こ前に HEAD を移動している。
https://stackoverflow.com/questions/1459150/how-to-undo-g...
*** いまのブランチ名を出力 [#gc049621]
git rev-parse --abbrev-ref @
*** 上流が共通のよそのリポジトリのブランチに追従する [#ze...
# ローカルのブランチを切る
git branch yosono-fork
# よその分化直前のコミットまで reset する
git reset --hard (SHA1)
# リモートの追加
git remote add yoso https://example.com/yoso/yoso.git
git fetch yoso
# 上流ブランチの設定
git branch --set-upstream-to yoso/master
git pull
** ssh [#ssh]
*** 鍵ペアの生成 [#yf8ca5b2]
ssh-keygen # RSA3072
ssh-keygen -t ed25519
***固まったセッションの強制終了 [#of2334f3]
(Enter)
~.
** screen [#r46c236d]
*** 切断 [#h700e353]
(Ctrl + a)
k
** certbot [#certbot]
*** 証明書の取得 [#w3ec2f8b]
certbot --non-interactive certonly --webroot -w /var/www...
*** 証明書の取得 (staging server) [#w4055b4e]
certbot --non-interactive certonly --webroot -w /var/www...
staging server は production server よりも[[証明書の重複...
*** ストアしている証明書の一覧 [#t7abf0ad]
certbot certificates
*** ストアしている証明書を削除する [#r8e6f814]
sudo certbot delete --cert-name example.com
取得済みの証明書が「Certificate not yet due for renewal」...
** openssl [#openssl]
*** 自己証明書の作成 [#x5580df6]
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out ...
*** RSA 鍵からパスワードを削除する [#jba2224e]
openssl rsa -in key.pem -out key.pem
openssl rsa - Mister PKI
https://www.misterpki.com/openssl-rsa/
** curl [#curl]
*** verbose [#z85df100]
curl -X GET -v https://...
*** 要求ヘッダを指定/追加する [#ed71acbc]
curl --header "Accept: application/json,application/xml"...
curl -H "Accept: application/json" -H "Accept-Language: ...
*** NTLM 認証をする [#gfac7aa9]
curl --ntlm -u user:password https://...
** dig [#dig]
*** ルートサーバからの反復問い合わせとその応答をすべて表...
dig @recursive.ns.example.com mgmn.jp +trace
*** 再帰的動作を要求しない問い合わせを行う [#j86af4b8]
デフォルトでは `+recurse` を付加したときと同じ 再帰的動作...
>&color(#006600){$ dig a mgmn.jp @authoritative.ns.exampl...
; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> a mgmn.jp...
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1234
;; flags: qr aa &color(#ff0000){rd};((Recursion Desired ...
;; &color(#ff0000){WARNING: recursion requested but not a...
`+norecurse` を付加すると、フルリゾルバから権威サーバに行...
キャッシュサーバと権威サーバを兼ねているサーバ((このよう...
dig a mgmn.jp @authoritative.ns.example.com +norecurse
dig a mgmn.jp @authoritative.ns.example.com +norec
:thanks to |
DNSチュートリアル - JANOG53 Meeting in Hakata
https://www.janog.gr.jp/meeting/janog53/dnsbasic/
*** 回答を複数行表示する [#u1aabec0]
SOA レコードがとくに見やすくなる。
dig mgmn.jp soa +multiline
dig mgmn.jp soa +multi
** firewall-cmd [#firewall-cmd]
サービス名指定で許可・禁止
sudo firewall-cmd --add-service=https --permanent
sudo firewall-cmd --remove-service=ssh --permanent
ポート番号指定で許可・禁止
sudo firewall-cmd --add-port=1234/tcp --permanent
sudo firewall-cmd --remove-port=1234/tcp --permanent
** Mastodon [#mastodon]
下段は development 環境用。
*** 依存関係の更新 [#s43ac6ba]
bundle && yarn --frozen-lockfile
*** DB のバックアップ [#eedc9a89]
pg_dump -Fc mastodon_production -f ~/donbak/pg_backup.dump
pg_dump -Fc mastodon_development -f ~/donbak/pg_backup.d...
*** DB のマイグレーション [#aae0edfd]
RAILS_ENV=production bundle exec rails db:migrate
RAILS_ENV=development bundle exec rails db:migrate
*** アセットのリビルド [#q75c2c36]
RAILS_ENV=production bundle exec rails tmp:clear assets:...
RAILS_ENV=development bundle exec rails tmp:clear assets...
%%public/packs を消した場合は OS 再起動したほうがいいかも%%
より文明的なやり方をみつけたので mastodon-web の reload ...
*** web と sidekiq の再起動 [#a3c93205]
sudo systemctl daemon-reload && sudo systemctl reload ma...
# サービス稼働状態の確認
sudo systemctl | grep mastodon
*** ユーザの追加 [#i6bdc7b6]
RAILS_ENV=development bin/tootctl accounts create --emai...
*** オーナユーザの追加 [#t5266537]
RAILS_ENV=development bin/tootctl accounts create --role...
*** 既存ユーザをオーナにする [#a5bd9e6d]
RAILS_ENV=production bin/tootctl accounts modify --role ...
RAILS_ENV=development bin/tootctl accounts modify --role...
終了行:
* command snippet [#fdef793e]
#contents
** Windows [#d80b2e97]
→[[command snippet/windows]]
** user [#user]
*** ユーザとグループの一覧 [#rafe9a0c]
cat /etc/passwd
cat /etc/group
*** sudo ができる管理ユーザの追加の例 [#b41e60e7]
sudo useradd -G adm,sudo USERNAME
*** パスワードの設定 [#q0de9365]
sudo passwd USERNAME
かんたん。
sudo usermod -p PASSWORD_ENCRYPTED USERNAME
自動化にはいい。PASSWORD_ENCRYPTED は
openssl passwd
を実行し、プロンプトに沿ってパスワードを入れると出力でき...
以下は passwd と同じ動き:
sudo usermod -p `openssl passwd` USERNAME
*** ユーザのログイン名を変更し、ホームディレクトリを引っ...
sudo usermod -l CHANGE_TO -d /home/CHANGE_TO -m CHANGE_F...
-l でログイン名変更、-d でホームディレクトリ変更、-m でホ...
たぶん当然だけど CHANGE_FROM ユーザでこれを実行すべきでは...
** 今のセッションのコマンド履歴を忘れる [#l7e8322c]
unset HISTFILE
** 文字列のハッシュ値を取得する [#gbaa248b]
echo -n 'loremipsum' | sha256sum
** disk free [#df]
df -h
'-h' は 61917736 を 60G とかになおしてくれる。
** parted [#parted]
パーティションの一覧表示
parted -l
未使用スペースを含めて表示
parted
(parted) print free
** tar+gzip [#tar]
*** ディレクトリの圧縮 [#j6db2f31]
tar -cvzf tgzFILE DIRCompressTo
*** ディレクトリの展開 [#gf16d085]
tar -xvzf tgzFILE
** git [#git]
*** force pushed branch の pull [#i059c697]
git pull --rebase
*** 直前の commit のハッシュを出力 [#n905f855]
git rev-parse HEAD
# b90383d07388fe8513e59a6deb1a2391146c6561
git rev-parse --short @
# b90383d07
git rev-parse --short @~2
# hash from 2 commits ago
git rev-parse --short main
# hash of latest commit on main
*** 直前の commit の author の修正 [#nf32094b]
git commit --amend --author="mgmn <mgmnjp@example.com>" ...
*** 直前の amend commit を取り消す (変更を維持) [#e7e9ff19]
git reset --soft HEAD@{1}
`git reflog` した結果の `{n}` こ前に HEAD を移動している。
https://stackoverflow.com/questions/1459150/how-to-undo-g...
*** いまのブランチ名を出力 [#gc049621]
git rev-parse --abbrev-ref @
*** 上流が共通のよそのリポジトリのブランチに追従する [#ze...
# ローカルのブランチを切る
git branch yosono-fork
# よその分化直前のコミットまで reset する
git reset --hard (SHA1)
# リモートの追加
git remote add yoso https://example.com/yoso/yoso.git
git fetch yoso
# 上流ブランチの設定
git branch --set-upstream-to yoso/master
git pull
** ssh [#ssh]
*** 鍵ペアの生成 [#yf8ca5b2]
ssh-keygen # RSA3072
ssh-keygen -t ed25519
***固まったセッションの強制終了 [#of2334f3]
(Enter)
~.
** screen [#r46c236d]
*** 切断 [#h700e353]
(Ctrl + a)
k
** certbot [#certbot]
*** 証明書の取得 [#w3ec2f8b]
certbot --non-interactive certonly --webroot -w /var/www...
*** 証明書の取得 (staging server) [#w4055b4e]
certbot --non-interactive certonly --webroot -w /var/www...
staging server は production server よりも[[証明書の重複...
*** ストアしている証明書の一覧 [#t7abf0ad]
certbot certificates
*** ストアしている証明書を削除する [#r8e6f814]
sudo certbot delete --cert-name example.com
取得済みの証明書が「Certificate not yet due for renewal」...
** openssl [#openssl]
*** 自己証明書の作成 [#x5580df6]
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out ...
*** RSA 鍵からパスワードを削除する [#jba2224e]
openssl rsa -in key.pem -out key.pem
openssl rsa - Mister PKI
https://www.misterpki.com/openssl-rsa/
** curl [#curl]
*** verbose [#z85df100]
curl -X GET -v https://...
*** 要求ヘッダを指定/追加する [#ed71acbc]
curl --header "Accept: application/json,application/xml"...
curl -H "Accept: application/json" -H "Accept-Language: ...
*** NTLM 認証をする [#gfac7aa9]
curl --ntlm -u user:password https://...
** dig [#dig]
*** ルートサーバからの反復問い合わせとその応答をすべて表...
dig @recursive.ns.example.com mgmn.jp +trace
*** 再帰的動作を要求しない問い合わせを行う [#j86af4b8]
デフォルトでは `+recurse` を付加したときと同じ 再帰的動作...
>&color(#006600){$ dig a mgmn.jp @authoritative.ns.exampl...
; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> a mgmn.jp...
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1234
;; flags: qr aa &color(#ff0000){rd};((Recursion Desired ...
;; &color(#ff0000){WARNING: recursion requested but not a...
`+norecurse` を付加すると、フルリゾルバから権威サーバに行...
キャッシュサーバと権威サーバを兼ねているサーバ((このよう...
dig a mgmn.jp @authoritative.ns.example.com +norecurse
dig a mgmn.jp @authoritative.ns.example.com +norec
:thanks to |
DNSチュートリアル - JANOG53 Meeting in Hakata
https://www.janog.gr.jp/meeting/janog53/dnsbasic/
*** 回答を複数行表示する [#u1aabec0]
SOA レコードがとくに見やすくなる。
dig mgmn.jp soa +multiline
dig mgmn.jp soa +multi
** firewall-cmd [#firewall-cmd]
サービス名指定で許可・禁止
sudo firewall-cmd --add-service=https --permanent
sudo firewall-cmd --remove-service=ssh --permanent
ポート番号指定で許可・禁止
sudo firewall-cmd --add-port=1234/tcp --permanent
sudo firewall-cmd --remove-port=1234/tcp --permanent
** Mastodon [#mastodon]
下段は development 環境用。
*** 依存関係の更新 [#s43ac6ba]
bundle && yarn --frozen-lockfile
*** DB のバックアップ [#eedc9a89]
pg_dump -Fc mastodon_production -f ~/donbak/pg_backup.dump
pg_dump -Fc mastodon_development -f ~/donbak/pg_backup.d...
*** DB のマイグレーション [#aae0edfd]
RAILS_ENV=production bundle exec rails db:migrate
RAILS_ENV=development bundle exec rails db:migrate
*** アセットのリビルド [#q75c2c36]
RAILS_ENV=production bundle exec rails tmp:clear assets:...
RAILS_ENV=development bundle exec rails tmp:clear assets...
%%public/packs を消した場合は OS 再起動したほうがいいかも%%
より文明的なやり方をみつけたので mastodon-web の reload ...
*** web と sidekiq の再起動 [#a3c93205]
sudo systemctl daemon-reload && sudo systemctl reload ma...
# サービス稼働状態の確認
sudo systemctl | grep mastodon
*** ユーザの追加 [#i6bdc7b6]
RAILS_ENV=development bin/tootctl accounts create --emai...
*** オーナユーザの追加 [#t5266537]
RAILS_ENV=development bin/tootctl accounts create --role...
*** 既存ユーザをオーナにする [#a5bd9e6d]
RAILS_ENV=production bin/tootctl accounts modify --role ...
RAILS_ENV=development bin/tootctl accounts modify --role...
ページ名: