Shell command to Connect the Printer

Is there a shell command that can be sent from terminal of raspberry pi to connect the printer to octoprint?

yes, you can do this with curl and the API

# connect octoPrint and the printer again
curl -s -X POST  -H "Content-Type: application/json" -H "X-Api-Key":"$OCTOPRINT_X_API_KEY" -d '{"command":"connect"}' http://$PRINT_HOST/api/connection
sleep .5


I cannot remember where I got the instructions from (your Google search is going to be as good as mine), but I found instructions online so that when you insert the USB cable, Octoprint is notified, connects and runs the connect script.