Ubuntu 13.10 , Golang build and run, the terminal display error bash: ./filename : Permission denied - linux

I am trying to run Go's executable file after using command go build instead of typing go run filename.go.
I typed go build in the directory where the Golang source file resides. After the executable file had been created, I typed ./filename to run it. Then the terminal displayed a line :
bash : ./filename : Permission denied
I had tried to change the permission of the filename by typing :
chmod u+x filename
But this action doesn't give any effects. The permission denied error still occurs whenever I type ./filename.
Is there another way to build a Golang applications from source code, and then run it from executable file?
All things done well if I do this task in Windows command prompt, after typing go build, the filename.exe is created and there is no any problem when I run it by typing ./filename.exe.

NTFS and FAT have different permission models than Unix. This especially means that there is no executable flag on such a file system. Calling chmod a+x FILE is a no-op. Linux emulates classical Unix permissions on NTFS file systems by setting a mask for each file that contains the would-be permissions.
To fix these problemss, either move executables to a different file system or change the mount flags to use a permission mask that enables the executable-flag (for all files).

Related

Create directory "/dotenv" on MacOs, Read-only file system

I tried to create a directory under root (the directory when I open terminal)
sudo mkdir /dotenv
But the system says:
mkdir: /dotenv: Read-only file system
My OS is Catalina 10.15.2
Is there any way to create the dir? I need to run a node.js server locally which requires .env file in the /dotenv dir
You'll need to use mkdir dotenv if you are at your profile root (which it appears you are). That was the only way I could get it to work (I am on Catalina 10.15.3).
Using mkdir /dotenv (notice the /) I got the same error as you.
If you really want to, you can disable the read-only file system in Catalina by following these steps (which are also listed below).
Problem because of Read-only file system in mac os catalina
Boot you mac system into recovery mode. (by bootup system with holding CMD+R).
Open terminal (Present in "Utilities" in the top left menu).
Just run command
csrutil disable
Restart your system and Bootup normally
Before doing any activity open terminal and run command.
sudo mount -uw /
Once this all done you can do write in root location
Require the result in command: csrutil status
If result is enabled, you need to restart machine and press command + R, open the terminal in the recovery, so input csrutil diabled.
Restart, and check the status: csrutil status.
Here are two methods:
you are root.
sudo mount -uw /
so, you could mkdir or touch new file.
If you still can't read or write any, you maybe try this:
cd ~ # cd home directory
sudo vim /etc/synthetic.conf # create new file if this doesn't exist
In the conf files, add new line
dotenv /User/xx/dotenv # Notice: the space between this two strings is tab
Restart, and you will find a link named /dotenv in the root.

Can't execute from /usr/local/bin/ symlink

I've recently had to compile a program (Riak) from source since they don't have a repo available for Ubuntu 16.04 yet.
I've compiled the program and copied it to /opt/riak where it works fine.
Since this program requires sudo privileges, I've decided to symlink /opt/riak/bin/riak to /usr/local/bin/riak instead of adding the variable to the path via a profile.d file (because in order to work with sudo I'd have to remove env_reset from /etc/sudoers which I rather not do).
The error I get is the following:
/usr/local/bin/riak: 8: .: Can't open /usr/local/bin/../lib/env.sh
Shouldn't the symlink execute the file from the original's working directory? Is there a way to make it work?
The error message is almost self explanatory. Apparently the riak executable is trying to find a file called env.sh using a path relative to its own, namely ../lib/env.sh. Originally, this would resolve to the following path: /opt/riak/bin/../lib/env.sh, which is the same as /opt/riak/lib/env.sh. But now is trying to find the file at /usr/local/bin/../lib/env.sh which is the same as /usr/local/lib/env.sh and obviously the file is not there.
You have the following options (in order of preference):
Leave the program in /opt and invoke it from there
Leave the program in /opt and create a small wrapper shell script in /usr/local/bin that calls the original executable (see at the end of this post).
Recompile the program passing the right parameters to its configure script (e.g. --prefix=/usr/local) so that it works from /usr/local.
I would recommend against option 3; I prefer to let the /usr directory be managed by the distos package manager. If I have to compile something myself, I prefer to put it in a dedicated directory bellow /opt. This way, if I want to remove it later on, I can just delete that directory.
Example wrapper script for option 2:
#!/bin/bash
exec /opt/riak/bin/riak "$#"

Installing xampp form downloaded file?

I have downloaded xampp-linux-x64-1.8.3-2-installer.run and now how can I install it in my Linux OS.
I can only speculate that you haven't tried to run the file and you are totally new to Linux and Stackoverflow. The standardish way to run an executable on Linux is this (in a terminal).
Open a terminal
cd /Path/to/savedfile
Give the file permission to execute. (Google Linux file permissions)
chmod 777 xampp-linux-x64-1.8.3-2-installer.run
Run the file
./xampp-linux-x64-1.8.3-2-installer.run
(Totally untested)

Adding binaries to the 'bin' catalog

When I'm trying to add 'phantomjs' binary to the 'bin' folder (/usr/bin) on Mac OSX, the following error occurs:
Oskars-MacBook-Pro:bin oskarszura$ mv phantomjs ../../../../usr/local/bin/
mv: rename phantomjs to ../../../../usr/local/bin/phantomjs: Permission denied
i assume that I shouldn't change this catalog's permissions. How should I add binaries on Mac OSX ?
You need administrator (also called root) rights to fiddle with the system folders.
See the sudo command how gain those privileges for a single command.
Also, instead of using that relative path to /usr/local/bin, why not simple use the full path of just /usr/local/bin?

Access root of drive with a Unix-like shell

I'm using Cygwin to compile a library. The library is not stored within the same directory as Cygwin. I need to navigate to this directory in order to compile the library. The Cygwin shell only allows me to go back as far as the Cygwin root directory using cd .. .
The command su returns the following:
su: user root does not exist
How do I navigate my hard drive using Cygwin if the su command doesn't work?
As suggested by Wooble, the solution is to use the command /cygdrive/ , followed by the drive letter. So, to access the root of the C: drive, type cd /cygdrive/c.

Resources