表单: LinuxNotes
用户: dreamable
创建日期: 2023-06-28 07:41:42 UTC
更新日期: 2023-06-28 07:41:42 UTC
引用:(Table ID 28, Record ID 12)

标题 :
如何自动重启nginx
笔记 :

服务器nginx偶尔会被杀死,可能是系统资源不够了。

sudo systemctl edit nginx then paste in:

[Service]
Restart=always

check if it works

sudo systemctl status nginx
sudo pkill -f nginx
sudo systemctl status nginx
标签:
表单: LinuxNotes
用户: dreamable
创建日期: 2023-03-10 03:35:42 UTC
更新日期: 2023-03-10 03:43:42 UTC
引用:(Table ID 28, Record ID 11)

标题 :
Install MQTT on Ubuntu 22.04
笔记 :

Install

sudo apt-get install mosquitto mosquitto-clients
sudo mosquitto_passwd -c /etc/mosquitto/passwd <mqtt_user> (set passwd here)
sudo vi /etc/mosquitto/conf.d/default.conf # new file with
  allow_anonymous false # disable anonymous user
  listener 1883 0.0.0.0 # open to all IP, open to localhost by default.
  password_file /etc/mosquitto/passwd # make password work
sudo /etc/init.d/mosquitto restart

Test

mosquitto_sub  -h localhost -u netro -P netrohome -t 'test'
mosquitto_pub -h localhost -u netro -P netrohome -t 'test' -m 'hello'

Increase max open file limit issue

The default max open file is 1024, which may not be enough for large MQTT service, increase it to 65535
# vi /etc/systemd/system.conf
DefaultLimitNOFILE=65536:524288
sudo systemctl daemon-reexec
sudo /etc/init.d/mosquitto restart
# cat /proc/<pid>/limits should be: 
Max open files            65535                524288               files
# count the number of file opened by: 
sudo ls /proc/<pid>/fd | wc -l
标签:
表单: LinuxNotes
用户: dreamable
创建日期: 2022-05-03 23:55:38 UTC
更新日期: 2022-07-07 09:55:10 UTC
引用:(Table ID 28, Record ID 10)

标题 :
LVM 空间跑哪里去了
笔记 :

安装ubuntu,默认LVM,全盘安装。但是装完发现只有100G,另外的130多G去哪里了?

参见guide

扩展

lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
标签:
表单: LinuxNotes
用户: dreamable
创建日期: 2022-04-12 07:25:32 UTC
更新日期: 2022-04-12 07:25:32 UTC
引用:(Table ID 28, Record ID 9)

标题 :
undo remote commits in Git
笔记 :

undo remote commits:

git reset --hard 'xxxxx'

git clean -f -d

git push -f

标签:
表单: LinuxNotes
用户: dreamable
创建日期: 2021-09-08 13:25:30 UTC
更新日期: 2021-09-08 13:25:30 UTC
引用:(Table ID 28, Record ID 8)

标题 :
AWS Elastic IP
笔记 :
  • 保留IP,最多5个
  • 这样EC2重启后IP地址不再变化
  • 有些区域的可以设定reverse DNS,对发送email有帮助
标签:
表单: LinuxNotes
用户: dreamable
创建日期: 2021-08-23 00:18:58 UTC
更新日期: 2021-08-23 00:19:06 UTC
引用:(Table ID 28, Record ID 7)

标题 :
gio mount smb
笔记 :
gio mount smb://<servername>/<sharename>
# enter password
# once the mount is created it will create a temporary path located at  the following path, for example:
# /run/user/1000/gvfs/smb-share\:server\=host.domain.com\,share\=files/
ln -s /run/user/<userid>/gvfs/smb-share\:server\=<servername>\,share\=<sharename>/ ~/<mountpoint>
标签:
表单: LinuxNotes
用户: dreamable
创建日期: 2021-08-22 22:48:47 UTC
更新日期: 2021-08-22 22:59:21 UTC
引用:(Table ID 28, Record ID 6)

标题 :
Ubuntu disable sleep
笔记 :
 sudo -H gedit /etc/systemd/logind.conf
 HandleLidSwitch=ignore
 sudo service systemd-logind restart
 # Still sleep after idle
 sudoedit /etc/UPower/UPower.conf
 Change IgnoreLid to IgnoreLid=true
 service upower restart
# also in /etc/systemd/logind.conf
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
HandleHibernateKey=ignore
HandleSuspendKey=ignore
IdleAction=ignore
IdleActionSec=0
 # Still sleep after idle
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
标签:
表单: LinuxNotes
用户: dreamable
创建日期: 2021-08-22 22:00:21 UTC
更新日期: 2021-08-22 22:00:21 UTC
引用:(Table ID 28, Record ID 5)

标题 :
内网穿透
笔记 :

路由器NAT映射端口,尝试并成功

  1. ssh
  2. rdesktop
  3. smb
标签:
表单: LinuxNotes
用户: dreamable
创建日期: 2021-08-22 21:59:39 UTC
更新日期: 2021-08-22 21:59:39 UTC
引用:(Table ID 28, Record ID 4)

标题 :
Basic HTTP File Server
笔记 :

python3 -m http.server

标签:
表单: LinuxNotes
用户: dreamable
创建日期: 2021-05-12 11:21:28 UTC
更新日期: 2021-05-12 11:21:39 UTC
引用:(Table ID 28, Record ID 3)

标题 :
How do I resolve a ssh connection closed by remote host due to inactivity?
笔记 :

source

  • Add to .ssh/config
TCPKeepAlive yes
ServerAliveInterval 30
  • In command line
ssh -o TCPKeepAlive=yes user@some.host.com
ssh -o ServerAliveInterval=30 user@some.host.com

TCPKeepAlive: This uses the KEEPALIVE option of the TCP/IP protocol to keep a connection alive after a specified interval of inactivity. On most systems, this means 2 hours. So, with the TCPKeepAlive option passed to SSH, the SSH client will send an encrypted packet to the SSH server, keeping your TCP connection up and running.

ServerAliveInterval: This sets a timeout interval in seconds, which is specified by you, from which if no packets are sent from the SSH client to the SSH server, SSH will send an encrypted request to the server for a TCP response. To make that request every 30 seconds:

标签:
表单: LinuxNotes
用户: dreamable
创建日期: 2021-03-19 01:29:17 UTC
更新日期: 2021-03-19 02:11:18 UTC
引用:(Table ID 28, Record ID 2)

标题 :
Mongo DB dump with compress and archive
笔记 :

source

mongodump --db country --gzip --archive=country.archive
mongorestore --gzip --archive=country.archive

NOTE: The archive is mongo-specific format, can't be opened by other tools e.g. tar

标签:
表单: LinuxNotes
用户: dreamable
创建日期: 2021-02-07 08:10:06 UTC
更新日期: 2021-02-07 08:10:06 UTC
引用:(Table ID 28, Record ID 1)

标题 :
How to run a cron job using the sudo command
笔记 :

guide

sudo crontab -e
@hourly rm somefile
标签: