Skip to main content
RapidDev - Software Development Agency
replit-tutorial

How to run system commands in Replit

Replit's Shell tab is a full Linux terminal powered by Nix where you can run system commands, install packages, manage processes, and interact with Git. Open Shell from the Tools dock, run standard commands like ls, curl, wget, and htop, install system packages via replit.nix, and use kill 1 to restart the environment when processes get stuck. The Shell is separate from the Console, which only shows output from the Run button.

What you'll learn

  • Open and use the Shell tab for interactive system commands
  • Install system-level packages through replit.nix
  • Use curl and wget to interact with APIs and download files
  • Manage and kill processes when your Repl gets stuck
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner8 min read12 minutesAll Replit plans (Starter, Core, Pro, Enterprise)March 2026RapidDev Engineering Team
TL;DR

Replit's Shell tab is a full Linux terminal powered by Nix where you can run system commands, install packages, manage processes, and interact with Git. Open Shell from the Tools dock, run standard commands like ls, curl, wget, and htop, install system packages via replit.nix, and use kill 1 to restart the environment when processes get stuck. The Shell is separate from the Console, which only shows output from the Run button.

How to Run System Commands in Replit's Terminal

Replit is a browser-based IDE, but underneath it runs a full Linux environment with Nix package management. The Shell tab gives you command-line access to install system tools, manage files, run scripts, monitor processes, and interact with external services via curl or wget. This tutorial covers the most common system operations you can perform in Replit's Shell.

Prerequisites

  • A Replit account (free Starter plan works)
  • An existing Repl or the ability to create a new one
  • Basic familiarity with terminal or command-line concepts

Step-by-step guide

1

Open the Shell from the Tools dock

In your Replit workspace, find the Tools dock on the left sidebar. Click the Shell icon to open an interactive Linux terminal. If you do not see it, use the search bar at the top and type Shell. The Shell pane opens inside your workspace with a blinking cursor ready for commands. You can resize it by dragging the pane border, float it into a separate window from the three-dot menu, or open multiple Shell instances by clicking the plus icon next to the tab.

Expected result: A Shell pane opens with a blinking cursor, ready to accept Linux commands.

2

Run basic file and system commands

The Shell supports standard Linux commands. Use ls to list files, pwd to print your current directory, mkdir to create directories, cp and mv to copy and move files, and rm to delete them. Use cat to view file contents and head or tail for partial views. The command history is available with the up arrow key, and tab completion works for file names and commands.

typescript
1# List all files including hidden ones
2ls -la
3
4# Show current directory
5pwd
6
7# Create a new directory
8mkdir src/utils
9
10# View a file's contents
11cat .replit
12
13# Check disk usage
14du -sh .
15
16# Show running processes
17ps aux

Expected result: Commands execute and display output directly in the Shell pane, just like any Linux terminal.

3

Install system packages with replit.nix

Replit uses Nix to manage system-level tools beyond npm or pip packages. To add tools like htop, curl, wget, ffmpeg, or ImageMagick, edit the replit.nix file. Search for available packages at search.nixos.org/packages to find the correct name. After editing replit.nix, type exit in Shell to restart the environment and load new packages. You can also add quick packages directly in the .replit file under [nix] packages.

typescript
1# replit.nix example
2{ pkgs }: {
3 deps = [
4 pkgs.nodejs-20_x
5 pkgs.htop
6 pkgs.curl
7 pkgs.wget
8 pkgs.imagemagick
9 ];
10}
11
12# Alternative: add in .replit under [nix]
13# [nix]
14# packages = ["htop", "curl", "wget"]

Expected result: After running exit in Shell, the new packages are installed and available as commands.

4

Use curl and wget for API calls and downloads

Curl and wget let you interact with external APIs and download files directly from Shell. Use curl to test API endpoints, send POST requests, and check response headers. Use wget to download files. Both tools are pre-installed in most Replit environments. These are useful for testing your app's API endpoints, downloading configuration files, or verifying external service connectivity.

typescript
1# GET request to an API
2curl https://httpbin.org/get
3
4# POST request with JSON body
5curl -X POST https://httpbin.org/post \
6 -H "Content-Type: application/json" \
7 -d '{"name": "test", "value": 42}'
8
9# Download a file
10wget https://example.com/data.csv
11
12# Test your own app's endpoint
13curl http://localhost:3000/api/health
14
15# Show response headers
16curl -I https://example.com

Expected result: API responses or downloaded files appear in Shell. You can verify your endpoints work correctly before deploying.

5

Manage processes and recover from stuck states

When a process hangs or your Repl becomes unresponsive, use Shell to diagnose and fix the problem. Run ps aux to see all running processes. Use kill followed by the process ID to stop a specific process. The most powerful recovery command is kill 1, which restarts the entire Repl environment including reloading Nix packages and environment variables. This is also required after adding new Secrets to make them available in Shell.

typescript
1# List all running processes
2ps aux
3
4# Kill a specific process by PID
5kill 12345
6
7# Force kill a stubborn process
8kill -9 12345
9
10# Restart the entire Repl environment
11kill 1
12
13# Check resource usage interactively
14htop

Expected result: Stuck processes are terminated and the Repl environment recovers. After kill 1, the environment restarts fresh with all current secrets and Nix packages.

6

Use Git from the command line

The Shell includes git, gh (GitHub CLI), and glab (GitLab CLI) for version control operations. While Replit has a visual Git pane, Shell gives you full control for advanced operations like cherry-picking, rebasing, and managing multiple remotes. For private repositories, store your GitHub personal access token in Tools → Secrets as GIT_URL and use it for push operations. For teams managing complex Git workflows on Replit, RapidDev provides guidance on branching strategies and CI/CD integration.

typescript
1# Initialize a repository
2git init
3
4# Stage and commit changes
5git add .
6git commit -m "Initial commit"
7
8# Check status and log
9git status
10git log --oneline -10
11
12# Push to GitHub (using token from Secrets)
13git remote add origin https://github.com/user/repo.git
14git push -u origin main

Expected result: Git commands execute in Shell, allowing you to commit, push, pull, and manage your repository from the command line.

Complete working example

replit.nix
1# replit.nix System-level package configuration
2# This file controls what system tools are available in your Repl
3# Search for packages at: https://search.nixos.org/packages
4# After editing, run 'exit' in Shell to reload
5
6{ pkgs }: {
7 deps = [
8 # Runtime
9 pkgs.nodejs-20_x
10 pkgs.python311
11
12 # System tools
13 pkgs.htop # Interactive process viewer
14 pkgs.curl # HTTP client
15 pkgs.wget # File downloader
16 pkgs.jq # JSON processor
17 pkgs.tree # Directory visualizer
18
19 # Development tools
20 pkgs.nodePackages.typescript-language-server
21 pkgs.nodePackages.prettier
22
23 # Media processing (add only if needed)
24 # pkgs.imagemagick
25 # pkgs.ffmpeg
26 ];
27}

Common mistakes when running system commands in Replit

Why it's a problem: Trying to use sudo for privileged operations, which is not available on Replit

How to avoid: Install system packages through replit.nix instead. Replit uses Nix for package management, not apt or sudo.

Why it's a problem: Expecting Shell changes (installed packages, environment variables) to persist without a restart

How to avoid: After editing replit.nix, run exit in Shell. After adding Secrets, run kill 1 to reload the environment.

Why it's a problem: Running npm install globally with -g flag, causing packages to disappear on restart

How to avoid: Install packages locally in your project or add tools to replit.nix for persistent system-level availability.

Why it's a problem: Storing passwords or tokens in Shell command history by typing them inline

How to avoid: Store credentials in Tools → Secrets and reference them as environment variables like $MY_TOKEN in Shell.

Best practices

  • Use Shell for interactive commands and system operations; use Console only to monitor Run button output
  • Always search for Nix package names at search.nixos.org/packages before adding them to replit.nix
  • Run exit in Shell after editing replit.nix to reload the Nix environment with new packages
  • Use kill 1 to restart the Repl environment after adding Secrets or when the workspace becomes unresponsive
  • Monitor resources via the Resources panel (or htop in Shell) to avoid out-of-memory crashes
  • Store GitHub tokens in Tools → Secrets, never in Shell history or code files
  • Open multiple Shell instances for parallel tasks instead of running everything in one tab
  • Use curl to test your API endpoints locally before deploying

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I need to install ffmpeg and imagemagick on Replit to process images in my Node.js project. How do I add system packages using replit.nix and verify they are available in Shell?

Replit Prompt

My Replit app is frozen and the Run button does nothing. Show me how to use Shell to find and kill the stuck process, then restart the environment cleanly. Also check if there is a Nix error by reading /run/replit/env/error.

Frequently asked questions

Shell is an interactive Linux terminal where you type commands, install packages, and manage files. Console is read-only and only shows output when you click the Run button. Client-side JavaScript logs appear in Preview DevTools, not in either Shell or Console.

No. Replit does not provide root or sudo access. Install system packages through replit.nix or the Dependencies GUI instead. Nix handles package management without requiring elevated privileges.

Add them to your replit.nix file under the deps array (e.g., pkgs.ffmpeg, pkgs.imagemagick). Search for the correct package name at search.nixos.org/packages, then run exit in Shell to reload.

kill 1 sends a signal to process ID 1, which is the init process in Replit's container. This restarts the entire environment, reloading Nix packages, environment variables, and clearing stuck processes. It does not delete your files.

You need to run exit in Shell after editing replit.nix to restart the environment. Also verify the package name at search.nixos.org/packages — wrong names cause a Nix build error.

No. Replit does not support Docker. The platform uses Nix for environment management. If you need specific tools, add them to replit.nix instead of trying to run containers.

Click the Resources panel icon (stacked computers) in the left sidebar to see real-time RAM and CPU usage. You can also run htop in Shell for a detailed interactive process viewer. The Starter plan has 2 GiB RAM, Core has 8 GiB.

In the workspace, yes — files persist across sessions. In deployments, no — the file system resets every time you publish. Store persistent data in Replit's PostgreSQL database or Object Storage.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.