Stockfish on Ubuntu, which might be unknown to many computer users, is an open-source but strong UCI chess engine that can analyze chess positions and compute optimal moves. It is a command line program and hence does not include a graphical user interface (GUI) but you can develop your GUI or use the ones developed by Stockfish and available online to use.
So, if you’re an avid chess player or an enthusiast looking to enhance your chess experience on your Linux then can install Stockfish on Ubuntu.
In this step-by-step guide, we’ll walk you through the process of installing Stockfish on Ubuntu.
1. Update Your System
It is always a good idea to update your Ubuntu system before installing any new software package. To do that, open your terminal, you can use the keyboard shortcut that is Ctrl+Alt+T or search for it in the application menu. After that run the system update command which will also update your APT package index cache.
sudo apt update && sudo apt upgrade
This command will ensure you have the latest package information on your system.
2. Install Stockfish on Ubuntu 22.04 or 20.04
Stockfish version 14, while writing this article was present to install through the default repository of Ubuntu 22.04. So, to install that you just need to run the given command in your terminal.
sudo apt install stockfish
Those who want Stockfish version 15:
If you want to install version 15 or upgrade the existing 14 to 15 then here are the commands to follow:
sudo dpkg -i stockfish_15.1-4_amd64.deb
Once the installation is complete, you’re ready to use the chess engine.
3. Running Stockfish
With it installed, we can call Stockfish command-line interface (CLI) engine to run the different commands available for it.
To start it, type stockfish in the terminal and press Enter.
Now, you can start sending chess commands to Stockfish and receive responses either through the engine’s command-line interface (CLI) or in a chess graphical user interface (GUI) that supports Stockfish.
Here are some of the essential commands you can use with Stockfish:
- UCI: This command is used to identify and configure the engine when it starts up. It stands for “Universal Chess Interface.” When you run Stockfish, it usually starts with the UCI protocol enabled.
- isready: This command checks if the engine is ready to receive commands. It is often used after the “uci” command to make sure the engine is ready before sending additional instructions.
- ucinewgame: This command informs Stockfish that a new game is about to start. It resets the internal state of the engine, preparing it for a new game.
- position [fen | startpos] [moves …]: This command sets up the board position for analysis or play. You can provide the position in Forsyth-Edwards Notation (FEN) or use “startpos” to set the default starting position. Optionally, you can add a list of moves following the “position” command to set up a specific position.
- go [search parameters …]: The “go” command tells Stockfish to start searching for the best move. It can be followed by various search parameters like “depth,” “movetime,” “nodes,” etc., to control the engine’s search behavior.
- stop: This command instructs Stockfish to stop the search immediately.
- ponderhit: If you’re implementing a chess GUI or using Stockfish with an opponent who plays on its own, the “ponderhit” command indicates that the engine should start considering the opponent’s move as the new position to analyze.
- quit: This command terminates the Stockfish engine and closes the program.
Here’s an example of how to use these commands in the command-line interface:
position startpos moves e2e4 e7e5
go depth 12
In the above-given example, the command is issued sequentially. “usci” command is to initialize the engine, after that, to set up the environment for a new game we used “ucinewgame“. To declare some moves “position” was used and then finally, the engine started searching to a depth of 12 moves with the “go” command.
4. Using Stockfish with a Chess GUI (optional)
Although the command line interface of Stockfish is quite powerful to use on both GUI Ubuntu Desktop and CLI systems, however, if you prefer to have GUI to interact with this chess engine, which will be ofcourse more comfortable; then we can use the Stockfish with popular chess GUIs such as Scid vs. PC, Arena, or XBoard.
Here we discuss, how to install Scid, which is available through the default Ubuntu repository to install, here is the command to follow:
sudo apt install scid
5. Configure SCID Analysis Engine
Once you have installed your preferred chess GUI, like we have used SCID, you can configure it to use Stockfish as the chess engine. Usually, this involves specifying the path to the Stockfish executable in the GUI’s settings.
Those who are using SCID, to configure the StockFish Analysis engine for it, follow the given steps:
- Open SCID GUI, and for that search it in the Application library.
- Next, click on Tools and select Analysis Engine.
- Click on the New button
- After that set – Name = StockFish, Command =
/usr/games/stockfishand for Directory simply click on
- Press the Ok button.
6. Playing Chess with Stockfish
After installing SCID on your Ubuntu you will have a GUI for Stockfish using which you can start playing and analyzing chess games. You just need to load or start a new game within the GUI, and Stockfish will provide analysis and suggested moves as you play.
Whereas those who want to use the command line to play against Stockfish can also do that by providing moves in standard algebraic notation. For example, as we have shown previously in Step 4, just type your move, press Enter key, and the software will respond with its action or analysis.
7. Updating Stockfish (optional)
Over time, if a new version of Stockfish is released through the default system repository of your current Ubuntu Linux release then to upgrade to it you can use the APT package manager again:
sudo apt update
sudo apt upgrade stockfish
Installing Stockfish on Ubuntu Linux is not difficult but yes, you should know how to play chess to get the full benefit of this piece of software.
It will help you to analyze games, improve your skills, and challenge yourself against one of the strongest chess engines available.