When I try to run my Android app on an emulator I get this error:
/dev/kvm permission denied.
I checked the permissions and added the user I am currently logged in with to the kvm group. What is wrong?
As mentioned in the comments, starting with Ubuntu 18.04 and Linux Mint Tara you need to first sudo apt install qemu-kvm.
To check the ownership of /dev/kvm use
ls -al /dev/kvm
The user was root, the group kvm. To check which users are in the kvm group, use
grep kvm /etc/group
This returned
kvm:x:some_number:
on my system: as there is nothing rightwards of the final :, there are no users in the kvm group.
To add your user to the kvm group, you could use
sudo adduser $USER kvm
which adds the user to the group, and check once again with grep kvm /etc/group.
As mentioned by #marcolz, the command newgrp kvm should change the group membership live for you. If that did not work, #Knossos mentioned that you might want to log out and back in (or restart), for the permissions to take effect. Or do as #nmirceac mentioned and re-login in the same shell via su - $USER.
This is how I got it to work in Ubuntu 18.04
sudo apt install qemu-kvm
Add your user to kvm group using:
sudo adduser <Replace with username> kvm
If still showing permission denied:
sudo chown <Replace with username> /dev/kvm
Try it.
Try this, it worked for me:
sudo apt install qemu-kvm
sudo chown -R <username>:<username> /dev/kvm
This is because /dev/kvm is not accessible. To make is accessible from android studio run the below command
sudo chmod 777 -R /dev/kvm
It will ask for your password. After that restart Android Studio.
KVM is required to rum emulator. If you have not install it yet then install it
sudo apt install qemu-kvm
Have you also tried following, it should work:
sudo chown <username> /dev/kvm
sudo chmod o+x /dev/kvm
sudo chown $USER /dev/kvm
Simply running that one command worked for me here in September 2019 running:
Description: Ubuntu 18.04.3
LTS Release: 18.04
Codename: bionic
Step 1: (Install qemu-kvm)
sudo apt install qemu-kvm
Step 2: (Add your user to kvm group using)
sudo adduser username kvm
Step 3: (If still showing permission denied)
sudo chown username /dev/kvm
Final step:
ls -al /dev/kvm
I am using ubuntu 18.04. I was facing the same problem. I run this piece of command in terminal and problem is resolved.
sudo chown $USER /dev/kvm
the above command is for all the user present in your system.
If you want to give access to only a specific user then run this command
sudo chown UserNameHere /dev/kvm
Under Ubuntu, the permissions of /dev/kvm usually look like this:
$ ls -l /dev/kvm
crw-rw---- 1 root kvm 10, 232 May 24 09:54 /dev/kvm
The user that runs the Android emulator (i.e. your user) needs to get access to this device.
Thus, there are basically 2 ways how to get access:
Make sure that your user is part of the kvm group (requires a re-login of your user after the change)
Widen the permissions of that device such that your user has access (requires a change to the udev daemon configuration)
Add User to KVM Group
Check if your user is already part of the kvm group, e.g.:
$ id
uid=1000(juser) gid=1000(juser) groups=1000(juser),10(wheel)
If it isn't then add it with e.g.:
$ sudo usermod --append --groups kvm juser
After that change you have to logout and login again to make the group change effective (check again with id).
Widen Permissions
Alternatively, you can just can widen the permissions of the /dev/kvm device.
Example:
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
| sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
FWIW, this is the default on other distributions such as Fedora and CentOS.
Check the effectiveness of the above commands with another ls. You should see output similar to:
$ ls -l /dev/kvm
crw-rw-rw-. 1 root kvm 10, 232 2020-05-16 09:19 /dev/kvm
Big advantage: You don't need to logout and login again for this change to be effective.
Non-Solutions
calling chmod and chown directly on /dev/kvm - 1) these changes aren't persistent over reboots and 2) since /dev/kvm permissions are controlled by the udev daemon, it can 'fix' its permissions at any time, e.g. after each emulator run
adding executable permissions to /dev/kvm - your emulator just requires read and write permissions
changing permissions recursively on /dev/kvm - I don't know what's up with that - looks like cargo cult
installing extra packages like qemu - you already have your emulator installed - you just need to get access to the /dev/kvm device
Here is a simple solution
open the terminal and run the following commands
sudo groupadd -r kvm
sudo gedit /lib/udev/rules.d/60-qemu-system-common.rules
Add the following line to the opened file and save it
KERNEL=="kvm", GROUP="kvm", MODE="0660"
Finally run:
sudo usermod -a -G kvm <your_username>
Reboot your PC and Done!
There's absolutely no need to install qemu-kvm (and all its dependencies) if you only want to run the Android Studio Emulator.
The only thing you have to do is to give your user (i.e. the one you are logged in with) the right to access the /dev/kvm-device.
This is done in three simple steps.
First:
Create the kvm-group
groupadd -r kvm
The option -r creates a system group, i.e. with a GID <= 999 (see /etc/login.defs => SYS_GID_MAX)
Second:
Change permissions on /dev/kvm. This could be done as part of the qemu-kvm-installation, because one of the dependencies is installing qemu-system-common (on current Ubuntu systems, package name may vary), which in turn installs the file /lib/udev/rules.d/60-qemu-system-common.rules containing the following:
KERNEL=="kvm", GROUP="kvm", MODE="0660"
So if you are just create a file /etc/udev/rules.d/60-qemu-permissions.rules containing the above line, you are done with the first step.
Third:
Add your username to the group by executing
usermod -a -G kvm <your_username> - the -a is important for adding your user to the kvm-group. Without that you will overwrite the group-settings for your user to only belonging to "kvm"...
That's it.
For the new udev rule and group setting to take effect it's easiest to reboot and login again.
You can also execute
udevadm control --reload-rules && udevadm trigger
for reloading the rules but you still have to logout and login again with regard to the new group.
I countered the same problem and to solve this issue just type the following commands in terminal for Linux clients
sudo apt-get install qemu-kvm
// type your password
sudo chmod 777 -R /dev/kvm
and after that try running simulator it'll work
sudo setfacl -m u:$USER:rwx /dev/kvm
Worked for me.
I am using linux debian, and i am facing the same way. In my AVD showing me a message "/dev/kvm permission denied" and i tried to find the solution, then what i do to solve it is, in terminal type this :
sudo chmod -R 777 /dev/kvm
it will grant an access for folder /dev/kvm,then check again on your AVD , the error message will disappear, hope it will help.
This Worked For Me on Linux (x18) ☑ Hope It Will Work For You Aswell
sudo chown hp /dev/kvm
Just one slight improvement on Jerrin's answer on fixing this error with Ubuntu 18.04 by utilizing $USER variable available in the bash terminal. So you could use the following commands two commands:
sudo apt install qemu-kvm
Add the current user to the kvm group
sudo adduser $USER kvm
Also if you are still having issues, one other problem for me was the way in which I installed Ubuntu. I made the mistake of checking the box during installation for installing 3rd party software which did not play nice with my nvidia graphics card for development. So I reinstalled Ubuntu with this third party software unchecked.
Then after installation, open up Software & Updates and go to the Additional Drivers tab. Select the most up to date proprietary drivers that have also been tested and apply changes. Should restart the machine for the changes to take affect.
What finally fixed it for me on Ubuntu 18.04 was:
sudo apt install qemu-kvm
sudo adduser $USER kvm
sudo chown $USER /dev/kvm
I tried sudo setfacl -m u:UserName:rwx /dev/kvm . and it works .
In the android studio you need to change : tools> avd manager >(chose the pen to edit your device and change 'graphics' from automatic to software ) to avoid emulator drawable error
Here is what I did:
user#user:~$ whoami
antonio
sudo apt install qemu-kvm
sudo adduser antonio kvm
sudo chown antonio /dev/kvm
last but not least
On Android studio
select File -> Restart IDE
to apply the changes
Then create the emulator
I was in a similar situation with the same error of permissions on /dev/kvm
I had done the necessary installations but not added the user to the kvm group
All I had to do was
sudo adduser <Replace with username> kvm
and ofcourse DON'T forget to restart your Ubuntu instance.
/dev/kvm permission denied android studio
[Motherboard]Set VT(Virtualization Technology) in BIOS and install Virtual Machine
I got this error after updating my ubuntu to 18.04.1. I just download new system image for emulator or you can say that download new emulator and it is worked for me.
Open Terminal and log as admin
sudo su
Go to the dev folder
cd /dev/
Change the kvm mode
chmod 777 -R kvm
Type in terminal:
sudo apt install qemu-kvm -y
sudo chown $USER /dev/kvm
Although KVM is a module built into the Linux kernel itself, it doesn't mean that all the necessary packages are included in your Ubuntu/Linux install by default. You'll need a few to get started, and they can be installed with this command in the terminal:
& sudo apt install qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virt-manager
Configure the network bridge
In order for your virtual machines to access your network interface and be assigned their own IP addresses, we need to configure bridged networking on our system.
First, run the following Linux command in order to find out what name your network interface has been assigned. Knowing this will allow us to do additional configuration later.
$ ip a
In my case, the network interface is called enp2s0. Yours will likely be very similarly named.
In order to tell Ubuntu that we want our connection to be bridged, we'll need to edit the network interfaces configuration file. Doing this won't negatively impact your connection at all. It'll just allow that connection to be shared with the VMs.
Use code (Visual Studio Code) or your favorite text editor to open the following file:
$ code /etc/network/interfaces
When you first open this file, it may be empty or contain just a couple of lines. Your bridge interface is called br0, so add the following line for the interface to come up by default:
auto br0
Below this line, add the following line for your current network interface (the one who's named you determined earlier).
iface enp2s0 inet manual
Next, you can add the bridge information. These lines tell Ubuntu that your bridge will use DHCP for automatic IP address assignment, and your bridge will manage your current interface.
iface br0 inet dhcp
bridge_ports enp2s0
This is how your file should look once all the changes have been applied (if you also have a couple of lines that were already there, it's fine to have them too):
Save your changes and exit the file.
Add your user to the groups
In order to manage your virtual machine(s) without root privileges, your user will need to belong to two user groups. Run the following commands to add your user to the appropriate groups (replacing user1 with the name of your user):
$ sudo adduser user1 libvirt
$ sudo adduser user1 libvirt-qemu
$ sudo adduser user1 kvm
When you're done, you should restart your system to ensure that all of the changes done to your user and network configuration have a chance to take effect.
In order to make a virtual device in Linux - I have to follow this three command and it helps me to avoid trouble for building avd devices - the process are -
sudo apt install qemu-kvm
sudo adduser $USER kvm
sudo chown $USER /dev/kvm
so, now you are good to go, restart android studio and start building application with emulator.
Provide appropriate permissions with this command
sudo chmod 777 -R /dev/kvm
Running the below command in Ubuntu 18.04 worked for me
sudo chown -R /dev/kvm
If you open your ide with sudo. You are not going to have this problem.
Related
I am a newbie with server handling and Linux. I am trying to install composer on my server so that i can host my Laravel project onto it as mentioned in the tutorial in Ultimate Guide: Deploy Laravel 5.3 App on LEMP Stack. I ssh into the server and after installation of composer when I run sudo mv composer.phar /usr/local/bin/composer I am getting a message in the terminal:
-bash: sudo: command not found
I desperately need some deliberate help
Sudo is probably not installed or not in your path
check to see if you are root in this case sudo is not needed unless you are trying to impersonate another user. just run your command without sudo mv composer.phar /usr/local/bin/composer
See if sudo is your path by running which sudo or echo $PATH. If sudo is not in your path, your path variable might be broken. You can try testing this by executing a common location for sudo /usr/bin/sudo or running locate sudo | grep bin to attempt to find its location.
If you know that sudo was installed, or your path looks broken, try fixing your path. Check your distribution's env file (/etc/environment in ubuntu) to make sure that it is formatted correctly (script commands are illegal in this file)
If you are not root and you want to run a command with root prvileges then you must install sudo. But if you don't have sudo and you are not root then you can't install it. In this case I recommend switching to the root user with su
If you do not have the root password and you own the machine, you can reset the root password with a tutorial such as https://askubuntu.com/questions/24006/how-do-i-reset-a-lost-administrative-password
After you manage to login as root install sudo with apt-get update; apt-get install sudosince you are using Ubuntu.
Verify the the name of your sudoers group with visudo and modify your sudoers file if you need to. https://www.digitalocean.com/community/tutorials/how-to-edit-the-sudoers-file-on-ubuntu-and-centos
if you have an existing sudoers group or you create one you can add yourself to the group. For example if your sudoers group is called sudo run usermod -aG sudo myuser. The sudoers group by default in Ubuntu based Linux is sudo. A sudoers group entry looks like this: %sudo ALL=(ALL:ALL) ALL
If you are trying to impersonate another user and cannot install sudo, you can still use su if it is installed and you have permission / password for the other user.
e.g. su someuser
As suggested in this post, you may have to install sudo in your server.
To do that, log in as root with the following command: su -. Then install sudo with your package manager (if you're in Ubuntu: apt-get install sudo).
Then add your user to the sudo group: usermod -aG sudo <username>.
Finally type exit to log out of the root account and go back to your user.
try to install your sudo using by first logging in as a root(su - ) and then try to install **apt-get or yum sudo **. Make sure your path variable is set so that you would be able to get binary.
which sudo
echo $PATH
I want to enable the mod_rewrite on Apache, I used Putty to access the server on my windows OS.
I logged in using my username and password, My friend said that I should have root access to enable the mod_rewrite, so he advice me to type sudo su after I successfully log in. So I added sudo su command and it asked me a password again, so I type my password but I got an error.
[myusername] is not in the sudoers file.the incident will be reported
So maybe anyone here could help me.
You can add a new user into sudo group in debian based systems (Ubuntu, kbuntu, debian, etc) and the wheel group under RedHat based systems (RedHat, Fedora, CentOS, etc) by using the following commands
usermod -a -G sudo user
or
usermod -a -G wheel user
restart your machine
choose Advance ubuntu option
then go for the root option
you are now root here, root#machine:
enter: usermod -aG sudo username
now you have added the user to sudo group, you can exit from root and login as a user.
you can do this without restarting your machine if your root password is updated,
by default it is not but if not, then you have to restart and set the root password by passwd command.
But if you already have a root password setup
enter:
su -
and you will be root,
but recommended is to use:
sudo -s
as a temporary root access
It's necessary to add this user in a sudo group. You can do this, first, accessing the system using an admin user, next taking access to superuser mod:
sudo su
Then, you can add a user you need in a sudo group using the following commands:
adduser [username] sudo
I have been trying to allow access to the normal user of an EC2 amazon server ('ec2-user') to a certain library.
I did: "sudo chown -R ec2-user /usr" which I realize now had been a fatal mistake. It worked, but sudo is gone. If I try to use sudo I get: "sudo: effective uid is not 0, is sudo installed setuid root?"
I tried "chmod u+s /usr" like it is suggested in another answer. It does not solve the issue.
I guess that there is something basic I am missing. Forgive my newb ignorance.
The suid bit of the permissions for sudo changes the effective user to the owner of the sudo command file, which you changed to be ec2-user. You need to give ownership of the sudo command back to root.
After upgrading my system from 14.10 to 15.04 I can't seem to use docker like I used to. I already have a docker group that my user is part of and I used to be able to use docker without sudo just fine. Now I can't use it unless I have sudo docker -d running in another terminal. Simply running docker ps gives me this error:
FATA[0000] Get http:///var/run/docker.sock/v1.18/containers/json: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?
I've tried reinstalling, rebooting, restarting services, and blowing out configurations to no avail. Any tips would be appreciated. As a side note, I installing 15.04 in a vm to see if I could get docker working there and I was able to set it up no problem. seems like an issue specific to those who have upgraded from 14.10.
Did u checked this http://docs.docker.com/articles/systemd/? This helped me to start docker under Ubunu 15.04.
What to do if this fails...
$ sudo usermod -aG docker $USER
..and you have added user to docker group and Ubuntu still requires sudo:
If you initially ran Docker CLI commands using sudo before adding your user to the docker group, you may see the following error, which indicates that your ~/.docker/ directory was created with incorrect permissions due to the sudo commands.
To fix this problem, either remove the ~/.docker/ directory (it is recreated automatically, but any custom settings are lost), or change its ownership and permissions using the following commands:
$ sudo chown "$USER":"$USER" /home/"$USER"/.docker -R
$ sudo chmod g+rwx "$HOME/.docker" -R
What the link mafahand provided tells is how to use docker on a systemd based host. Ubuntu 15.04 uses systemd now while older version used upstart. That might explain why upgraded systems show erratic behavior. Check out the Ubuntu wiki for some help on that regard.
After installing docker via
sudo apt install docker.io
you might have to reboot your system or start the docker.socket unit manually. For some reason that did not happen on my machine after installing it.
Type
systemctl status docker
to check whether docker is up and running. If it is not enabled use
sudo systemctl enable docker
to enable it permanently and/or
sudo systemctl start docker
to run the service.
I am a newbie to couchDB. Recently, I have dived into it with a quick installation instruction over here:
sudo apt-get update -y
sudo apt-get install g++ -y
sudo apt-get install erlang-base erlang-dev erlang-eunit erlang-nox -y
sudo apt-get install libmozjs185-dev libicu-dev libcurl4-gnutls-dev libtool -y
curl -O http://apache.mirrors.tds.net/couchdb/source/1.5.1/apache-couchdb-1.5.1.tar.gz
tar -zxvf apache-couchdb-1.5.1.tar.gz
cd apache-couchdb-1.5.1
./configure
make
sudo make install
sudo adduser --disabled-login --disabled-password --no-create-home couchdb
sudo chown -R couchdb:couchdb /usr/local/var/log/couchdb
sudo chown -R couchdb:couchdb /usr/local/var/lib/couchdb
sudo chown -R couchdb:couchdb /usr/local/var/run/couchdb
sudo ln -s /usr/local/etc/logrotate.d/couchdb /etc/logrotate.d/couchdb
sudo ln -s /usr/local/etc/init.d/couchdb /etc/init.d
sudo update-rc.d couchdb defaults
1. modify /usr/local/etc/couchdb/local.ini
2. change bindAddress to 0.0.0.0
3. reboot
4. remember to go into the config settings and secure server
5. remember to turn on auto compaction
I have followed exactly the guide, except the 4th and 5th steps cause I did not know how to do it. When I ran:
couchdb
I got the following message in the terminal (I am using Ubuntu 14.04 LTS):
Apache CouchDB 1.5.1 (LogLevel=info) is starting.
Error opening log file /usr/local/var/log/couchdb/couch.log: permission denied{"init terminating in do_boot",{{badmatch,{error,{bad_return,{{couch_app,start,[normal,["/usr/local/etc/couchdb/default.ini","/usr/local/etc/couchdb/local.ini"]]},{'EXIT',{{badmatch,{error,{shutdown,{failed_to_start_child,couch_primary_services,{shutdown,{failed_to_start_child,couch_log,{error,"permission denied","/usr/local/var/log/couchdb/couch.log"}}}}}}},[{couch_server_sup,start_server,1,[{file,"couch_server_sup.erl"},{line,98}]},{application_master,start_it_old,4,[{file,"application_master.erl"},{line,269}]}]}}}}}},[{couch,start,0,[{file,"couch.erl"},{line,18}]},{init,start_it,1,[]},{init,start_em,1,[]}]}}
Crash dump was written to: erl_crash.dump
init terminating in do_boot ()
May anyone help me figure out this problem and suggest some solution to fix it? Thank you very much.
You may need to start the couchdb process as the couchdb user, with su couchdb -c ./couchdb (assuming the current directory contains the executable) - double-check the su command options for your system.
Also, check the permissions on /usr/local/var/log/couchdb/couch.log - make sure it is writeable by the couchdb user.
I would like to make a note here for how I fixed this problem in my environment. In my case, the /opt/couchdb/data folder was a symlink to /var/lib/couchdb. No matter what I tried I would get a permission denied error at startup, even though all the files seemed to be owned by user couchdb.
I eventually figured out that the "execute" permission was not set on /var/lib. Without this permission the symlink would not work. If you run into this problem, start by setting chmod -R a+x /var as I did, to prevent this from happening.
Although on CentOS, the "problem" is avoided using service couchdb [start|status|stop|restart].
https://medium.com/#tomiwatech_45998/installing-couchdb-on-ubuntu-17-10-18148e2eb846
Hi there,
this helped me resolve the issue and solved the problem. My ubuntu version is 16.04 and i downloaded couchdb-1.7.0 version.
You can start couchdb using below command
sudo couchdb stop
sudo couchdb start