Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 5 days ago.
Improve this question
For some reason I was trying to set up homebrew based from some youtuber and I got this error everytime I launch my terminal.
Error: Unknown command: sellenv
is it possible to remove it ?
Thanks in advance!
this is my 1st mac(M1 macbook air) and I have totally no idea what I have done to it...
I think your problem is that sellenv isn't existing. You provided not enough information to say it exactly, but you should try to replace the occurences from "sellenv" with "shellenv".
Try to execute these commands in terminal in this order:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval "$(which brew shellenv)"' >> $HOME/.zshrc
eval "$(which brew shellenv)"
If that is done, run:
brew doctor
You should get following output:
Your system is ready to brew
Related
This question already has answers here:
How can I check if a program exists from a Bash script?
(39 answers)
Closed 2 years ago.
I want to check whether a program like firefox exists on ubuntu or not. In case it is not installed, I want to install it. I studied this topic and got information about command -v p programName, but I didn't understand how can I check if the program is installed or not. I want to write this:
#If firefox not installed:
sudo apt-get update
sudo apt install firefox
but I don't know how to write the if condition part.
#!/usr/bin/env sh
if ! command -v firefox >/dev/null 2>&1
then
sudo apt-get update
sudo apt install firefox
fi
Also notice that not all Linux systems use apt-get and that if sudo is
configured to request a password the script will stall and wait for
user to type a password which might be confusing.
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 would like to run sudo with my password as parameter so that I can use it for a script. I tried
sudo -S mypassword execute_command
but without any success. Any suggestions?
The -S switch makes sudo read the password from STDIN. This means you can do
echo mypassword | sudo -S command
to pass the password to sudo
However, the suggestions by others that do not involve passing the password as part of a command such as checking if the user is root are probably much better ideas for security reasons
You can set the s bit for your script so that it does not need sudo and runs as root (and you do not need to write your root password in the script):
sudo chmod +s myscript
echo -e "YOURPASSWORD\n" | sudo -S yourcommand
One option is to use the -A flag to sudo. This runs a program to ask for the password. Rather than ask, you could have a script that just spits out the password so the program can continue.
# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I recently installed Ruby on my mac using this following command:
brew install rbenv ruby-build
I was then instructed to enter this command to add rbenv to bash so it loads every time the terminal is open:
# Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile
Now, everytime I open the terminal I get this error:
Last login: Sun Sep 6 17:30:09 on ttys000
-bash: /Users/pw/.bash_profile: line 1: syntax error near unexpected token `source'
-bash: /Users/pw/.bash_profile: line 1: `if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi source /Users/pw/.bash_profile'
Any ideas to how I can stop this error from showing?
Thanks
There should be a single line at the bottom of your ~/.bash_profile that says:
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
That's all. No mention of source anything.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I have a little problem with the i3 tiling window manager's ~/.i3/config file.
I am trying to set the pm-suspend utility as a key-binding of Mod4 (the windows key) + p (the p char).
I have this bash script called suspendandlock in /usr/bin/:
#!/bin/bash
sudo pm-suspend | i3lock -i /home/antony/unity-desk.png -p default -d -n
I previously modified the /etc/sudoers file with visudo, adding this line:
%users ALL = NOPASSWD: /usr/sbin/pm-suspend
So that no one needs the password to execute pm-suspend utility.
Then I have my i3 config file, where I added this:
bindsym $mod+p exec suspendandlock
Where $mod is the Mod4 key.
The script works fine from gnome-terminal when I type the suspendandlock command -> it suspends the system and blocks the screen as expected.
But when I type Mod4+p from keyboard it only blocks the screen without executing pm-suspend.
Why does it not work?
Does anyone knows where I am wrong?
It looks like OP solved the problem, but for anyone else who needed to fix it (myself included), just run:
sudo usermod -aG users `whoami`
which pm-suspend || sudo apt-get install pm-utils #make sure you have pm-suspend command, install it if you don't
run sudo visudo and add:
%users ALL = NOPASSWD: /usr/sbin/pm-suspend
and then add:
bindsym $mod+p exec "sudo pm-suspend | i3lock"
to ~/.i3/config. Running $mod+p will now lock and then suspend your computer.
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 11 years ago.
Improve this question
What should I type on the Mac OS X terminal to run a script as root?
As in any unix-based environment, you can use the sudo command:
$ sudo script-name
It will ask for your password (your own, not a separate root password).
Or you can access root terminal by typing sudo -s
sudo ./scriptname
In order for sudo to work the way everyone suggest, you need to be in the admin group.
sudo ./scriptname
sudo bash will basically switch you over to running a shell as root, although it's probably best to stay as su as little as possible.