Ubuntu, ファイルシステムがマウントされていない場合に書き込みを失敗させる

Ubuntu 22.04 ext4ファイルシステム 外部ストレージなどのファイルシステムのマウントに失敗したとき、 定期実行スクリプトやDockerコンテナなどが、実際にはマウントされていないマウントポイント以下に書き込みしてしまう場合があります。 /etc/fstabからnofailの指定を外せば、マウントに失敗した場合にOSが起動しなくなることで誤った操作を防げますが、 外部ストレージと関係のない他のサービスが共存している、遠隔操作を前提とした運用をしている、などの理由で、OSは起動してほしい場合があります。 マウントポイントがext4ファイルシステムにある場合、chattrコマンドを使って、変更を禁止することができます。 /mnt/mystorageのマウントを解除した状態で、以下のように指定します。 chattr +i /mnt/mystorage これによりマウントしている間、immutable属性がなくなり、変更できるようになります。 mount /mnt/mystorage linux - Prevent the possiblity of writing data to an unmounted mount point directory - Server Fault chattr(1): change file attribs on file system - Linux man page

2023年12月9日 · aoirint

Ubuntu 22.04, コマンドラインでパスワードをハッシュ化する(htpasswd bcrypt, doveadm SHA-512, openssl SHA-512)

htpasswd + bcrypt $ sudo apt install apache2-utils $ sudo apt list --installed apache2-utils apache2-utils/jammy-updates,now 2.4.52-1ubuntu4.6 amd64 [installed] $ htpasswd -nB myuser New password: password Re-type new password: password myuser:$2y$05$aw7xqaxQ207POKX8bavQleo52mb1jxRT7WenwvXqW21FA4wnygHjq password - Compute bcrypt hash from command line - Unix & Linux Stack Exchange doveadm + SHA-512 $ sudo apt install dovecot-core $ sudo apt list --installed dovecot-core dovecot-core/jammy-updates,now 1:2.3.16+dfsg1-3ubuntu2.2 amd64 [installed] $ doveadm pw -s SHA512-CRYPT Enter new password: password Retype new password: password {SHA512-CRYPT}$6$jtT1Mdke./dCtWSp$5ptqP0pgduBjHiRHCfh0nrWstAI46Jmytf88VlrJgpMsBPSNVhFG1cdgxkHVAXLporwb0d9pcYskAfFPqdtEy1 security - How to create SHA512 password hashes on command line - Unix & Linux Stack Exchange openssl + SHA-512 $ sudo apt list --installed openssl openssl/jammy-updates,jammy-security,now 3.0.2-0ubuntu1.12 amd64 [installed] $ openssl version OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022) $ openssl passwd -6 Password: password Verifying - Password: password $6$TmbOcErpIJRy.gWH$phJqAZzmdBj206D4kQEJNEq638KJyUwcnLbK61yBQeVsImjIg0SYXeClDjyMFCVCAvjqeNszhwtz1aUtTPKo70 security - How to create SHA512 password hashes on command line - Unix & Linux Stack Exchange LinuxでSHA-512のパスワードハッシュ作成方法まとめ #Python - Qiita

2023年11月1日 · aoirint

Ubuntu コマンドの実行を1度だけスケジュールする(atコマンド)

sudo apt install at コマンドは/bin/shで実行される。 次の18:00に1度だけコマンドを実行 echo 'wondershaper clear eno1' | sudo at 18:00 2023年6月29日 18:00に1度だけコマンドを実行 echo 'wondershaper clear eno1' | sudo at 18:00 2023-06-29 実行スケジュール(ジョブ一覧)を確認する sudo at -l ジョブ1番の実行スケジュールをキャンセルする sudo at -d 1 https://yuya-hirooka.hatenablog.com/entry/2021/01/22/215657

2023年6月28日 · aoirint

Ubuntu ネットワーク帯域を制限する(Wondershaper)

sudo apt install wondershaper # 上下300kbpsに制限 sudo wondershaper eno1 300 300 sudo wondershaper enp0s31f6 300 300 # 下り1000kbps、上り300kbpsに制限 sudo wondershaper eno1 1000 300 sudo wondershaper enp0s31f6 1000 300 # 帯域制限を解除 sudo wondershaper clear eno1 sudo wondershaper clear enp0s31f6 https://askubuntu.com/questions/20872/how-do-i-limit-internet-bandwidth rootユーザで/bin/shによるコマンド実行をスケジュール(atコマンド) echo "wondershaper eno1 300 300" | sudo at 18:00 2023-06-29 echo "wondershaper clear eno1" | sudo at 2:00 2023-06-29

2023年6月28日 · aoirint

Ubuntu ネットワーク通信量をターミナルからグラフで見る(Speedometer)

Ubuntu Server 22.04 sudo apt install speedometer 通信量を見たいネットワークデバイスの名前を調べる(eno1、enp0s31f6、enp3s0、eth0、wlan0など)。 ip addr eno1を目的のデバイスの名前に置き換えて、以下のコマンドを実行する。 speedometer -l -r eno1 -t eno1 -m $(( 1024 * 1024 * 3 / 2 )) # other examples speedometer -l -r enp0s31f6 -t enp0s31f6 -m $(( 1024 * 1024 * 3 / 2 )) speedometer -l -r enp3s0 -t enp3s0 -m $(( 1024 * 1024 * 3 / 2 )) speedometer -l -r eth0 -t eth0 -m $(( 1024 * 1024 * 3 / 2 )) speedometer -l -r wlan0 -t wlan0 -m $(( 1024 * 1024 * 3 / 2 )) 参考 networking - How to display network traffic in the terminal? - Ask Ubuntu

2023年5月19日 · aoirint

Jenkinsのapt GPGキーを更新する

$ sudo apt update Err:9 https://pkg.jenkins.io/debian-stable binary/ Release.gpg The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 5BA31D57EF5975CA W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://pkg.jenkins.io/debian-stable binary/ Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 5BA31D57EF5975CA W: Failed to fetch https://pkg.jenkins.io/debian-stable/binary/Release.gpg The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 5BA31D57EF5975CA W: Some index files failed to download. They have been ignored, or old ones used instead. ...

2023年4月17日 · aoirint

HashiCorpのapt GPGキーを更新する

$ sudo apt update Err:2 https://apt.releases.hashicorp.com focal InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AA16FCBCA621E701 W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://apt.releases.hashicorp.com focal InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AA16FCBCA621E701 W: Failed to fetch https://apt.releases.hashicorp.com/dists/focal/InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AA16FCBCA621E701 W: Some index files failed to download. They have been ignored, or old ones used instead. https://developer.hashicorp.com/terraform/cli/install/apt wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg gpg --no-default-keyring --keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg --fingerprint echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list

2023年1月25日 · aoirint

topコマンドの設定

shift+wで設定を保存 https://unix.stackexchange.com/questions/424486/linux-command-top-saving-configuration shift+mでメモリ使用率順にソート fから項目にSWAPを追加 https://beyondjapan.com/blog/2016/02/change-sort-top/ https://qiita.com/k0kubun/items/7368c323d90f24a00c2f eで表部分のメモリ量スケールを変更 shift+eでサマリー部分のメモリ量スケールを変更

2022年5月22日 · aoirint

CDの取り込み

Ubuntu Rhythmboxで取り込む。 ogg形式に変更する。 EasyTagを使ってID3タグ、アルバムアートを設定する。 Windows Windows Media Playerで取り込む。 初期設定が低ビットレートのMP3になっているので、320kbpsのMP3に変更する。 MP3Tag 2.88aを使ってID3タグ、アルバムアートを設定する。 (Windows版EasyTag 2.4.3は日本語が文字化けしてID3タグの書き込みが動作しないことがある)

2022年3月30日 · aoirint

Ubuntu 20.04, ネットワーク設定変更時の認証を回避する

Ubuntu 20.04にアップデートしてから、ネットワーク設定の変更時(接続のON/OFFなど)にSystem policy prevents control of network connectionsと表示され、認証を要求されるようになりました。 ここまではまだいいのですが、認証が表示されるたびに数秒間デスクトップがハングする状態になっていて、ストレスでした。 Keyringのロックを解除するときも数秒間ハングするので、似た原因がありそうです。 ひとまず、設定変更時の認証を要求されないようにして、ハングを防ぐことを試みました。結果として試みは成功し、ハングを回避できるようになりました。 https://unix.stackexchange.com/questions/534469/system-policy-prevents-control-of-network-connections https://code.luasoftware.com/tutorials/linux/ubuntu-prompt-system-policy-prevents-modification-of-network-settings-for-all-users/ /etc/polkit-1/localauthority/50-local.d/50-allow-network-manager.pkla [Allow Network Manager all Users] Identity=unix-user:* Action=org.freedesktop.NetworkManager.settings.modify.system;org.freedesktop.NetworkManager.network-control ResultAny=no ResultInactive=no ResultActive=yes systemctl restart network-manager.service

2021年11月29日 · aoirint