Eridian
eridian.xyzx.comGitHub
  • πŸ“–Eridian Docs
  • Ethereum Dev
    • ✏️Ethereum Notes
      • πŸŽ›οΈTechnical Basics
      • πŸͺ§Ethereum Addresses
      • πŸ“šEthereum State Explained
      • β›½Gas Fees Explained
    • πŸ”§Useful Tools
      • ☁️Ethers
      • *️⃣Ethernal
    • πŸ“Solidity Notes
      • ❔Interview Questions
        • 🟒1. Easy - Interview Questions
        • 🟠2. Medium - Interview Questions
        • 🟑3. Hard - Interview Questions
        • πŸ”΄4. Advanced - Interview Questions
      • πŸ’‘Note Ideas
      • ABI
      • abi.encodePacked
      • Abstract Contracts
      • Arrays
      • Casting
      • CEI - Checks, Effects, Interactions
      • Comments (NATSPEC)
      • Constructor
      • Contract Structure & Versions
      • Data - Storage vs Memory
      • Data - Storage Layout
      • Enum
      • Errors (require & revert)
      • Events
      • EVM Opcodes
      • External Contract Interaction
      • πŸ—οΈExternal Dependencies
      • Functions
      • Function Modifiers
      • If / Else / For / While Loops
      • Inheritance
      • Interfaces
      • Keccak256
      • Library
      • Mappings
      • msg.sender
      • Objects & Types
      • OpenZeppelin
      • Payable
      • Public State Variable vs Function
      • Receive & Fallback
      • Security
      • Self Destruct
      • Send ETH (transfer, send, call)
      • Stack Too Deep
      • Structs
      • Style Guide
      • Time Units
      • Try / Catch
      • Typecasting
      • Using Directive
      • Variables, Consts & Immutable
      • Withdraws
    • βš’οΈFoundry Notes
      • πŸ“–Docs & GitHub Pages
      • 🀝Useful Commands
        • πŸ”¨Anvil
        • πŸͺ„Cast
        • πŸ”₯Forge
      • πŸ§ͺTests
        • Cheatcodes
      • πŸ“Useful Scripts
        • Deploy Contract Using Hex
    • πŸ‘ΎDeFi Challenges
      • πŸ‘¨β€πŸš€Ethernaut
        • Ethernaut - Template
        • Level 1 - Fallback ⏺
        • Level 2 - Fallout ⏺
        • Level 3 - Coin Flip ⏺⏺
        • Level 4 - Telephone ⏺
        • Level 5 - Token ⏺⏺
        • Level 6 - Delegation ⏺⏺
        • Level 7 - Force ⏺⏺⏺
        • Level 8 - Vault ⏺⏺
        • Level 9 - King ⏺⏺⏺
        • Level 10 - Re-entrancy ⏺⏺⏺
        • Level 11 - Elevator ⏺⏺
        • Level 12 - Privacy ⏺⏺⏺
        • Level 13 - Gatekeeper 1 ⏺⏺⏺⏺
        • Level 14 - Gatekeeper 2 ⏺⏺⏺
        • Level 15 - Naught Coin ⏺⏺⏺
        • Level 16 - Preservation ⏺⏺⏺⏺
        • Level 17 - Recovery ⏺⏺⏺
        • Level 18 - Magic Number ⏺⏺⏺
        • Level 19 - Alien Codex ⏺⏺⏺⏺
        • Level 20 - Denial ⏺⏺⏺
        • Level 21 - Shop ⏺⏺
        • Level 22 - Dex ⏺⏺
        • Level 23 - Dex Two ⏺⏺
        • Level 24 - Puzzle Wallet ⏺⏺⏺⏺
        • Level 25 - Motorbike ⏺⏺⏺
        • Level 26 - DoubleEntryPoint ⏺⏺
        • Level 27 - Good Samaritan ⏺⏺⏺
        • Level 28 - Gatekeeper 3 ⏺⏺⏺
        • Level 29 - Switch ⏺⏺⏺⏺
        • Level 30 - Higher Order ⏺⏺⏺⏺
        • Level 31 - Stake ⏺⏺⏺
      • πŸ’ΈDamn Vulnerable DeFi
    • πŸ”Auditing
      • πŸ—žοΈExploit Resources
      • πŸ”§Audit Tools
    • πŸ€–MEV
  • Infrastructure Docs
    • πŸ’»Hardware
    • 🐧Linux
      • πŸ“–Linux Glossary
      • ⌨️Linux Commands
      • πŸ’ΎInstallation
      • πŸ—οΈMaintenance
      • πŸ–₯️Ubuntu Desktop
      • πŸ›œZeroTier
      • 🎞️TMUX
      • πŸ”΅Bluetooth
    • ⛓️Ethereum Clients
      • βš™οΈExecution Clients
        • ⛏️Geth
          • πŸ’ΎInstallation
          • ⌨️Useful Commands
          • πŸ—οΈMaintenance
        • 🐻Erigon
          • πŸ’ΎInstallation
          • ⌨️Useful Commands
          • πŸ—οΈMaintenance
        • 🧢Besu
          • πŸ’ΎInstallation
          • ⌨️Useful Commands
          • πŸ—οΈMaintenance
      • 🀝Beacon Clients
        • πŸ’‘Lighthouse
          • πŸ’ΎInstallation
          • ⌨️Useful Commands
          • πŸ—οΈMaintenance
        • πŸͺ…Teku
          • πŸ’ΎInstallation
          • ⌨️Useful Commands
          • πŸ—οΈMaintenance
      • πŸ’ŽValidator Clients
        • πŸ’‘Lighthouse
          • πŸ’ΎInstallation
          • ⌨️Useful Commands
          • πŸ—οΈMaintenance
      • βž•L2 Clients
        • πŸ”΅Base
          • πŸ’ΎInstallation
          • ⌨️Useful Commands
          • πŸ—οΈMaintenance
      • πŸ’°MEV Boost
        • πŸ’ΎInstallation
        • πŸ—οΈMaintenance
    • 🚨Alerting and Monitoring
      • πŸ”₯Prometheus
      • 🌑️HealthChecks.io
      • πŸ“ŸPagerDuty
  • General Dev
    • πŸ’ΎGit Notes
      • Repos
      • Committing changes
      • Branches
      • Merging & Rebasing
      • PRs
Powered by GitBook
On this page
  • geth.service
  • Geth Direct Queries
  • Geth JavaScript Console
  • Other Useful Commands
  • Data Locations
Edit on GitHub
  1. Infrastructure Docs
  2. Ethereum Clients
  3. Execution Clients
  4. Geth

Useful Commands

Notes on how to use a Geth Client.

All of the alias commands have been defined as aliases in ~/.bashrc wheninstalling Geth.

geth.service

geth-log            # View the geth.service logs
geth-start          # Start the geth.service
geth-stop           # Stop the geth.service
geth-restart        # Restart the geth.service
geth-status         # View the status of the geth.service
geth-version        # Check the version of Geth in use
geth-enable         # Enable the geth.service
geth-disable        # Disable the geth.service
geth-delete-data    # Delete all Geth chain data

geth-config         # Open the /etc/systemd/system/geth.service in vim
daemon-reload       # Reload any changes made to the geth.service

Geth Direct Queries

To make this easier, these commands can be executed directly from the command line without attaching the JS console.

geth-blockNumber
geth-peerCount
geth-nodeInfo

Geth JavaScript Console

Attach to the Geth JavaScript console.

geth-attach

Console commands.

eth.syncing                                            // Check if Geth is syncing
eth.blockNumber                                        // Show the current block number
eth.getTransaction("0x000...."                         // Get details of a specific transaction
eth.syncing.highestBlock - eth.syncing.currentBlock    // Distance remaining to sync
net.listening                                          // Report whether the Geth node is listening for inbound requests
net.peerCount                                          // Show number of active peers
admin.peers                                            // Show info about all peers
admin.peers[0]                                         // Show info about specific peer
admin.nodeInfo                                         // Show info about your own node
admin.peers.map((el) => el.network.inbound)            // You should see both true and false values meaning that your node is discoverable in the P2P network. If you’re seeing only false, you probably did not publicly expose the TCP and UDP port
blockInfo()                                            // Show information about the current block
blockInfo().totalDifficulty                            // Show the current block total difficulty

Exit the Geth JavaScript console.

exit

Other Useful Commands

Checks Geth is running.

GETH_PORT=        # Default 8545

curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}' http://localhost:${GETH_PORT}

Check ports can be accessed.

PORTS_TO_CHECK=        # E.g. 30303,9000

curl https://eth2-client-port-checker.vercel.app/api/checker?ports=${PORTS_TO_CHECK}

Checks the validator status using the validator's public address.

VALIDATOR_HTTP_PORT=        # Lighthouse default: 5052
VALIDATOR_PUBLIC_KEY=       # E.g. 0x88426dd9c3d2bb71ad862a2e47d537304de528e88f5164f6db6ec423f1f7ed24d050c27ae4df45b37d2a4931fc820edf

curl -s http://127.0.0.1:${VALIDATOR_HTTP_PORT}/eth/v1/beacon/states/head/validators/${VALIDATOR_PUBLIC_KEY} |jq

Check validator status using a public endpoint in a browser.

https://beaconstate.info/eth/v1/beacon/states/head/validators/<VALIDATOR_PUBLIC_KEY>

Data Locations

Geth chaindata location.

/var/lib/goethereum/geth/chaindata

Last updated 1 year ago

⛓️
βš™οΈ
⛏️
⌨️