# How to run system commands in Replit

- Tool: Replit
- Difficulty: Beginner
- Time required: 12 minutes
- Compatibility: All Replit plans (Starter, Core, Pro, Enterprise)
- Last updated: March 2026

## 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.

## Before you start

- 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.

```
# List all files including hidden ones
ls -la

# Show current directory
pwd

# Create a new directory
mkdir src/utils

# View a file's contents
cat .replit

# Check disk usage
du -sh .

# Show running processes
ps 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.

```
# replit.nix example
{ pkgs }: {
  deps = [
    pkgs.nodejs-20_x
    pkgs.htop
    pkgs.curl
    pkgs.wget
    pkgs.imagemagick
  ];
}

# Alternative: add in .replit under [nix]
# [nix]
# 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.

```
# GET request to an API
curl https://httpbin.org/get

# POST request with JSON body
curl -X POST https://httpbin.org/post \
  -H "Content-Type: application/json" \
  -d '{"name": "test", "value": 42}'

# Download a file
wget https://example.com/data.csv

# Test your own app's endpoint
curl http://localhost:3000/api/health

# Show response headers
curl -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.

```
# List all running processes
ps aux

# Kill a specific process by PID
kill 12345

# Force kill a stubborn process
kill -9 12345

# Restart the entire Repl environment
kill 1

# Check resource usage interactively
htop
```

**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.

```
# Initialize a repository
git init

# Stage and commit changes
git add .
git commit -m "Initial commit"

# Check status and log
git status
git log --oneline -10

# Push to GitHub (using token from Secrets)
git remote add origin https://github.com/user/repo.git
git 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 code example

File: `replit.nix`

```nix
# replit.nix — System-level package configuration
# This file controls what system tools are available in your Repl
# Search for packages at: https://search.nixos.org/packages
# After editing, run 'exit' in Shell to reload

{ pkgs }: {
  deps = [
    # Runtime
    pkgs.nodejs-20_x
    pkgs.python311

    # System tools
    pkgs.htop          # Interactive process viewer
    pkgs.curl          # HTTP client
    pkgs.wget          # File downloader
    pkgs.jq            # JSON processor
    pkgs.tree          # Directory visualizer

    # Development tools
    pkgs.nodePackages.typescript-language-server
    pkgs.nodePackages.prettier

    # Media processing (add only if needed)
    # pkgs.imagemagick
    # pkgs.ffmpeg
  ];
}
```

## Common mistakes

- **Trying to use sudo for privileged operations, which is not available on Replit** — undefined Fix: Install system packages through replit.nix instead. Replit uses Nix for package management, not apt or sudo.
- **Expecting Shell changes (installed packages, environment variables) to persist without a restart** — undefined Fix: After editing replit.nix, run exit in Shell. After adding Secrets, run kill 1 to reload the environment.
- **Running npm install globally with -g flag, causing packages to disappear on restart** — undefined Fix: Install packages locally in your project or add tools to replit.nix for persistent system-level availability.
- **Storing passwords or tokens in Shell command history by typing them inline** — undefined Fix: 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

## Frequently asked questions

### What is the difference between Shell and Console in Replit?

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.

### Can I use sudo on Replit?

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.

### How do I install system tools like ffmpeg or ImageMagick?

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.

### What does kill 1 do in Replit?

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.

### Why is a Nix package not found after I added it to replit.nix?

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.

### Can I run Docker containers in Replit Shell?

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.

### How do I check if my Repl is running out of memory?

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.

### Is the Shell file system persistent?

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.

---

Source: https://www.rapidevelopers.com/replit-tutorial/how-to-use-replit-s-terminal-to-perform-system-level-operations-in-a-project
© RapidDev — https://www.rapidevelopers.com/replit-tutorial/how-to-use-replit-s-terminal-to-perform-system-level-operations-in-a-project
