Always use the least privilege principle and never run scripts using pwd as root unless necessary. Also, be cautious when handling sensitive information like passwords or other personal details.