Sobes.tech
Junior — Middle

What is the purpose of the `&` operator in the command line or scripts?

sobes.tech AI

Answer from AI

The & operator in the Linux command line and scripts is used to run a command or process in the background.

This means that the command executes concurrently with the current terminal session, and you immediately receive a prompt for new commands without waiting for the launched process to finish.

Example:

sleep 30 &

This command will run sleep for 30 seconds in the background, and you can immediately enter other commands.

This is convenient for running long tasks without blocking the terminal.