/replit-tutorials

How to run system commands in Replit

Learn how to run system commands in Replit with simple steps, tips, and examples to streamline your workflow and build projects faster

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to run system commands in Replit

To run system commands in Replit, you usually open the built‑in Shell and type the command exactly as you would on a normal Linux machine. Replit containers run on Linux, so most common commands (like ls, mkdir, pip, npm, git) work normally. You can also run system commands from inside your code using functions like child_process.exec in Node.js or subprocess.run in Python, as long as the command is allowed in the Replit environment. Just keep in mind that Replit is sandboxed: you can’t install system-level packages or run privileged commands, and anything you install with apt won’t persist across restarts.

 

Where and how to run system commands

 

Replit gives you a Shell (sometimes labelled “Console” when it’s running your program). The Shell is the true system terminal. This is where you type commands exactly like on Linux. If a junior dev asks “Where do I run this command?”, 99% of the time the correct answer is “Open the Shell panel and paste it there”.

  • The Shell is persistent during your session, but not across container rebuilds.
  • Commands like ls, pwd, git status, npm install, pip install all work.
  • Commands requiring sudo or system-level installation (like apt-get install) will fail or not persist.

 

// Example: installing a Node package from the shell
npm install dayjs

 

Running system commands inside your code (Node.js)

 

If you need to run a system command from your Node program, use the standard Node module child\_process. This works in Replit exactly the same as locally.

import { exec } from "child_process"

exec("ls -la", (err, stdout, stderr) => {
  if (err) {
    console.error("Error running command:", err)
    return
  }
  console.log("Command output:")
  console.log(stdout)
})

 

  • This runs ls -la in the Replit container.
  • Output appears in your program’s Console, not the Shell.
  • Make sure commands don’t rely on interactive prompts.

 

Running system commands inside your code (Python)

 

Python’s subprocess module works normally in Replit.

import subprocess

result = subprocess.run(["ls", "-la"], capture_output=True, text=True)
print(result.stdout)

 

  • Useful when a script needs to call a CLI tool.
  • Commands still obey Replit’s sandbox limits.

 

Important limitations in Replit

 

Replit is powerful, but it’s not a full root-level server. Many junior devs get tripped up thinking they can treat it like a VPS. Here are the realistic boundaries.

  • No sudo: You can’t run sudo or elevate privileges.
  • No persistent apt installs: Even if apt appears to run, packages will not persist after the container resets.
  • Filesystem resets: Temporary files outside your workspace may be deleted.
  • Heavy background processes die: Long-running system commands may be killed when the repl sleeps.

 

When to use Shell vs running commands in code

 

  • Use Shell when installing packages, checking files, or debugging.
  • Use commands-in-code only when your application truly needs to call an external CLI.
  • For anything build-related (npm, pip, git), the Shell is the cleanest and most predictable path.

 

A small sanity pattern for juniors

 

If you’re ever unsure “Will this system command work in Replit?”, check this mental checklist:

  • Does it require sudo? Then it won’t work.
  • Does it install system software? It won’t persist.
  • Is it a simple CLI command? It will probably work fine.
  • Is it part of your language environment (pip, npm)? Then it works great.

Using system commands in Replit is easy once you understand the container limits. Stay inside those guardrails, and everything runs smoothly.

Still stuck?
Copy this prompt into ChatGPT and get a clear, personalized explanation.

This prompt helps an AI assistant understand your setup and guide you through the fix step by step, without assuming technical knowledge.

AI AI Prompt

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022