can't use apt-get command with ubuntu core

Kieran Grant kieran.thehacker.grant at gmail.com
Wed Dec 5 08:00:13 UTC 2012


On 05/12/12 17:01, David Henningsson wrote:
> On 12/04/2012 03:14 PM, Emmet Hikory wrote:
>> Saqlain Abbas wrote:
>>> I have installed Ubuntu core on VM i followed instruction from
>>>
>>> https://wiki.ubuntu.com/Core
>>>
>>> I am able to boot and login, but if try apt-get install I get below
>>> errors,
>>> my system (virgin ubuntu core) got no packages installed like synaptic
>>> package manager etc
>>>
>>> "could not open lock file /var/lib/dpkg/lock -open (13:permission
>>> denied)
>>> unable to lock the administration directory (/var/lib/dpkg) , are
>>> you root?"
>>>
>>> I can't try using "sudo" command as it is not installed on (ubuntu
>>> core).
>>
>>      If you wish to run apt-get, you will either need to grant a root
>> password,
>> and use su, or mount the filesystem on some other machine, chroot
>> into it, and
>> install sudo from the chroot.
>>
>>> [T]he user i created "ubuntu" I added it to adm and sudo groups,
>>> "groups" command shows it is added to "ubuntu" "adm" and "sudo"
>>> groups. My
>>> other part of question is as user is added to sudo group why i got no
>>> "root" permission?
>>
>>      Because the sudo package is not installed, so there is no
>> interpretation
>> of the sudo group meaning anything.  While the adm group does grant
>> the ability
>> to access many files, it does not provide for any sort of root access.
>>
>
> The instructions at https://wiki.ubuntu.com/Core clearly says to add
> the local user to the sudo group. This makes no sense if the sudo
> package is not part of Ubuntu Core, so either the instructions are
> broken, or Ubuntu Core is broken because it should have included the
> sudo package?
>
The answers provided are correct, but you need to add sudo package manually.

Download ubuntu-core, as directed, and if you want to use it in an
image, say for example a VM (this is pretty much what I do):
Pre-download or pre-build Linux Kernel Debs (Download is easier)
host$ dd if=/dev/zero bs=1 seek=size-in-bytes count=1 of=./image
host$  su
host# mkdir mnt
host# mkfs.ext{2,3,4} -f ./image
host# mount ./image mnt
host# cd mnt
host# tar -xvnf ../ubuntu-core-{version}-core-{arch}.tar.gz
host# cd ..
host# cp /path/to/kernel/debs mnt/var/cache/apt/archives
host# chroot mnt
chroot# dpkg -i /var/cache/apt/archives/*.deb
chroot# apt-get update && apt-get upgrade
chroot# apt-get install net-tools sudo vim{/other editor of choice}
{aptitude/other package manager if you want} {and anything else you feel
you need}
chroot# apt-get clean
chroot# adduser username
chroot# addgroup username adm
chroot# addgroup username sudo
chroot# add
chroot# exit
host# cd ..
host# cp mnt/boot/vmlin* . && cp mnt/boot/init* . # copy kernel and init
image to outside chroot
host# umount mnt
host# exit
host$ kvm -m 512M -vga std -soundhw ac97,sb16 -smp
{n},sockets=1,threads=1,cores={n} -kernel vmlinux-... -initrd initrd-...
-append "vga=ask root=/dev/sda" hda=image -daemonize

(Also look at https://wiki.ubuntu.com/Core/InstallationExample)

Or you can skip the whole image creation process, just extract
ubuntu-core as root into empty directory and do similar process, then
you can tar archive it later to send to a target computer (using a Live USB)

The only thing of note I have, is that today I had a phantom bug that if
I change my /etc/apt/sources.list file (in chroot) to point to somewhere
else it fails (Does the ubuntu-core know the ip address of
archive.ubuntu.com? as there is no nslookup package installed in core to
lookup alt mirrors)

From,
Kieran Grant




More information about the Ubuntu-devel-discuss mailing list