You can run multiple commands as sudo
by separating the commands with a semicolon (;) or by using a shell script.
- Using semicolon:
sudo command1 ; sudo command2 ; sudo command3
- Using a shell script:
Create a shell script with the commands you want to run, make it executable and then run it with sudo
:
command1
command2
command3
chmod +x script.sh
sudo ./script.sh
Note: Running multiple commands as sudo
can be dangerous, as it gives the commands elevated privileges. Make sure that the commands you run with sudo
are safe and necessary.