Skip to content

Instantly share code, notes, and snippets.

@zu1k
Last active October 15, 2020 11:15
Show Gist options
  • Save zu1k/f09833c5b74f3c8b35078805d1164ffd to your computer and use it in GitHub Desktop.
Save zu1k/f09833c5b74f3c8b35078805d1164ffd to your computer and use it in GitHub Desktop.
run-shell-with-sudo.sh
#!/usr/bin/env bash
if [[ $EUID -ne 0 ]]; then
if sudo -v ; then
sudo $0
else
echo "请使用root权限运行脚本"
fi
else
# your shell
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment