logo
down
shadow

Security of su root in bash script


Security of su root in bash script

Content Index :

Security of su root in bash script
Tag : bash , By : tayles
Date : November 28 2020, 08:01 AM


Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

bash: fail if script is not being run by root


Tag : linux , By : kema
Date : March 29 2020, 07:55 AM
like below fixes the issue I have a bash script that installs some software. I want to fail as soon as possible if it is not being run by root. How can I do that?
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
   echo "This script must be run as root" 1>&2
   exit 1
fi

How to run from PHP a bash script under root user


Tag : php , By : Jonathan
Date : March 29 2020, 07:55 AM
Hope this helps How to run from PHP a bash script under root user (with all permissions) and not nobody user - php default user? , You can use sudo:
exec("sudo /your/script");
nobody ALL = NOPASSWD: /your/script
chown root:root /your/script
chmod 755 /your/script

Bash script - change to root then exit root


Tag : bash , By : ravibits
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further If I am in the middle running a bash script, is there any way to switch over to root user, process a command, and then exit root mode? For example, I'd like to include these commands in the middle of a bash script: , In order to perform the umount as root, use
sudo umount /home/user/myMount

run bash script as root from php page


Tag : bash , By : Brandon
Date : March 29 2020, 07:55 AM
With these it helps This question is similar to sudo in php exec() and they did not arrive at a conclusion.
In your case, since only one bash script needs to be executed in this fashion, considering using setuid instead:
$ su
[enter password]
chown root:root something.sh
chmod 4755 something.sh
exit

Bash Script in Sudoers File, But Want Said Script to Ask for Root Password Under Certain Conditions


Tag : linux , By : Bart van Bragt
Date : March 29 2020, 07:55 AM
wish help you to fix your issue When you are root, you can switch to a regular user at any point with su.
if [ -z "$SUDO_USER" ]; then
    gksudo aptitude
else
    su -c 'gksudo aptitude' "$SUDO_USER"
fi
Related Posts Related QUESTIONS :
  • How to write for loop to fetch data to newly created file?
  • Translate git-log old commiter timestamp to strict ISO 8601 timestamp
  • move files that no not contain specific string
  • How to group by one column and divide the numbers in second column depending from the third
  • Bash get the command that is piping into a script
  • while read line not working on mac with makefile
  • How to redirect A's stdout to B's stdin and B's stdout to A's stdin?
  • echo is not entered into hash table
  • sed an remove everything after the first pattern (only in the line)
  • Bash using cut to separate an IP and Port
  • Can a shebang refer to a remote program?
  • Why I am not getting a value when i call a function within another in a bash script
  • Why does ". myscript" return file-not-found in only one Git for Windows sh.exe?
  • How to parse a rdf format file from command line
  • Unknown shorthand flag: 'd' in -d
  • Why does a pipeline reading from and writing to the same file result in a blank file?
  • why the code inside EOF shows this error?
  • Why should I add wait after done?
  • Script bash : Remove numbers from a file name between "-" and "_"
  • How to pass multiple commands to a single command in bash using &&?
  • Bash Conditional Odd Behavior
  • Shell script read multiple inputs from user
  • Passing variables with spaces to function
  • Is the term trap (of Bash) more accurate than the generic "callback" term in programming?
  • How to extract only specific string matching lines from a multiple lines standard input
  • $BASH_VERSION reports old version of bash on macOS, is this a problem that should be fixed?
  • Using awk to get lines between two patterns
  • -bash: emacs.profile: command not found
  • Write a script (or a command)
  • Using variables within a function (passing in a place holder)
  • Using SED to change name of object in txt
  • kB to MB using awk
  • Can't read with IFS and read
  • Output in Variable
  • change date format from DD/MM/YYYY to YYYY-MM-DD with sed
  • Remove spaces from the end of string
  • AWK Pass Variable to Command
  • Store Output into Variable with a Function
  • Reasons for git commit failure (exiting with non-zero)
  • Split a line of text in bash using SOH delimiter
  • Getting a partial path to a file in a bash script
  • Convert absolute path into relative path given a current directory using Bash
  • Making bash script to check connectivity and change connection if necessary. Help me improve it?
  • How to propagate a signal through a collection of scripts?
  • Inline comments for Bash?
  • Exclude a string from wildcard search in a shell
  • getopts in bash programming
  • How do I extract the values from this data using bash and awk?
  • How do I display a tree of things in Bash?
  • How is using WSL bash in vscode through the remote WSL extension different from using it by selecting as default shell w
  • Read file n chars at a time with bash (without counting the newlines)
  • Makefile target to check for clean git diff
  • What does the statement, f2=${f%????} , mean?
  • Pipenv on VSCode: Why is (pipenv) not displayed on the terminal?
  • Why process substitution with binary doesn't work?
  • Remove file name extension in shell based on pattern
  • Is there some command that would guarantee stop of further processing but not exit terminal?
  • Bash, sed, get 2 specific string from lines from html, store as csv
  • What does the bash read -d '' do?
  • copying files to another folder using bash
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com