UbuntuFakeroot

Summary (from man page)

  • fakeroot - run a command in an environment faking root privileges for file manipulation

Prerequisites

   sudo apt-get install fakeroot

Example

Actually very similar examples are in the man page, too.

    /tmp/test-fakeroot$ fakeroot bash
    root@cscfpc:/tmp/test-fakeroot# mkdir dir1 dir1/dir2
    root@cscfpc:/tmp/test-fakeroot# find . -ls
    1310950    4 drwxrwxr-x   3 root     root         4096 May 30 15:40 .
    1310951    4 drwxrwxr-x   3 root     root         4096 May 30 15:40 ./dir1
    1310952    4 drwxrwxr-x   2 root     root         4096 May 30 15:40 ./dir1/dir2
    root@cscfpc:/tmp/test-fakeroot# mkdir dev
    root@cscfpc:/tmp/test-fakeroot# mknod dev/sda9 b 8 9
    root@cscfpc:/tmp/test-fakeroot# ls -ld dev/sda9
    brw-rw-r-- 1 root root 8, 9 May 30 15:40 dev/sda9
    root@cscfpc:/tmp/test-fakeroot# touch dir1/file1
    root@cscfpc:/tmp/test-fakeroot# ls -ld dir1/file1
    -rw-rw-r-- 1 root root 0 May 30 15:40 dir1/file1
    root@cscfpc:/tmp/test-fakeroot# chown cscf-adm:adm dir1/file1
    root@cscfpc:/tmp/test-fakeroot# touch dir1/dir2/file2
    root@cscfpc:/tmp/test-fakeroot# chown games:games dir1/dir2/file2
    root@cscfpc:/tmp/test-fakeroot# tar cf t.tar .
    tar: ./t.tar: file is the archive; not dumped
    root@cscfpc:/tmp/test-fakeroot# exit
    exit
    /tmp/test-fakeroot$ tar tvf t.tar
    drwxrwxr-x root/root         0 2016-05-30 15:41 ./
    drwxrwxr-x root/root         0 2016-05-30 15:40 ./dir1/
    drwxrwxr-x root/root         0 2016-05-30 15:41 ./dir1/dir2/
    -rw-rw-r-- games/games       0 2016-05-30 15:41 ./dir1/dir2/file2
    -rw-rw-r-- cscf-adm/adm      0 2016-05-30 15:40 ./dir1/file1
    drwxrwxr-x root/root         0 2016-05-30 15:40 ./dev/
    brw-rw-r-- root/root       8,9 2016-05-30 15:40 ./dev/sda9
    /tmp/test-fakeroot$ find . -ls
    1310950    4 drwxrwxr-x   4 arpepper arpepper     4096 May 30 15:41 .
    1310951    4 drwxrwxr-x   3 arpepper arpepper     4096 May 30 15:40 ./dir1
    1310952    4 drwxrwxr-x   2 arpepper arpepper     4096 May 30 15:41 ./dir1/dir2
    1310956    0 -rw-rw-r--   1 arpepper arpepper        0 May 30 15:41 ./dir1/dir2/file2
    1310955    0 -rw-rw-r--   1 arpepper arpepper        0 May 30 15:40 ./dir1/file1
    1310953    4 drwxrwxr-x   2 arpepper arpepper     4096 May 30 15:40 ./dev
    1310954    0 -rw-r--r--   1 arpepper arpepper        0 May 30 15:40 ./dev/sda9
    1310957   12 -rw-rw-r--   1 arpepper arpepper    10240 May 30 15:41 ./t.tar
    /tmp/test-fakeroot$ 
An oddity is that, although arpepper is in group adm the group membership did not get set. That's presumably because the joint chown call failed. To wit..
    /tmp/test-fakeroot$ fakeroot chgrp adm /tmp/test-fakeroot/dir1/file1
    /tmp/test-fakeroot$ ls -ld /tmp/test-fakeroot/dir1/file1
    -rw-rw-r-- 1 arpepper adm 0 May 30 15:40 /tmp/test-fakeroot/dir1/file1
    /tmp/test-fakeroot$ 

-- AdrianPepper - 2016-05-30

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r2 - 2016-05-31 - AdrianPepper
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback