azure bash: sudo: command not found - bash

In tutorial of azure iot edge, there's a sample said that user is able to command "sudo" in Bash, however the other tutorial said that "Permissions are set as regular users without sudo access".
enter image description hereenter image description here
Also when I followed the tutorial command in azure bash(sudo), it didn't work, so I'm wondering if I've missed something?
By the way, the tutorials are all from the Microsoft.

This is mainly because you were running on a Debian system, which does not come with the sudo command to add it use the following steps:
su -
apt-get install sudo -y
After that you would need to play around with users and permissions. Give sudo right to your own user.
usermod -aG sudo yourusername

Related

Hombrew installation issue on macos Big Sur

Trying to install homebrew in my new corporate pc.
facing this issue-
el$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
==> Checking for `sudo` access (which may request your password)...
Password:
Need sudo access on macOS (e.g. the user el needs to be an Administrator)!
P87111:~ el$
Checked System preferences->users and group
Seems like i am designated as an admin.
What could be a possible fix? Thanks.
This should be a comment but I don't have enough reputation.
Take a look at these duplicate posts - here and another one here.
The gist from both the aforementioned posts are as follows (three choices):
Choice 1: Install homebrew without root privileges:
For this, please read the homebrew's alternative install instructions for further information.
Choice 2: Make your user an administrator (using Terminal):
For this, first check if your user is an admin or not using sudo dseditgroup -o checknumber -m your-user-name admin. The output will be either Unable to find the user record or yes your-user-name is a member of admin. (If the latter, homebrew installation should work)
If the former, you need to make your user a member of admin using sudo dscl . -merge /Groups/admin GroupMembership your-user-name (more information about his command has been provided in this previous post.
Choice 3: Make your user an administrator (using System Preferences):
Go to System Preferences > Users & Groups & Current User > Check "Allow user to administer this computer".
Reboot in all cases

Is there an alternative to usermod on MacOS?

I want to build a docker image natively on a shell runner:
So I've been trying to register a GitLab runner with a shell executor on my local (MacOS) to build and run a docker image using this link:
https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-the-shell-executor
I have to run this command: sudo usermod -aG docker gitLab-runner to grant permissions to gitLab-runner.
However usermod doesn’t work on mac anymore, so I tried to follow a few StackOverflow links which told me to use sudo or dscl. None of them seem to be working.
The error I’m getting on the pipeline :
mkdir: /builds/ht8y-6qs/0/webapp.tmp: Read-only file system
Does anyone know a workaround?
Ps: I know the best way to do this would be inside a layer of virtualization but I still want to figure this out

Run gcloud without sudo

I'm on Mac OSX and I've always had to run the gcloud command with sudo. I can usually work around it, but it has started to cause me some issues. I tried following this answer here, but I am not sure where the gcloud command gets called from. It's not in /usr/bin.
I have found that my gcloud sdk is installed at /Users/Max/Desktop/google-cloud-sdk/, and I have tried adding /bin/gcloud and '/lib/gcloud.py' from that path. No luck! Any idea how I can give NOPASSWD permissions to this command?
I'm on macOS and my issue was that my google-cloud-sdk install folder and it's config folder at ~/.config/gcloud were owned by root. The fix is to sudo chown -R <your-username> google-cloud-skd and sudo chown -R <your-username> ~/.config/gcloud. And done: no more sudo.
I was able to resolve this issue myself. This article was very helpful. Ultimately, you just have to add sudo privileges to the gcloud command. You will have to give those permissions by running sudo visudo and adding a line in the following format:
<yourusername> ALL=NOPASSWD: <command1>, <command2>
Mine line ended up looking like this:
Max ALL=NOPASSWD: /Users/Max/Desktop/google-cloud-sdk/bin/gcloud
The part that tripped me up was figuring out where the gcloud command was installed. You have to add that path at the end of the permissions. You can find out where it is installed by running which gcloud.

Elasticsearch won't start on centos, permission denied

I installed elasticsearch this way :
retrieved the tar.gz on windows, extracted it and put it on a zip
uploaded the zip over ssh on a server and use 'unzip file' to unzip it.
I modified the elasticsearch file so that it has this line
export JAVA_HOME = "/home/xxx/project1/jdk1.8.0_73_linux64"
just below
#!/bin/sh
now when I go into /home/xxx/project1/elasticsearch/bin and type
./elasticsearch
I get
-bash: ./elasticsearch: Permission denied
What could I do to get more information about the problem?
I'm logged as user xxx
Thanks.
The problem is, that you've installed elastic being logged in as root. Now you're surely logged in as not root. If you're working as a user with root privileges, you potentially could start elastic, but it tells you, you can't run in as root. The owner of your elastic folder is root (he installed it). So, all you need to do is to change the owner of a folder to your xxx-user (to let him run elastic). You can easily do it executing a command:
chown -R new_owner path
for example, user is xxx and path is /opt/elasticsearch-2.3.5:
chown -R xxx /opt/elasticsearch-2.3.5
"-R" parameter ensures, that not only folder, but all files inside will recursively change the owner you provide.
Try to install using the package Yum Install for elasticsearch.
Else try: Its sounds like the user permission to access the files.
Ensure that you have downloaded the linux distribution (Optional) Since you have mentioned its tar.gz.
If you have extracted using sudo command then you need to change the user permission for elasticsearch folder to logged in user OR start the elasticsearch using sudo command
sudo ./elasticsearch -d
Check the execution permission if not please do the same by following command
sudo chmod +x /home/xxx/project1/elasticsearch/bin/elasticsearch.sh
Try this things if not please create a chat window and invite me.
Looking ahead I will immediately say that the ES app doesn't work using the sudo
In my case with ES 6.8.1 version on ubuntu i solved the problem using this steps:
Add the current user(or any other) to ES group:
sudo adduser <yourName> elasticsearch
Add possibility to execute ES:
sudo chmod +x /usr/share/elasticsearch/bin/elasticsearch
Then i changed owner of some paths**, in my case these were:
sudo chown -R <yourName>:elasticsearch /etc/default/elasticsearch
sudo chown -R <yourName>:elasticsearch /etc/elasticsearch
sudo chown -R <yourName>:elasticsearch /var/log/elasticsearch
**I started the application several times and then looked where I had no permission
Then i started ./usr/share/elasticsearch/bin/elasticsearch and saw the long-awaited JSON on port 9200 :)
Hope this will help someone.

Arch Linux sudo: command not found

I recently installed Arch Linux on my Raspberry Pi and, after logging in as root and creating myself a user account I tried to use the sudo command. This was the result:
[phillipus#alarmpi home]$ sudo mkdir Public
bash: sudo: command not found
After searching for the problem, I logged in as root and executed pacman -S sudo. This was followed by a long output and a confirmation of installation. Following this, I retried to use sudo both as root and as my user, both times getting the same response. Following another solution to the problem, I tried to add myself to /etc/sudoers, only to find out that it didn't exist.
I am not very experienced with Linux, so could you please try to explain your responses fully?
First, you need to install the sudo package to use sudo:
pacman -S sudo
After that, you need to edit the sudoers file and add your username to it.
You can add yor user to the wheel group using usermod -G wheel yourusername and uncomment the %wheel ALL=(ALL) ALLline in the sudoers file. For more information, have a look at Sudo - ArchWiki

Resources