Update linux.sh

Partially rewritten code for better compatibility