How to execute bash script without password? [closed] - linux

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I need to execute the script after system boot.
For example:
(sleep 5 && (sudo dhcpcd wlp4s0))
What I need: Executing the script.
What I have: [sudo] password for eugene:
I has been edited /etc/sudoers so:
eugene ALL=NOPASSWD: /home/eugene/dhcpcdstart.sh
But it's ineffectually. How I can to execute the current script without password?
Arch Linux 2013.05.01

I just tested your sudoers configuration and it works (not with dhcpcd, since I don't have it). Just make sure that you put that line at the end of sudoers file containing dhcpcd in the file list (I guess your script has executing rights for eugene user, but dhcpcd doesn't).
eugene ALL=NOPASSWD: dhcpcd_path/dhcpcd

Related

How to execute python script in Linux? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I would like to make a python script that would do some work with interfaces file in Linux.
How I may make this script executable in Linux? I would to open it with sudo and it would do some commands in terminal.
Make callable
chmod u+x <filename here>
first line in file with shebang to determine how the script should be executed:
#!/usr/bin/python3
execute with
./<filename here>

Shebang line in script on NFS mount on Linux client doesn't seem to work [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Here is our test script...
#!/bin/bash
echo "Hello World"
It is on an NFS share that is mounted on a Linux client. If we call the script like this:
./testscript.sh
then we get this:
sh: ./testscript.sh: Permission denied
If we call it like this:
bash ./testscript.sh
then it executes properly. Also, if we run it on the local filesystem, then it executes correctly without the "bash" prepended.
Any way to do this so that the shebang works? By the way, permissions are wide open on this. 777.
Edit 1:
I found the issue.
I had "user" set in the mount options for the NFS mount. Apparently that removes the ability to execute. I changed that and now it seems to be working.
Use the chmod command to set the executable flag:
chmod +x testscript.sh
Then execute it:
./testscript.sh

Linux command line....How do I change from $ to #? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm working with the sed editor and I realize that my command prompt is:
[darkchild#localhost ~]$
How can I change this so that it ends in #....and what does this mean?
for example:
[darkchild#localhost ~]#
A friend told me to write this command #!/bin/bash but it does not change the prompt to #.
Can someone educate me?
Canonically # means root shell. You probably do not actually want to do this, because it would confuse other users of your system. If you do actually want to do this, you can edit the PROMPT variable.
http://tldp.org/HOWTO/Bash-Prompt-HOWTO/
You can run the following command:
set prompt=\[`id -nu`#`hostname -s`\]\#\
This is the root user. You can go to this user using the su command.
More info: http://en.wikipedia.org/wiki/Su_(Unix)

How to change Linux shell in a remote computer that does not support ypchsh [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
How do I change shell in a remote PC? I am logged into a cluster with a Bash and the output I see is
elan#l01:~ $ chsh
chsh: can only change local entries; use ypchsh instead.
elan#l01:~ $ ypchsh
-bash: ypchsh: command not found
Since I have no root privilege there, I can not install ypchsh in the cluster. Is there any other way to change shell without invoking ypchsh?
Note 1:
Browsing, it looks like another user who installed the same software (currently not available for questioning) has .cshrc in his directory, with the right settings. His .bashrc is minimal and has no redirections.
The /etc/passwd has no entry for either of us.
getent passwd
shows entry for both of us, but shows only /bin/bash for both.
Note 2:
The sofware has been developed with autotools, and using bash instead of tcsh is known to have created wrong builds. (I am not changing shell because I fancy it.)
Thank you,
Elan
In your .bashrc, put exec tcsh last.
Once you're in bash in the cluster, why don't you just type tcsh? And if that works, why not just add it as the last line of .bashrc?

How to execute a script on linux ssh...? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
How do I execute a script on ssh? I need to execute:
/scripts/makecpphp
So I have tried run /scripts/makecpphp but it didn't work. Any help would be greatly appreciate. I know for sure that that file exists there.
If the script is on the remote machine:
ssh user#foo.example.com /scripts/makecpphp
If it's on the local machine:
/scripts/makecpphp
If makecpphp is executable, you just need to type:
./scripts/makecpphp
Are you sure it's executable? Note that this does not just apply over ssh, but any time you are running programs via a linux command line.
If it's executable, just do
/scripts/makecpphp
Otherwise you can do (replace $INTERPRETER by the used interpreter, eg bash, python,...)
$INTERPRETER /scripts/makecpphp
First off, do you have the permission to execute it and is it executable?
Secondly, I don't believe you would use run. You'd cd to the directory and then type
./makecpphp
you need to have execute permission on the script.
chmod +x /scripts/makecpphp
then run
/scripts/makecpphp

Resources