TradeLabs AILearn

Linux for Traders

The Linux skills traders need to run bots on servers: the command line, files, processes, services with systemd, logs, scheduling, SSH security and updates.

Advanced3 min readUpdated 3 Oct 2026
Markdown
Lesson 3 of 16

Most of the world's servers run Linux, including nearly all trading systems at professional firms and most cloud servers that retail traders rent. You do not need to become a systems administrator to run a trading bot, but a working knowledge of the Linux command line lets you deploy code, keep it running, read its logs and fix problems without guesswork. This lesson covers the essentials, in the order you will need them.

Connecting with SSH#

SSH (Secure Shell) gives you a command line on a remote server.

ssh trader@203.0.113.10

Use SSH keys instead of passwords, and disable password login on the server. Keep your private key safe; anyone with it can log in.

Core commands#

CommandDoes
ls, cd, pwdList, change and show directories
cat, less, tail -fView files; follow a log as it grows
cp, mv, rm, mkdirCopy, move, delete files, make folders
grepSearch text, such as errors in logs
ps, top, htopSee running processes and resource use
df -h, du -shDisk space
free -hMemory
chmod, chownFile permissions and ownership
sudoRun a command as administrator

Running a bot as a service#

A bot started in an SSH session stops when you disconnect. A systemd service runs in the background, starts at boot and restarts after crashes.

# /etc/systemd/system/mybot.service
[Unit]
Description=My trading bot
After=network-online.target

[Service]
User=trader
WorkingDirectory=/home/trader/bot
EnvironmentFile=/home/trader/bot/.env
ExecStart=/home/trader/bot/.venv/bin/python main.py
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

Then run sudo systemctl enable --now mybot to start it, systemctl status mybot to check it and journalctl -u mybot -f to follow its logs.

Scheduling tasks#

Cron runs commands on a schedule, such as downloading data after the close.

# minute hour day month weekday command
30 21 * * 1-5 /home/trader/bot/.venv/bin/python /home/trader/bot/download.py

Remember that cron uses the server's time zone; set servers to UTC and convert schedules accordingly. See Timestamps, Time Zones and Daylight Saving.

Logs and disk space#

Logs grow forever unless rotated. Use logrotate or systemd's journal limits, and alert when disk usage passes a threshold. A full disk can stop a database and crash a bot. See Monitoring and Logging Systems.

Security basics#

PracticeWhy
SSH keys only, no root loginBlocks password guessing
Firewall (such as ufw) allowing only needed portsReduces attack surface
Automatic security updatesPatches known vulnerabilities
A non root user for the botLimits damage if compromised
Secrets in protected files, not codeKeeps keys out of repositories
fail2ban or similarBlocks repeated failed logins

Clock synchronisation#

Make sure time synchronisation is active (timedatectl status). A drifting clock corrupts timestamps and can cause signed API requests to be rejected. See Clock Synchronization and PTP.

Deploying updates safely#

When you change your bot, avoid editing files directly on the live server. Commit the change to git, pull it on the server, install any new requirements and restart the service during a quiet period, never with open orders you cannot watch. Keep the previous version easy to restore, for example by tagging releases, so a bad update can be rolled back in one command. Check the logs right after the restart to confirm the bot connected, loaded its state and reconciled positions with the broker before it trades. A short written checklist for deploys prevents the rushed mistakes that cause most outages. See Developing, Testing and Monitoring Algorithms and Trade Accounting and Reconciliation.

Frequently asked questions#

Do I need Linux to run a trading bot?#

Not strictly, but most servers run Linux, and it is the most common, cheapest and best supported choice for bots that run unattended.

How do I keep a Python bot running on Linux?#

Run it as a systemd service with automatic restart, or in a container managed by a supervisor. See Docker and Kubernetes.

How do I see my bot's logs on Linux?#

For a systemd service, use journalctl -u servicename -f; for log files, use tail -f on the file.

Next, learn how networks affect trading in Networking for Traders.

Check your understanding

3 quick questions on this lesson. Get them all right to finish it.

Turn on JavaScript to take the quiz.

Finished this lesson?Sign in to save your progress across devices.
Next lessonNetworking for TradersThe networking basics behind trading: latency and distance, TCP versus UDP, multicast market data, packet loss, jitter and practical ways to improve connectivity.

Mentioned in