How to Solve Error Message on executing go package mkdir /usr/bin/src: permission denied

Posted on


This article has a specific content. It will show how to solve an error message upon executing the ‘go’ command. The error message exists as follows :

user@hostname:~$ go get -u 
package : mkdir /usr/bin/src: permission denied

Basically, the command above is a command for cloning specific directory in the where the location exists for an example in

The problem is the ‘go’ command exist in ‘/usr/bin’. By default, in an Ubuntu Linux operating system distribution, executing a command without any full path has several considerations. Normally, the operating system will search the command in the list path inside the file in the /etc/environment. For an example, below is the content of the file :


So, operating system will search the ‘go’ command in all of the path in the list above. Fortunately, the ‘go’ command exists in ‘/usr/bin’. There is an error message upon executing the above command for cloning a package or directory from It is a ‘permission denied’ error message because the execution of the ‘go’ command by a normal user doesn’t have a write permission in the ‘/usr/bin’ path.

The solution to solve the error

Fortunately, there is a solution for solving the problem. It is possible to change the path for cloning the package or directory from Below are the steps for achieving it :

1. Just try to define the environment variable with the name of ‘GOPATH’ in the environment variable file. Normally, it exists in the .bashrc file of the home user directory. For an example, if there is a user with the name of ‘user’, the location of the file exists in ‘/home/user/.bashrc’. The following is an example of the ‘GOPATH’ definition :

export GOPATH=/home/user/go

2. Next step, don’t forget to execute the following to apply the change. Type the following command :

user@hostname:~$ source /home/user/.bashrc

3. Finally, try to execute the command above. Afterwards, the cloning result of the package or directory is available in the ‘/home/user/go’ folder.

Leave a Reply