Permission Problems on Guest Machine

108 views
Skip to first unread message

evrim Alacan

unread,
Mar 17, 2016, 6:50:41 PM3/17/16
to Vagrant
Hi all, this is going to be my first question about linux since I just started to use it. So tell me if I need to tell more for you to help me. 


This is my uname -a:                 Linux EvrimAlacan 3.19.0-32-generic #37~14.04.1-Ubuntu SMP Thu Oct 22 09:41:40 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

I'm using VirtualBox version :    5.0.4_LinuxMintr102546

Vagrant Version :                      Vagrant 1.8.1


Before Linux I was using my windows to do my work and then I decided to dual-boot my computer into a linux, and I choosed Linux Mint because it seems the best to me. 
But unfortunately when I 'vagrant up', bootstrap.sh which does all the job about configurations on guest machine, does nothing. Because of the following problem:

==> default: E: Could not open lock file /var/lib/apt/lists/lock - open (1: Operation not permitted)
==> default: E: Unable to lock directory /var/lib/apt/lists/

I know, this problem is about permissions. Also this error is all over the command prompt since bootstrap.sh commits more installations and fails.
If I type 'sudo vagrant up', It will install all the packages, but as expected the virtual machine will not show up because the owner will be the 'root', not me.
Whatever I did, I couldn't solve this. I get into it with 'vagrant ssh'. I tried to take the first line from 'bootstrap.sh' which is 'apt-get update'. Tried to run it manually.
I typed 'sudo apt-get update', but It still gave me an error saying I don't have permission. I tried this with 'sudo su' as well. 

Here is what I get with 'sudo visudo' on guest machine:


#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        exempt_group=admin
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) NOPASSWD:ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

I can't even delete the 'lock' file by any means, I tried everything. Changing the parent permissions to 777, didn't work as well. I looked on the internet about 'immutable' thing,
found a command to check the file whether it is immutable or not, but I don't even have a permission for it, even if I'm root. I don't know whats wrong... 

I much appreciate any help




Alvaro Miranda Aguilera

unread,
Mar 18, 2016, 4:21:32 PM3/18/16
to vagra...@googlegroups.com
Hello,

Welcome to Vagrant linux and all that stuff :D

he lock error literally is just saying "this user can't do this.."

With some practice and after lots of error you will learn to read what that means.. "the user your are using cant do .."

So basically here, the command you are running is meant to be run as root and not as the user you are using

sudo <command> should fix the issue.,

the sudo need to be inside the script that is being run.

If you can share your Vagranfile and the script that is being run, I can help you more.

Alvaro.



--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/56c2d318-349f-4880-aada-4360ec3e4084%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

evrim Alacan

unread,
Mar 18, 2016, 9:37:11 PM3/18/16
to Vagrant
Hey!
Thank you very much for answering my question. 
As far as I know, vagrant executes the script as root, here in this link, it says if you don't add 'privileged' to your Vagrantfile, by default it will execute the shell script as root user.
 I propably used wrong words to explain myself so that you couldn't understand what I mean, let me clarify that. The shell script throws exceptions like 'operation not permitted' all the way. I decided to copy one line from shell script, like 'apt-get update'.
I gone into VAGRANT SSH, I typed SUDO APT-GET UPDATE, then he said, OPERATION NOT PERMITTED, (Writing in uppercase just to make it more readable between words, it looks so regular in normal way lol)
So I'm saying that I can't use root priorities even if I type SUDO... I tried to delete this lock file. I wrote ' SUDO RM -F /PATH/TO/LOCK/FILE/LOCK' and guess what, OPERATION NOT PERMITTED LOL
When I do this on my personal machine which is Linux Mint, I can do this. How is this even possible...  

Here is my Vagrantfile:

VAGRANTFILE_API_VERSION = "2"


Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    config
.vm.box = "precise64"
    
if Vagrant.has_plugin?("vagrant-cachier")
        config
.cache.scope = :box
        config
.cache.auto_detect = true
    
end
    config
.vm.box_url = "http://files.vagrantup.com/precise64.box"
    config
.vm.provision :shell, :path => "bootstrap.sh"
    config
.vm.hostname = "vagrant"
    config
.vm.network "private_network", ip: "192.168.50.4"
    config
.vm.synced_folder "..", "/var/www/3fcampus", :nfs => true
    config
.vm.network "forwarded_port", guest: 80, host: 8901
    config
.vm.network "forwarded_port", guest: 3306, host: 3313
    config
.vm.network "forwarded_port", guest: 1080, host: 1084
end

Here is my shell script, there are some sayings in my language, Turkish, but they are just comments like 'Downloading blah blah'. Don't mind.

#!/bin/bash


# install php, mysql, mailcatcher


echo 
"Gerekli paketler kuruluyor..."
apt
-get update
apt
-get install -y python-software-properties
add
-apt-repository ppa:ondrej/php5-oldstable
add
-apt-repository ppa:nginx/stable
apt
-add-repository ppa:ondrej/mysql-5.6
apt
-get update
apt
-get install -y php5 php5-mysql php5-cli php5-sqlite php5-mcrypt curl php5-xsl php5-fpm php5-curl php5-gd php5-dev make build-essential sqlite3 libsqlite3-dev libxrender1 libfontconfig1 git nginx
export DEBIAN_FRONTEND=noninteractive
apt
-get install --y mysql-server-5.5
echo 
"Mailcatcher kuruluyor..."
cd 
/vagrant/mailcatcher
gem install 
--local mailcatcher-0.5.12.gem


echo 
"Twig Konfigürasyonu yapılıyor..."
cd 
/var/www/3fcampus/dispatch/Twig-1.18.1/ext/twig
phpize
./configure
make
sudo make install


echo 
"Konfigurasyonlar yapılıyor..."
rm 
-/etc/php5/fpm/php.ini
cp 
/vagrant/php.ini /etc/php5/fpm/php.ini
rm 
-/etc/mysql/my.cnf
cp 
/vagrant/my.cnf /etc/mysql/my.cnf
rm 
-/etc/php5/fpm/pool.d/www.conf
cp 
/vagrant/www.conf /etc/php5/fpm/pool.d
ln 
-/vagrant/nginx-vhosts/phoenix /etc/nginx/sites-enabled
ln 
-/vagrant/nginx-vhosts/people /etc/nginx/sites-enabled
ln 
-/vagrant/nginx-vhosts/dispatch /etc/nginx/sites-enabled
ln 
-sf /vagrant/hosts /etc/hosts


# project installation
echo 
"Veritabanı yükleniyor..."
echo 
"CREATE DATABASE 3fcampus" | mysql -u root
echo 
"CREATE DATABASE 3fcampus_forms" | mysql -u root
echo 
"create user 'root'@'10.0.2.2' identified by ''" | mysql -u root
echo 
"grant all privileges on *.* to 'root'@'10.0.2.2' with grant option" | mysql -u root
echo 
"flush privileges" | mysql -u root
echo 
"SET @@global.sql_mode = ''" | mysql -u root
echo 
"Phoenix veritabanı yükleniyor..."
mysql 
-u root 3fcampus_forms < "/var/www/3fcampus/ahep_forms.sql"


echo 
"Composer indiriliyor..."
cd 
/var/www/3fcampus/laravel
curl 
-sS https://getcomposer.org/installer | php -- --install-dir=/bin
composer
.phar install --prefer-dist


echo 
"Servisler başlatılıyor..."
service php5
-fpm restart
service nginx restart
service mysql restart
mailcatcher 
--http-ip=0.0.0.0


echo 
"Migrationlar çalıştırılıyor..."
php artisan migrate
php artisan db
:seed


echo 
'export PATH=$PATH:/var/www/3fcampus/laravel/vendor/bin' > /home/vagrant/.bash_profile


echo 
"Kurulum bitti"

18 Mart 2016 Cuma 22:21:32 UTC+2 tarihinde Alvaro Miranda Aguilera yazdı:

Alvaro Miranda Aguilera

unread,
Mar 19, 2016, 3:20:47 AM3/19/16
to vagra...@googlegroups.com
Hello,

do vagrant destroy, then change this:

    config.vm.box = "precise64"
    
if Vagrant.has_plugin?("vagrant-cachier")
        config
.cache.scope = :box
        config
.cache.auto_detect = true
    
end

    config
.vm.box_url = "http://files.vagrantup.com/precise64.box


To this:


    config.vm.box = “hashicorp/precise64"

    
if Vagrant.has_plugin?("vagrant-cachier")
        config
.cache.scope = :box
        config
.cache.auto_detect = true
    
end

Then vagrant up

If still fails, comment out the vagrant-cachier part.

And share the logs and a zip file with Vagrantfile and script. of what you got.


Alvaro.

evrim Alacan

unread,
Mar 19, 2016, 10:40:03 AM3/19/16
to Vagrant
Hi again, after I changed my Vagrantfile by your orders now Vagrants comes up to be working quite well. I deleted 
and change the box as
config.vm.box = hashicorp/precise64"

Thank you so so much for helping me with this problem ^^ But If you can, I want to know how this solution was correct. What did it change? Why was I getting that kind of errors?
You know, signing as root and not having permissions is so strange... I want to know the reason for this for further debugs, thank you!


19 Mart 2016 Cumartesi 09:20:47 UTC+2 tarihinde Alvaro Miranda Aguilera yazdı:

Alvaro Miranda Aguilera

unread,
Mar 20, 2016, 12:52:41 PM3/20/16
to vagra...@googlegroups.com
Hello,

Basically the box you were using was too old.

Since Vagrant 1.5, Vagrant can use atlas as an index.

so replacing the box with   user /  box  will go to atlas. to check and download the box.

It will allow use version, and will tell you when a new box has been released:


^ those are the boxes available as hashicorp/

If you want more boxes, I suggest check:

Any question, please feel free to ask. Whatever its , all question are very welcome. :)

Alvaro.


-- 
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
--- 
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages