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 ネットワーク通信量をターミナルからグラフで見る(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

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

GNOME Shell Extension おすすめ

Pixel Saver ウインドウを最大化したとき、macOSのようにタイトルバーをタスクバーに統合。 https://extensions.gnome.org/extension/723/pixel-saver/ https://github.com/pixel-saver/pixel-saver sudo apt install gnome-shell-extension-pixelsaver gTile 画面にウインドウを割り付けるメニュー。 https://extensions.gnome.org/extension/28/gtile/ https://github.com/gTile/gTile Add to Desktop デスクトップにショートカット(*.desktopファイル)を作成するメニュー。 https://extensions.gnome.org/extension/3240/add-to-desktop/ https://github.com/Tommimon/add-to-desktop Screenshot Locations スクリーンショットの保存先ディレクトリを変更するメニュー(GNOME Tweaksから設定)。 https://extensions.gnome.org/extension/1179/screenshot-locations/ https://codeberg.org/kiyui/gnome-shell-screenshotlocations-extension Sound input & output device chooser 電源メニューに音声デバイス選択を追加。 https://extensions.gnome.org/extension/906/sound-output-device-chooser/ https://github.com/kgshank/gse-sound-output-device-chooser

2021年11月14日 · aoirint

Ubuntu 20.04, 自動ログイン+Chrome Remote Desktopの起動時に繰り返し認証を求められる

Chrome Remote Desktopを導入したUbuntu 20.04に自動ログインを設定すると、 初回の認証はkeyringのロックを解除する認証だが、ほかにも5回程度繰り返し認証を求められる。 以下のようなメッセージが表示される。 Authentication is required to create a color managed device 以下のファイルのうち、いずれかを作成することで、追加の認証をスキップできる。 /etc/polkit-1/localauthority.conf.d/02-allow-colord.conf https://god-support.blogspot.com/2019/11/ubuntu1804-xrdp-authentication-is.html polkit.addRule(function(action, subject) { if (( action.id == "org.freedesktop.color-manager.create-device" || action.id == "org.freedesktop.color-manager.create-profile" || action.id == "org.freedesktop.color-manager.delete-device" || action.id == "org.freedesktop.color-manager.delete-profile" || action.id == "org.freedesktop.color-manager.modify-device" || action.id == "org.freedesktop.color-manager.modify-profile" ) && subject.isInGroup("{users}") ) { return polkit.Result.YES; } }); /etc/polkit-1/localauthority/50-local.d/45-allow-colord.pkla https://www.cagylogic.com/archives/2021/03/23145121/11743.php [Allow Colord all Users] Identity=unix-user:* Action=org.freedesktop.color-manager.create-device;org.freedesktop.color-manager.create-profile;org.freedesktop.color-manager.delete-device;org.freedesktop.color-manager.delete-profile;org.freedesktop.color-manager.modify-device;org.freedesktop.color-manager.modify-profile ResultAny=no ResultInactive=no ResultActive=yes

2021年11月13日 · aoirint

Ubuntu 20.04, Unattended Upgradesを停止

https://unix.stackexchange.com/questions/470709/how-do-i-stop-disable-unattended-upgrades-from-being-launched-automatically 勝手にnvidia driverの更新が走って、 カーネルに読み込まれているdriverバージョンと、 ディスク上にあるdriverバージョンが一致しなくなって、 デスクトップアプリが起動しなくなったりする。 どうせ結構な頻度でapt upgradeするし、 再起動が保証されないタイミングで更新されて、 不安定になるのはいただけない。 sudo dpkg-reconfigure -plow unattended-upgrades これでTUIが起動するので、<No>を選ぶ。

2021年11月8日 · aoirint