Living a Simple Life is a Happy Life

有饭吃,自由自在,就非常开心

How to Enable VNC+xfce on Ubuntu16

| Comments

安装桌面环境和vncserver

1
sudo apt-get install xfce4 vnc4server

启动vncserver

1
vncserver

修改配置文件

1
2
3
4
5
6
7
8
9
10
11
vim ~/.vnc/xstartup


#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
startxfce4 &

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey

修改配置文件后,运行如下命令结束掉之前产生的窗口:1

1
vncserver -kill :1

用vnc client连接后,tab键自动补全用不了,可以进行如下设置

settings -> window manager -> keyboard -> switch window for same application -> clear

Linux下块设备缓存Bcache设置

| Comments

Bcache简介

Bcache是Linux内核块设备层cache,支持多块HDD使用同一块SSD作为缓存盘。它让SSD作为HDD的缓存成为了可能。由于SSD价格昂贵,存储空间小,而HDD价格低廉,存储空间大,因此采用SSD作为缓存,HDD作为数据存储盘,既解决了SSD容量太小,又解决了HDD运行速度太慢的问题。

Bcache是从Linux-3.10开始正式并入内核主线的,因此,要使用Bcache,需要将内核升级到3.10及以上版本才行。

Linux服务器极简安全配置

| Comments

网络知识了解的越多,就越胆小;也许,这就是江湖吧;

当配置一台新的Linux服务器并上线时,其实就是将Server暴露到了炮火横飞的战场上,任何的大意都会让其万劫不复;但由于永恒的人性的弱点,我们总是在安全和便利之间摇摆;

本文希望能提供一种最简单的办法,帮助我们抵抗大多数的炮火;

How to Close Lightning Channels by Lnd-cli?

| Comments

越来越有老年痴呆的倾向,这个命令至少Google过3次了,每次都忘,被自己蠢哭了~~

1
lncli closechannel <fund_txid> [fund_tx_vout_NO]

不要忘了vout_NO,不然会报错”channel not found”

How to Set Systemd Startup Script for Bitcoind?

| Comments

setup bitcoind.service

1
vim /etc/systemd/system/bitcoind.service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
[Unit]
Description=Bitcoin daemon
After=network.target

[Service]
ExecStart=/opt/node/bitcoin/bin/bitcoind -daemon -conf=/opt/node/bitcoin/blockdata/bitcoin.conf -pid=/run/bitcoind/bitcoind.pid
# Creates /run/bitcoind owned by bitcoin
RuntimeDirectory=bitcoind
RuntimeDirectoryPreserve=yes
User=ubuntu
Type=forking
PIDFile=/run/bitcoind/bitcoind.pid
Restart=on-failure
StandardOutput=/var/log/bitcoind.log
StandardError=/var/log/bitcoind.log

# Hardening measures
####################

# Provide a private /tmp and /var/tmp.
PrivateTmp=true

# Mount /usr, /boot/ and /etc read-only for the process.
ProtectSystem=full

# Disallow the process and all of its children to gain
# new privileges through execve().
NoNewPrivileges=true

# Use a new /dev namespace only populated with API pseudo devices
# such as /dev/null, /dev/zero and /dev/random.
PrivateDevices=true

[Install]
WantedBy=multi-user.target

Reload systemctl daemon

1
systemctl daemon-reload

Enabled new bitcoind service

1
systemctl enable bitcoind

Commands to start or stop the service

1
2
systemctl stop bitcoind
systemctl start bitcoind

Show service status

1
systemctl status bitcoind.service

More info in:

https://github.com/bitcoin/bitcoin/tree/master/contrib/init

Xargs Sh -c Skipping the First Argument

| Comments

其实这个问题已经见过很多次了,但是知其然不知其所以然;今天偶尔在stackoverflow上看到了,记录一下;

shell中的arg1, arg2…

在bash shell中,$1, $2代表arg1, arg2,比如

1
2
3
# echo hello world|xargs echo $1 $2

hello world