cat /etc/passwd
cat /etc/group
sudo useradd -G adm,sudo USERNAME
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_FROM
unset HISTFILE
echo -n 'loremipsum' | sha256sum
df -h
'-h' は 61917736 を 60G とかになおしてくれる。
パーティションの一覧表示
parted -l
未使用スペースを含めて表示
parted (parted) print free
tar -cvzf tgzFILE DIRCompressTo
tar -xvzf tgzFILE
git pull --rebase
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
git commit --amend --author="mgmn <mgmnjp@example.com>" --no-edit
git reset --soft HEAD@{1}
`git reflog` した結果の `{n}` こ前に HEAD を移動している。
https://stackoverflow.com/questions/1459150/how-to-undo-git-commit-amend-done-instead-of-git-commit
git rev-parse --abbrev-ref @
# ローカルのブランチを切る 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-keygen # RSA3072
ssh-keygen -t ed25519
(Enter) ~.
(Ctrl + a) k
certbot --non-interactive certonly --webroot -w /var/www/html -m "mgmnjp@example.com" --agree-tos -d "example.com"
certbot --non-interactive certonly --webroot -w /var/www/html -m "mgmnjp@example.com" --agree-tos -d "example.com" --test-cert
staging server は production server よりも証明書の重複取得の回数制限がかなり緩和されている。
certbot certificates
sudo certbot delete --cert-name example.com
取得済みの証明書が「Certificate not yet due for renewal」で再取得できない場合はこれで設定を消すと通るようになる。
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 3650
openssl rsa -in key.pem -out key.pem
openssl rsa - Mister PKI
https://www.misterpki.com/openssl-rsa/
curl -X GET -v https://...
curl --header "Accept: application/json,application/xml" https://...
curl -H "Accept: application/json" -H "Accept-Language: ja" https://...
curl --ntlm -u user:password https://...
dig @recursive.ns.example.com mgmn.jp +trace
デフォルトでは `+recurse` を付加したときと同じ 再帰的動作を要求する問い合わせが行われる。
$ dig a mgmn.jp @authoritative.ns.example.com
; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> a mgmn.jp @authoritative.ns.example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1234
;; flags: qr aa rd*1; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 1
;; WARNING: recursion requested but not available
`+norecurse` を付加すると、フルリゾルバから権威サーバに行われる問い合わせと同じように、再帰的動作を要求せずに問い合わせる。
キャッシュサーバと権威サーバを兼ねているサーバ*2に問い合わせるときは大切。
dig a mgmn.jp @authoritative.ns.example.com +norecurse dig a mgmn.jp @authoritative.ns.example.com +norec
SOA レコードがとくに見やすくなる。
dig mgmn.jp soa +multiline dig mgmn.jp soa +multi
サービス名指定で許可・禁止
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
下段は development 環境用。
bundle && yarn --frozen-lockfile
pg_dump -Fc mastodon_production -f ~/donbak/pg_backup.dump
pg_dump -Fc mastodon_development -f ~/donbak/pg_backup.dump
RAILS_ENV=production bundle exec rails db:migrate
RAILS_ENV=development bundle exec rails db:migrate
RAILS_ENV=production bundle exec rails tmp:clear assets:clean assets:precompile
RAILS_ENV=development bundle exec rails tmp:clear assets:clean assets:precompile
public/packs を消した場合は OS 再起動したほうがいいかも
より文明的なやり方をみつけたので mastodon-web の reload だけでよさそう
sudo systemctl daemon-reload && sudo systemctl reload mastodon-web && sudo systemctl restart mastodon-sidekiq # サービス稼働状態の確認 sudo systemctl | grep mastodon
RAILS_ENV=development bin/tootctl accounts create --email EMAIL --confirmed USERNAME
RAILS_ENV=development bin/tootctl accounts create --role Owner --email EMAIL --confirmed USERNAME
RAILS_ENV=production bin/tootctl accounts modify --role Owner USERNAME
RAILS_ENV=development bin/tootctl accounts modify --role Owner USERNAME