Ubuntu入れたらとりあえずやるやつ

自分的に最低限必要そうなもの

sudo apt update && sudo apt upgrade
sudo apt install -y openssh-server curl tmux zsh tightvncserver blueman ibus-mozc mozc-utils-gui php php-curl php-zip php-mysql php-pgsql php-mbstring php-xml php-gd php-imagick imagemagick
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/googlechrom-keyring.gpg] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list
curl -fsSL https://dl.google.com/linux/linux_signing_key.pub | sudo gpg --dearmor -o /usr/share/keyrings/googlechrom-keyring.gpg
curl -sS https://download.spotify.com/debian/pubkey_6224F9941A8AA6D1.gpg | sudo gpg --dearmor --yes -o /etc/apt/trusted.gpg.d/spotify.gpg
echo "deb http://repository.spotify.com stable non-free" | sudo tee /etc/apt/sources.list.d/spotify.list
sudo apt update
sudo apt install google-chrome-stable spotify-client

さくらのVPS上のモニタのないUbuntuでVino使おうとしたらxRDP使ってた話

あ…ありのまま 今起こった事を話すぜ! 「おれはUbunt標準でVNCが入っていると聞いたからVino使おうと思ったらいつのまにかxRDPを使っていた」 な…何を言っているのかわからねーと思うが  おれも何をされたのかわからなかった…

デスクトップ環境がなかったので設定

sudo apt update
sudo apt-get update
sudo apt-get -y install ubuntu-desktop
sudo shutdown -r now

Vino試してみる

Ubuntuには標準でVinoなるVNCソフトが入っているそうなので、起動してみる。 Display指定しないと私の環境ではうまくいきませんでした。 また、設定変えないとさくらのコントロールパネルから毎回コンソールログインして、画面共有を承認しないといけないので設定も変更。

gsettings list-recursively org.gnome.Vino

gsettings set org.gnome.Vino require-encryption false
gsettings set org.gnome.Vino prompt-enabled false

画面ちっせぇぇえええ

sudo apt install xserver-xorg-video-dummy
sudo vim /usr/share/X11/xorg.conf.d/80-dummy.conf

ダミーのディスプレイ設定

Section "Device"
    Identifier  "Configured Video Device"
    Driver      "dummy"
    VideoRam 256000
EndSection
 
Section "Monitor"
    Identifier  "Configured Monitor"
    HorizSync 5.0 - 1000.0
    VertRefresh 5.0 - 200.0
    # 1920x1080 @ 60.00 Hz (GTF) hsync: 67.08 kHz; pclk: 172.80 MHz
    Modeline "1920x1080" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync
    # 1920x1200 @ 60.00 Hz (GTF) hsync: 74.52 kHz; pclk: 193.16 MHz
    Modeline "1920x1200" 193.16 1920 2048 2256 2592 1200 1201 1204 1242 -HSync +Vsync
EndSection
 
Section "Screen"
    Identifier  "Default Screen"
    Monitor     "Configured Monitor"
    Device      "Configured Video Device"
    DefaultDepth 24
    SubSection "Display"
    Depth 24
    Modes "1920x1200"
    EndSubSection
EndSection

え?なんか画面真っ黒というかグレー

Vinoはセッションごとに起動するので、ログインしてGui画面起こさないと共有できない。。。 なんという。。。

xRDP入れた

sudo apt install xrdp

うそだろ、ってくらい簡単に使えた。インストールしただけですぐ使える。すごい。

アイコンとDockが消えた

なんか消えた。

sudo apt install gnome-tweak-tool

Tweak っていうアプリ使ってGuiから表示設定カスタマイズして表示させた。

以上おしまい。

さくらのVPSのUbuntuで初期ユーザー設定とローカル接続設定

作業用ユーザー作成

初期では ubuntu というユーザーですが、作業用に新規ユーザー作っておいた方が安全かな、と。ついでにroot権限も付与しておく。

sudo adduser <username>
sudo gpasswd -a <username> sudo

現在の設定を確認してローカル接続を設定。

ip addr show
sudo vim /etc/netplan/01-netcfg.yaml

ens4 が空いてたのでここへ設定します。

ens4:
  addresses:
    - <target address>/24

試してみて反映なら try 即時反映なら apply で。

sudo netplan try

コマンドラインからPDFのサイズを圧縮する

GhostScriptを使う

setting で品質を指定する "/screen" < "/ebook" < "/printer" の順。

gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=<setting> -sOutputFile=output.pdf input.pdf

CentOS7でメール受信時にスクリプトを実行する

Postfixの設定

すでにインストール済みのはずなのでアップデートしてから設定。DNSの設定は済んでいるものとする。

yum -y update postfix
cp /etc/postfix/main.cf /etc/postfix/main.cf.org
vi /etc/postfix/main.cf
diff /etc/postfix/main.cf.org  /etc/postfix/main.cf

サブドメイン限定で受信するだけなので編集するのはこれだけ。ユーザーのローカルから処理するように alias_maps の設定も変える。

76a77
> myhostname = noah.rocca.co.jp
113c114
< #inet_interfaces = all
---
> inet_interfaces = all
116c117
< inet_interfaces = 127.0.0.1
---
> #inet_interfaces = 127.0.0.1
386c387,388
< alias_maps = hash:/etc/aliases
---
> #alias_maps = hash:/etc/aliases
> alias_maps = hash:/home/<username>/.aliases

エイリアスに以下を追記して受信時にスクリプト呼び出し。今回、ローカルから処理したいので、ローカル側で以下の設定とした。

touch /home/<username>/.aliases.db
vi /home/<username>/.aliases

test@sub.domain.ltd で受信。

test: "| /home/<username>/commands/bin/script"

Rootで反映して再起動

postalias /home/<username>/.aliases
systemctl restart postfix

なんかあったら以下でログ確認のこと。

tail -f /var/log/maillog

ポートについて

今回は受信だけなので25さえ空けてればOKです。

さくらのVPSでCentOS7にローカル接続の設定

何度やっても忘れますので備忘録。 192.168.0.5 に設定する例です。

nmcli connection up "System eth1"
nmcli c m "System eth1" connection.autoconnect yes
nmcli connection modify "System eth1" ipv4.method manual ipv4.addresses "192.168.0.5/24" connection.autoconnect yes
nmcli connection up "System eth1"
ip addr