dotlinux blog

Linux Fun – Play Old Classic Snake Game in Linux Terminal

Remember the nostalgic charm of the classic Snake game—controlling a growing snake to eat food, avoid collisions, and beat your high score? You can relive (or discover) this retro experience right in your Linux terminal! This guide will show you how to install, play, and customize the Snake game in the Linux command line, blending nostalgia with terminal fun. Whether you’re a Linux enthusiast, a retro gamer, or just seeking a quick, fun break, this walkthrough has you covered.

2026-05

Table of Contents#

What is the Snake Game?#

The Snake game is a timeless arcade-style classic where you control a snake (a growing line of segments) on a grid. The goal is to:

  • Eat Food: Move the snake to consume food (e.g., a colored dot) to grow longer.
  • Avoid Collisions: Don’t hit the grid’s walls, your snake’s own body, or obstacles (if enabled).
  • Score Points: Each food eaten increases your score—longer snakes = higher scores!

Historically, Snake gained fame on early mobile phones (e.g., Nokia’s iconic devices) and has roots in older arcade/computer games. The Linux terminal version retains these core mechanics with a retro, text-based twist.

Installing the Snake Game in Linux Terminal#

We’ll cover two popular methods: nSnake (modern, customizable) and bsdgames (classic Unix games, including a Snake variant).

Method 1: Using nSnake (Feature-Rich Terminal Snake)#

nSnake is an open-source, highly customizable terminal Snake game. It supports speed adjustments, board size changes, color customization, and more.

For Debian/Ubuntu (and Derivatives: Linux Mint, Pop!_OS, etc.)#

Open your terminal and run:

sudo apt update
sudo apt install nsnake

For Fedora/RHEL (and Derivatives: CentOS, AlmaLinux, etc.)#

First, enable the Extra Packages for Enterprise Linux (EPEL) repository (if not already enabled):

sudo dnf install epel-release

Then install nSnake:

sudo dnf install nsnake

For Arch Linux (and Derivatives: Manjaro, EndeavourOS, etc.)#

Use Pacman:

sudo pacman -S nsnake

Method 2: Using bsdgames (Classic Unix Games Package)#

bsdgames includes several retro Unix games, including a Snake-like game (often named snake or snakebites). It’s ideal for pure nostalgic charm.

For Debian/Ubuntu:#

sudo apt update
sudo apt install bsdgames

For Fedora/RHEL:#

sudo dnf install bsdgames

For Arch Linux:#

sudo pacman -S bsdgames

Playing the Snake Game#

We’ll focus on nSnake (more user-friendly), but bsdgames’ Snake follows similar logic.

Controls (for nSnake)#

  • Arrow Keys: Move the snake (up/down/left/right).
  • WASD: Alternative movement (W=up, A=left, S=down, D=right) – enabled by default.
  • Spacebar: Pause/resume the game.
  • Q: Quit the game (during gameplay or pause).

Gameplay Mechanics (nSnake)#

Launch nSnake by typing nsnake in the terminal. You’ll see a grid with your snake (a small segment) and a food item (a colored dot). The goal:

  1. Eat Food: Move the snake to the food. Each meal makes the snake grow (new segments) and spawns new food.
  2. Avoid Collisions: Hitting walls or your snake’s body ends the game.
  3. Score Points: Earn points for each food eaten (longer snake = higher score).

Tips for Success#

  • Plan Moves: As the snake grows, plan paths to avoid self-collision.
  • Use Walls Wisely: In some modes, walls are “hard” (collision = game over), but they can help corner food.
  • Adjust Speed: If the game feels too fast/slow, customize the speed (see “Customizing” section).

Customizing Your Snake Experience#

nSnake offers deep customization via in-game options or a config file (~/.config/nsnake/nsnake.conf).

Adjusting Speed#

  • In-Game: Press P (pause), select OptionsSpeed, and choose from 1 (slow) to 5 (fast).
  • Config File: Edit ~/.config/nsnake/nsnake.conf and modify the speed line (e.g., speed=3).

Changing Board Size#

  • In-Game: Pause → OptionsBoard Size → Choose small, medium, or large.
  • Config File: Edit board_width and board_height (e.g., board_width=40, board_height=20).

Modifying Colors#

  • In-Game: Pause → OptionsColors → Customize snake, food, background, or wall colors.
  • Config File: Edit color values (e.g., snake_color=green, food_color=red) in ~/.config/nsnake/nsnake.conf.

Troubleshooting Common Issues#

Game Fails to Install#

  • Check Repositories: Ensure your package manager is configured (e.g., EPEL for RHEL/Fedora).
  • Update Packages: Run sudo apt update (Debian/Ubuntu) or sudo dnf update (Fedora) before installing.
  • Missing Dependencies: Install missing libraries (e.g., sudo apt install libncurses5-dev for ncurses issues).

Controls Not Responding#

  • Terminal Focus: Click the terminal to ensure it’s active.
  • Keybindings: Some environments override keys—try a different terminal (e.g., xterm, gnome-terminal).

Visual Glitches (Distorted Grid)#

  • Terminal Emulation: Use a UTF-8/ncurses-compatible terminal (most modern terminals work).
  • Font Issues: Try a different terminal font (e.g., “Monospace,” “DejaVu Sans Mono”).

Conclusion#

Playing Snake in the Linux terminal is a delightful mix of nostalgia and technical fun. Whether you use nSnake for customization or bsdgames for retro charm, the terminal offers a unique way to enjoy this classic game. It’s also a reminder that Linux isn’t just for productivity—there’s room for play!

If you love terminal games, explore others like nethack (roguelike), tetris-cli (Tetris), or cmatrix (Matrix-style fun). Happy gaming!

References#