This is an n8n community node that allows you to execute shell commands on self-hosted n8n instances.
n8n is a fair-code licensed workflow automation platform.
IMPORTANT: This node executes arbitrary commands on your server. It should ONLY be used on self-hosted n8n instances that you control. Never use this node if you don't understand the security implications.
- Commands run with the same permissions as your n8n process
- Malicious commands could damage your system or compromise security
- Always validate and sanitize inputs when using generic command mode
- Consider using templates for common operations to reduce risk
Follow the installation guide in the n8n community nodes documentation.
npm install n8n-nodes-command-executor- Clone this repository
- Run
npm installto install dependencies - Run
npm run buildto build the node - Copy the built files to your n8n custom nodes directory
The Command Executor node supports two modes:
Execute any shell command you specify. This mode gives you complete flexibility but requires careful attention to security.
Example:
echo "Hello from n8n!"Use pre-configured command templates with safe, parameterized inputs. This is the recommended mode for most use cases.
| Template | Description | Parameters |
|---|---|---|
| System Information | Get OS info, disk usage, and memory | None |
| List Files | List files in a directory | Path, Options |
| Read File | Read file contents | File Path |
| Find Files | Find files matching a pattern | Search Path, Pattern |
| Process List | List running processes | Filter (optional) |
| Network Ping | Ping a host | Host, Count |
| HTTP Request (curl) | Make HTTP requests with curl | URL, Options |
| Disk Usage | Show disk usage for a path | Path |
| Execute Python Code | Run Python code or script files | Execution Mode, Interpreter, Code/File Path, Arguments |
| Execute Node.js Code | Run JavaScript code or script files | Execution Mode, Code/File Path, Arguments |
- Working Directory: Set the working directory for command execution
- Timeout: Maximum execution time in seconds (1-300, default: 30)
- Environment Variables: Add custom environment variables for your command
- Continue on Error: If enabled, the workflow continues even if the command fails
The node returns the following data for each execution:
{
"command": "echo 'test'",
"exitCode": 0,
"stdout": "test\n",
"stderr": "",
"executionTimeMs": 45,
"success": true
}Use the "System Information" template to get details about your server:
- Add Command Executor node
- Select Mode: "Template"
- Select Template: "System Information"
- Run the workflow
List all files in a directory with details:
- Add Command Executor node
- Select Mode: "Template"
- Select Template: "List Files"
- Path:
/var/log - Options: "Long format with hidden files (-lah)"
Execute a custom command:
- Add Command Executor node
- Select Mode: "Generic Command"
- Command:
df -h | grep /dev/ - Run the workflow
Use generic mode to backup a database:
mysqldump -u root -p'password' mydb > /backups/mydb_$(date +%Y%m%d).sqlRun Python code inline:
- Add Command Executor node
- Select Mode: "Template"
- Select Template: "Execute Python Code"
- Execution Mode: "Inline Code"
- Python Interpreter: "Python 3"
- Code:
import sys; print(f"Python {sys.version}") - Run the workflow
Or execute a Python script file:
- Execution Mode: "File Path"
- File Path:
/path/to/script.py - Arguments:
--arg1 value1
Run JavaScript code inline:
- Add Command Executor node
- Select Mode: "Template"
- Select Template: "Execute Node.js Code"
- Execution Mode: "Inline Code"
- Code:
console.log(process.version); console.log("Hello from Node!") - Run the workflow
Or execute a JavaScript file:
- Execution Mode: "File Path"
- File Path:
/path/to/script.js - Arguments:
--experimental-modules
git clone https://github.com/your-repo/n8n-nodes-command-executor.git
cd n8n-nodes-command-executor
npm installnpm run buildnpm run devThis will start n8n with your node loaded and watch for changes.
npm run lint
npm run lint:fix- Tested with n8n v1.0+
- Compatible with Node.js v20+
- Initial release
- Generic command execution
- 10 pre-configured templates (including Python and Node.js code execution)
- Environment variable support
- Configurable timeouts and working directory
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
If you have any issues or questions, please open an issue on GitHub or ask in the n8n community forum.
This node is provided as-is with no warranties. Use at your own risk. The authors are not responsible for any damage or security issues that may arise from using this node.