Use the system method to run a system command from Ruby:

system("ls")

command output

System can return 3 possible values:

  • true if the command worked
  • false if the command returns an error code
  • nil if command execution fails (command not found)

👉 More info