> For the complete documentation index, see [llms.txt](https://unitynodes.gitbook.io/unity-nodes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://unitynodes.gitbook.io/unity-nodes/mainnet-network/story-story-1/useful-commands.md).

# 💡 Useful commands

## ⚙️ Service Commands

### **Check Logs**&#x20;

```sh
sudo journalctl -u story -f -o cat
```

### **Start service**&#x20;

```shell
sudo systemctl start story  
```

### **Stop service**&#x20;

```sh
sudo systemctl stop story 
```

### **Restart service**&#x20;

```sh
sudo systmctl restart story 
```

### **Check status**&#x20;

```sh
sudo systemctl status story 
```

### **Enable Service**&#x20;

```sh
sudo systemctl enable story 
```

### **Reload service**&#x20;

```sh
sudo systemctl daemon-reload
```

### **Disable service** &#x20;

```sh
sudo systemctl disable story 
```

### **Check synchronization status**&#x20;

```sh
while true; do 
  local_height=$(story status | jq -r .sync_info.latest_block_height)
  network_height=$(curl -s https://rpc.story-testnet.unitynodes.app/status | jq -r '.result.sync_info.latest_block_height')
  blocks_left=$((network_height - local_height))

  echo -e "\033[1;33m[Sync Status]\033[0m \033[1;32mNode Height:\033[0m \033[1;37m$local_height\033[0m | \033[1;32mNetwork Height:\033[0m \033[1;37m$network_height\033[0m | \033[1;32mBlocks Left:\033[0m \033[1;31m$blocks_left\033[0m"

  sleep 5
done
```

{% hint style="info" %}
**If&#x20;**<mark style="color:red;">**"Block left - 0"**</mark>**&#x20;- synchronized**
{% endhint %}

### **Check the latest block of your validator**

```sh
story status | jq '.SyncInfo.latest_block_height // .sync_info.latest_block_height'
```

### **View the ports used node**

```sh
ss -tulpn | grep story 
```

***

## ⚙️ Key Command

**Export EVM private key**

```sh
story validator export --export-evm-key
```

***

## ⚙️ Validator Commands

### **Validator details**

```sh
curl localhost:$(sed -n '/\[rpc\]/,/laddr/ { /laddr/ {s/.*://; s/".*//; p} }' $HOME/.story/story/config/config.toml)/status | jq
```

### **Validator private key**

```sh
cat $HOME/.story/story/config/private_key.txt
```

### **Validator pubkey**

```sh
story validator export
```

### Node peer

```sh
echo "$(curl localhost:$(sed -n '/\[rpc\]/,/laddr/ { /laddr/ {s/.*://; s/".*//; p} }' $HOME/.story/story/config/config.toml)/status | jq -r '.result.node_info.id')@$(wget -qO- eth0.me):$(sed -n '/Address to listen for incoming connection/{n;p;}' $HOME/.story/story/config/config.toml | sed 's/.*://; s/".*//')"
```

### Enode info

```sh
geth --exec "admin.nodeInfo.enode" attach ~/.story/geth/iliad/geth.ipc
```

## ⚙️ Tokens Commands

### **Delegate to yourself**

```sh
story validator stake --validator-pubkey $(story validator export | grep "Compressed Public Key (base64)" | awk '{print $NF}') --stake 1000000000000000000 --private-key $(cat $HOME/.story/story/config/private_key.txt | grep "PRIVATE_KEY" | awk -F'=' '{print $2}')
```

### **Delegate to another validator**

```sh
story validator stake --validator-pubkey <VALIDATOR_PUB_KEY_IN_BASE64> --stake 1024000000000000000000 --private-key $(cat $HOME/.story/story/config/private_key.txt | grep "PRIVATE_KEY" | awk -F'=' '{print $2}')
```

### **Unstake from yourself**

```sh
story validator unstake --validator-pubkey $(story validator export | grep "Compressed Public Key (base64)" | awk '{print $NF}') --unstake 1024000000000000000000 --private-key $(cat $HOME/.story/story/config/private_key.txt | grep "PRIVATE_KEY" | awk -F'=' '{print $2}')
```

### **Unstake**

```sh
story validator unstake --validator-pubkey <VALIDATOR_PUB_KEY_IN_BASE64> --unstake 1024000000000000000000 --private-key $(cat $HOME/.story/story/config/private_key.txt | grep "PRIVATE_KEY" | awk -F'=' '{print $2}')
```

## ⚙️ Geth commands

### Check the latest block

```bash
geth --exec "eth.blockNumber" attach ~/.story/geth/iliad/geth.ipc
```

### Peers your client is connected to

```bash
geth --exec "admin.peers" attach ~/.story/geth/iliad/geth.ipc
```

### Check if syncing is still in progress:&#x20;

will output <mark style="color:red;">"true"</mark> if geth is syncing

```bash
geth --exec "eth.syncing" attach ~/.story/geth/iliad/geth.ipc
```

### Check gas price

```bash
geth --exec "eth.gasPrice" attach ~/.story/geth/iliad/geth.ipc
```

### Check account balance

```bash
geth --exec "eth.getBalance('<YOUR_EVM_ADDRESS>')" attach ~/.story/geth/iliad/geth.ipc
```

## ⚙️ Utility

### **Set Custom Port**

```bash
#CHANGE PORT
STORY_PORT=33
sed -i.bak -e "s%:26658%:${STORY_PORT}658%g;
s%:26657%:${STORY_PORT}657%g;
s%:26656%:${STORY_PORT}656%g;
s%^external_address = \"\"%external_address = \"$(wget -qO- eth0.me):${STORY_PORT}656\"%;
s%:26660%:${STORY_PORT}660%g" $HOME/.story/story/config/config.toml
```

### **Reset node**

```sh
story tendermint unsafe-reset-all --home $HOME/.story/story --keep-addr-book
```

### **Update server name**

```sh
 sudo hostnamectl set-hostname server_name
```

### **How much SSD use node (currently)**

```sh
du -sh $HOME/.story
```

### **How much RAM use node (currently)**

```sh
sudo systemctl status story | grep "Memory:"
```

### **How much CPU use node (currently)**

```sh
ps -C story -o %cpu --no-headers | awk '{print $1"% CPU"}'
```

### **Delete node**

```sh
sudo systemctl stop story-geth
sudo systemctl stop story
sudo systemctl disable story-geth
sudo systemctl disable story
sudo rm /etc/systemd/system/story-geth.service
sudo rm /etc/systemd/system/story.service
sudo systemctl daemon-reload
sudo rm -rf $HOME/.story
sudo rm $HOME/go/bin/story-geth
sudo rm $HOME/go/bin/story
```
