dreamable/LinuxNotes
ID 标题 笔记 标签
8
AWS Elastic IP
  • 保留IP,最多5个
  • 这样EC2重启后IP地址不再变化
  • 有些区域的可以设定reverse DNS,对发送email有帮助
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>
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
5
内网穿透

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

  1. ssh
  2. rdesktop
  3. smb
4
Basic HTTP File Server

python3 -m http.server

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:

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

mongodb
1
How to run a cron job using the sudo command

guide

sudo crontab -e
@hourly rm somefile