The most recent version of this page is a draft.DiffThis version is outdated by a newer approved version.DiffThis version (2020/12/31 20:03) is a draft.
Approvals: 0/1

This is an old revision of the document!


Access Batocera Linux via ssh

First, make sure that SSH is enabled on your box — by default, on a fresh install, it is enabled. Check your /userdata/system/batocera.conf file and make sure you have:

system.ssh.enabled=1

When SSH is enabled, the only Linux user on a Batocera system is root:

ssh root@batocera.local
  • user is always root
  • the default password is linux
  • if you enabled SYSTEM SETTINGS SECURITY, the root password is visible from this menu.

For passwordless authentication, you can add your public SSH keys (from ~/.ssh/id_rsa.pub on your client machine) to the list of authorized keys on your Batocera box into the file /userdata/system/.ssh/authorized_keys.

Windows users are advised to use Putty to connect through ssh: https://www.putty.org
Linux and MacOSX users can use command line ssh from a terminal.

Once you are connected to batocera, you can use the command-line to operate on the system.

Know that upon connecting, you will be put into the HOME folder of Batocera, this folder is called ~ and is located at /userdata/system.

Using the command line with paths of files can be confusing at first, there are two types of paths:

  • Absolute paths : they will always be the same ones regardless of the current directory you are in, and they start with a / character, for exemple /userdata/saves
  • Relative paths : they are relative to you current position, for exemple, if you are in the /userdata directory, and you use nano system/batocera.conf, you will execute the command nano on the file batocera.conf located in the /userdata/system folder.

If a path, or a filename, contains special characters or spaces, you will need to put either single quotes ' or double quotes " around it

Here is a subset of the commands you might want to know:

  • cd : changes the current working directory [Change Directory], for exemple cd /userdata/roms puts you in the /userdata/roms folder
  • du -sh : gives you the size of the specified element [Disk Usage, Specified, Human-readeable], for exemple du -sh /userdata/roms/snes gives you the size of the snes roms folder (If you use batocera on a PC, and access it from a windows computer with the file manager, the size of some elements may not be accurate, especially for .wine games, so this command lets you see the actual size)
  • ls : lists the files and folders present in the current directory [LiSt].
  • mkdir : creates a directory [MaKe DIRectory], for exemple mkdir content will create a directory called content in the current working directory.
  • nano : opens a command-line text editor for the specified file, for exemple nano /userdata/system/batocera.conf opens the file batocera.conf to edit it, for more infos see this link (external).
  • rmdir : deletes a directory if it is empty [ReMove DIRectory], for exemple rmdir content will delete the directory content if it is empty.
  • rm : deletes a specified file [ReMove], for exemple rm invaders-201226-124223.png will erase the file invaders-201226-124223.png in the current working directory.
  • rm -r : deletes a directory and all the files it contains [ReMove, Recursive], use with caution!
  • reboot : reboots the system
  • pidof : gives a list of PIDs for a running process name, for exemple pidof retroarch returns a number when a retroarch-based emulator is running.
  • kill : kills a process with a given PID, for exemple if pidof retroarch returned 640, then doing kill 640 will terminate the retroarch process.

Sometimes, you might prefer having the output of a command inside a separated text file instead of reading through the command line interface. to do that you can use the > and >> symbols followed by the path of a filename.

for exemple, the command ls gives you the list of all files and folders in your current working directory, if you want to gather this inside a text file named list-files.txt at /userdata/system, you simply need to use:

  • ls > /userdata/system/list-files.txt, the command will return nothing, and instead the files will be listed inside a new file called list-files.txt located in /userdata/system. Running the command again will replace the content of list-files.txt.
  • ls >> /userdata/system/list-files.txt however will add the output of the command to the existing file, without removing the previous infos.

Whenever you are using a command-line, try to understand what you are doing, even if it doesn't seem like it, some of them can be used in harmful ways. for exemple, putting simply > empty.txt without any command will create an empty file called empty.txt in the current working directory, however if you already had a useful file with this name, it'll be empty after this command.

  • access_the_batocera_via_ssh.1609441399.txt.gz
  • Last modified: 3 years ago
  • by fishou