'bash' : no such file or directory - ruby-on-rails

I just joined the windows insider program so I could install Ubuntu and install Ruby via bash commands. Everytime I open the the ubuntu command prompt it will not allow me to run any commands without throwing errors. examples
Command 'sudo' is not availiable in '/usr/bin/sudo'
At the top of the Ubuntu command prompt it says:
/usr/bin/env: 'bash': no such file or directory
How can I resolve this issue. I need to set up ruby so I can start developing.

You can check content of PATH variable by executing command $ echo $PATH
If you do not find /usr/bin in the output than you can append /usr/bin in PATH variable by executing command
$ export PATH=$PATH:/usr/bin

Related

vscode-remote-container open user terminal after post*Command

if you run a post*Command you get an integrated terminal that runs the command(s) and outputs:
Running the PostCreateCommand from devcontainer.json...
[2709 ms] Start: Run in container: ...
Done. Press any key to close the terminal.
is there a way to have this auto close and open a user terminal or just leave it and open a user terminal as if you werent running any commands from devcontainer.json at all?
Using an example involving Python, you can try using postAttachCommand:
{
"postCreateCommand": ["poetry", "install"],
"postAttachCommand": "bash"
}
which gives:
Running the postCreateCommand from devcontainer.json...
[28000 ms] Start: Run in container: poetry install
Installing dependencies from lock file
No dependencies to install or update
Installing the current project: project (0.1.0)
Running the postAttachCommand from devcontainer.json...
[33815 ms] Start: Run in container: /bin/sh -c bash
root#a0fd27a3b2cc:/workspaces/directory#
The description for postCreateCommand reads:
A command to run after creating the container. This command is run after "updateContentCommand" and before "postStartCommand".
whereas the description for postAttachCommand specifies:
A command to run when attaching to the container. This command is run after "postStartCommand".
So other variations might be possible, but this one worked for me.

/usr/bin/sudo: Permission denied when calling sudo from sh script via telegra-cli with lua script

Im trying to run my .sh scipt status.sh via a telegram message:
Ubuntu 20.04.1 LTS server
Telegram-cli with a lua script to action status.sh script
when i send the message "status" to my server via telegram it actions the status.sh script, in this script i have a bunch of stuff that gathers info for me and sends it back to telegram so i can see what the status of my server is, however (i recently did a fresh install of the server) for some reason if the script has a line of code starting with sudo i get:
line 38: /usr/bin/sudo: Permission denied
if i run the script from the command line ./status.sh it runs without any problem!? so im thinking its because it is being called from telegram or lua!?
example of code that generates the error: sudo ifconfig enp0s25 >> file
on the other hand this line works without a problem:
sudo echo Time: $(date +"%H:%M:%S") > file
/usr/bin has 0755 permission set
sudo has 4755 permission set
The following command
sudo ifconfig enp0s25 >> file
would not work if file requires root privilege to be modified.
sudo affects ifconfig but not the redirection.
To fix it:
sudo sh -c 'ifconfig enp0s25 >> file'
As mentioned in Egor Skriptunoff's answer, sudo only affects the command being run with sudo, and not the redirect.
Perhaps nothing is being written to file in your case because ifconfig is writing the output you are interested in to stderr instead of to stdout.
If you want to append both stdout and stderr to file as root, use this command:
sudo sh -c 'ifconfig enp0s25 >> file 2>&1'
Here, sh is invoked via sudo so that the redirect to file will be done as root.
Without the 2>&1, only ifconfig's stdout will be appended to file. The 2>&1 tells the shell to redirect stderr to stdout.
If file can be written to without root, this may simplify to
sudo ifconfig enp0s25 >> file 2>&1

Is there any way to run "pkexec" from a docker container?

I am trying to set up a Docker image (my Dockerfile is available here, sorry for the french README: https://framagit.org/Gwendal/firefox-icedtea-docker) with an old version of Firefox and an old version of Java to run an old Java applet to start a VPN. My image does work and successfully allows me to start the Java applet in Firefox.
Unfortunately, the said applet then tries to run the following command in the container (I've simply removed the --config part from the command as it does not matter here):
INFO: launching '/usr/bin/pkexec sh -c /usr/sbin/openvpn --config ...'
Then the applet exits silently with an error. While investigating, I've tried running a command with pkexec with the same Docker image, and it gives me this result:
$ sudo docker-compose run firefox pkexec /firefox/firefox-sdk/bin/firefox-bin -new-instance
**
ERROR:pkexec.c:719:main: assertion failed: (polkit_unix_process_get_start_time (POLKIT_UNIX_PROCESS (subject)) > 0)
But I don't know polkit at all and cannot understand this error.
EDIT: A more minimal way to reproduce the problem is with this Dockerfile:
FROM ubuntu:16.04
RUN apt-get update \
&& apt-get install -y policykit-1
And then run:
$ sudo docker build -t pkexec-test .
$ sudo docker run pkexec-test pkexec echo Hello
Which leads here again to:
ERROR:pkexec.c:719:main: assertion failed: (polkit_unix_process_get_start_time (POLKIT_UNIX_PROCESS (subject)) > 0)
Should I conclude that pkexec cannot work in a docker container? Or is there any way to make this command work?
Sidenote: I have no control whatsoever on the Java applet that I try to run, it is a horrible and very dated proprietary black box that I am supposed to use at work, for which I have no access to the source code, and that I must use as is.
I have solved my own problem by replacing pkexec by sudo in the docker image, and by allowing passwordless sudo.
Given an ubuntu docker image where a user called developer was created and configured with a USER statement, add these lines:
# Install sudo and make 'developer' a passwordless sudoer
RUN apt-get install sudo
ADD ./developersudo /etc/sudoers.d/developersudo
# Replacing pkexec by sudo
RUN rm /usr/bin/pkexec
RUN ln -s /usr/bin/sudo /usr/bin/pkexec
with the file developersudo containing:
developer ALL=(ALL) NOPASSWD:ALL
This replaces any call to pkexec made in a process running in the container, by a call to sudo without any password prompt, which works nicely.

Installing TaskCat using docker, and running taskCat errors out bash: taskcat: command not found

After installing docker successfully, and installing taskCat using docker,
$ curl -s https://raw.githubusercontent.com/aws-quickstart/taskcat/master/installer/docker-installer.sh | sh
When i run the below command
$ taskcat -c /ci/taskcat.yml
I get an error
"bash: taskcat: command not found"
Do a whereis taskcat, or use the find command or locate command to find the install location of the taskcat command.
The path variable for taskcat has not been setup, that maybe a reason why it says command not found.
Some commands get installed in the homedirectory/bin folder, this path is not included by default in the PATH variable.
You can do export PATH=$PATH:/home/myuserdir/bin to solve this issue.

-bash: iTMSTransporter: command not found

I have install iTMSTransporter and try to run it from it is destination directory in order to fetch the metadata from iTunes Connect .
I am in lookup mode and used following command:
iTMSTransporter -m lookupMetadata -u uid -p password -vendor_id SnapLion000011 - destination /Users/Snaplion4/Desktop
and got following error :
-bash: iTMSTransporter: command not found
On my Mac the installer installed the binaries here. /usr/local/itms/bin
I cd into that folder and run
$ ./iTMSTransporter -m verify -f .....
You might not be in the same folder with iTMSTransporter. If you are in the same folder try adding ./ at the beginning of the command.
BTW you should hide your password. I can't believe superwoman has that much downloads.

Resources