[Ubuntu] hostname 변경

hostname 또는 cat /etc/hostname 을 입력하면 기존 호스트네임을 볼 수 있다. 새로 셋팅하고 싶다면 다음과 같이 한다.

sudo hostnamectl set-hostname my-new-hostname

그리고 빼먹기 쉬운 게 /etc/hosts 이다.

sudo vi /etc/hosts
127.0.0.1    localhost
127.0.1.1    my-old-hostname  # 기존 호스트네임

이전 호스트 네임 부분을 새 호스트 네임으로 바꿔준다.

127.0.0.1    localhost
127.0.1.1    my-new-hostname

이제 reboot 해주자.

sudo reboot

[Ethereum] 우분투에 node 설치

execution layer client로 geth를, consensus layer client로 Prysm을 사용한다.

geth 설치

sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt update
sudo apt install -y geth

확인

geth version

부팅 시 자동 실행

sudo vi /etc/systemd/system/geth.service

[Unit]
Description=Ethereum Geth Node
After=network.target

[Service]
Type=simple
User=dasomoli
ExecStart=/usr/bin/geth --mainnet --syncmode "snap" --datadir "/home/dasomoli/geth/data" --http --http.api web3,eth,txpool --http.addr 0.0.0.0
Restart=always
RestartSec=5
LimitNOFILE=8192

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start geth
sudo systemctl enable geth
sudo systemctl status geth

위에서는 “snap” 방식을 사용했다. sync mode로 “full”도 가능.

도메인을 연결한다면 설정에 다음 설정을 포함해야 한다.

	--http.corsdomain "*" \
	--http.vhosts "*"

IPC로 geth console 연결

geth attach ipc:/home/dasomoli/geth/data/geth.ipc

로그 확인

journalctl -u geth -f

Prysm 설치

mkdir prysm
cd prysm/
sudo apt update
sudo apt install -y wget
wget <https://raw.githubusercontent.com/prysmaticlabs/prysm/master/prysm.sh>
chmod +x prysm.sh

부팅 시 자동 실행

sudo vi /etc/systemd/system/prysm-beacon.service

[Unit]
Description=Prysm Beacon Chain Client
After=network.target

[Service]
Type=simple
User=dasomoli
ExecStart=/home/dasomoli/prysm/prysm.sh beacon-chain \
    --execution-endpoint=http://localhost:8551 \
    --datadir=/home/dasomoli/prysm/data \
    --jwt-secret=/home/dasomoli/geth/data/geth/jwtsecret \
    --accept-terms-of-use \
    --mainnet \
    --checkpoint-sync-url=https://beaconstate.info --genesis-beacon-api-url=https://beaconstate.info
Restart=always
RestartSec=5
LimitNOFILE=8192

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start prysm-beacon
sudo systemctl enable prysm-beacon
sudo systemctl status prysm-beacon

로그 확인

journalctl -u prysm-beacon -f

[Ubuntu] 자동 업데이트 설정

Unattended Upgrade 설치

sudo apt update
sudo apt install unattended-upgrades

자동 업데이트 활성화

sudo dpkg-reconfigure --priority=low unattended-upgrades

설정 파일 편집: sudo vi /etc/apt/apt.conf.d/50unattended-upgrades

Unattended-Upgrade::Allowed-Origins {
    "Ubuntu stable";
    "Ubuntu ${distro_codename}-security";
    "Ubuntu ${distro_codename}-updates";
};

업데이트 주기 설정: sudo vi /etc/apt/apt.conf.d/20auto-upgrades

다음은 패키지 목록 업데이트 간격(1 = 매일), 자동 업데이트 실행 간격 (1 = 매일)

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

로그는 다음에서 확인 가능

less /var/log/unattended-upgrades/unattended-upgrades.log

자동 재부팅 설정: sudo vi /etc/apt/apt.conf.d/50unattended-upgrades

다음은 새벽 2시에 자동 리부팅.

Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "02:00";

우분투 설치 CD를 USB로 부팅

http://unetbootin.sourceforge.net/ 에서 unetbootin 을 다운받는다.
우분투 설치 ISO 파일을 http://www.ubuntu.com/getubuntu/download 에서 다운로드받는다.
미러를 통해 다운로드받는 것이 빠르다.
USB를 꽂고, unetbootin 을 실행시킨 후 Disk image의 ISO 에 다운로드 받은 ISO를 선택한 후 OK를 누른다.

1~4까지 진행된 후 뽑아서 쓰면 된다.
윈도우즈가 깨진 노트북에서 외장하드로 파일 복사(데이터 백업)가 필요해서 사용했다.

iptables 설정

오랜만에 iptables 설정을 하려니 어떻게 했었는지 하나도 기억이 안나더군요.
기억나는건 iptables -L 하나…;;;
할 때만 기억했다가 또 까먹고 또 까먹고.. 이 놈의 돌대가리..;;
암튼 그래서 검색을 해보니 우분투의 community 도움말에 설정 관련 글(https://help.ubuntu.com/community/IptablesHowTo)이 있네요~
참 편리하게 잘 만들어놨네요^^

1. Establicshed 세션 허용
$ sudo iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT

2. 특정 포트 허용
$ sudo iptables -A INPUT -p tcp –dport <포트 번호> -j ACCEPT
<포트 번호> 는 135:139 형식으로 범위를 조절할 수 있다.

3. 그 외 모두 막기
sudo iptables -A INPUT -j DROP

4. 현재 iptables 설정 파일로 저장하기
$ sudo sh -c “iptables-save > /etc/iptables.rules”

5. iptables 설정 파일로 부팅 시에 재설정하기
$ sudo vi /etc/network/interfaces

auto eth0
iface eth0 inet dhcp
 pre-up iptables-restore < /etc/iptables.rules
 post-down iptables-save -c > /etc/iptables.rules

p.s : 본문의 etc/etc 로 해주셔야 합니다. > 나 < 이후에 / 가 붙지 않는 버그가 텍스트큐브에 있는 듯 합니다. -> 티스토리로 이전 후 수정되었습니다.

예제)
1. 특정 IP 대역만 허용

# iptables -A INPUT -p all -s 192.168.0.0/24 -j ACCEPT
# iptables -A INPUT -j DROP

우분투 8.04(Hardy Heron)에서 Eclipse 사용시..

우분투 8.04에서 Eclipse 사용 시 다음과 같은 메시지가 뜬다면!

Could not initialize the application’s security component. The most
likely cause is problems with files in your application’s profile
directory. Please check that this directory has no read/write
restrictions and your hard disk is not full or close to full. It is
recommended that you exit the application and fix the problem. If you
continue to use this session, you might see incorrect application
behaviour when accessing security features.

$HOME/.mozilla/eclipse 폴더를 수동으로 만들어 주시면 됩니다.

출처 : https://bugs.launchpad.net/ubuntu/+source/eclipse/+bug/188380