<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6949755262638406535</id><updated>2011-12-08T22:44:05.311-08:00</updated><title type='text'>Bingo</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://bingouv.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6949755262638406535/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://bingouv.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Bingo</name><uri>http://www.blogger.com/profile/13157100120237815021</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6949755262638406535.post-2994137175266172542</id><published>2008-08-16T12:21:00.000-07:00</published><updated>2008-09-03T11:24:35.095-07:00</updated><title type='text'>Linux: Share files between two or more users</title><content type='html'>We need to maintain the situation where all files in a given directory satisfy these requirements:&lt;br /&gt;1. Owned by a common group , say "team".&lt;br /&gt;2. Permissions - 770 or thereabouts.&lt;br /&gt;&lt;br /&gt;I have faced this requirement many times, and many others have asked questions about this. So I decided to create a script for this.&lt;br /&gt;&lt;br /&gt;The following script fixes the owner of all files in the given directory to root. Group owner is forced to be "team", and file permissions to be 770. It uses inotify to fix a file as soon as it is created, or its permissions are modified. You need to install inotify-tools package of your distribution. Tested with Fedora 9 linux, and eeebuntu on a eeepc.&lt;br /&gt;&lt;br /&gt;If you save this as filepermd.sh, you have to call it as&lt;br /&gt;&lt;br /&gt;sudo nice filepermd.sh /path/to/shared/directory/  team&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;#!/bin/bash&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;#remove trailing slash&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 255, 255);"&gt;dirRoot&lt;/span&gt;=&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;`echo &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;$1&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;|&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;sed&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;'&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 255, 0);"&gt;s/&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;\(&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 255, 0);"&gt;.*&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;\)&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 255, 0);"&gt;\/$/\1/&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;'&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;`&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;echo&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 255, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;$dirRoot&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 255, 255);"&gt;groupname&lt;/span&gt;=&lt;span style="color: rgb(255, 64, 255);"&gt;$2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;chown root:&lt;span style="color: rgb(255, 64, 255);"&gt;$groupname&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;$dirRoot&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;inotifywait &lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;-c&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;-e&lt;/b&gt;&lt;/span&gt; ATTRIB &lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;-e&lt;/b&gt;&lt;/span&gt; CREATE &lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;-r&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;-m&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;$dirRoot&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;|&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;while&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;read&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt; line&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;do&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(0, 255, 255);"&gt;dirname&lt;/span&gt;=&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;`echo &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;$line&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;|&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt; awk -F&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 255, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;'&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 255, 0);"&gt;{print $1}&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;'&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;`&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(0, 255, 255);"&gt;filename&lt;/span&gt;=&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;`echo &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;$line&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;|&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt; awk -F&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 255, 0);"&gt;,&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;'&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 255, 0);"&gt;{print $NF}&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;'&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;`&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(0, 255, 255);"&gt;filepath&lt;/span&gt;=&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;${&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;dirname&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;}${&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;filename&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;}&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(0, 255, 255);"&gt;perm&lt;/span&gt;=&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;`&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;ls&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt; -ld &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;$filepath&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;|&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt; awk &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;'&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 255, 0);"&gt;{print $1}&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;'&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;|&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;sed&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;'&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 255, 0);"&gt;s/.&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;\(&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 255, 0);"&gt;.*&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;\)&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 255, 0);"&gt;/\1/&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;'&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;`&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(255, 96, 96);"&gt;#remove first letter from permissions string. This is d for a &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(255, 96, 96);"&gt;#directory, and - for a file. Not useful for us.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(0, 255, 255);"&gt;owner&lt;/span&gt;=&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;`stat -c &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;'&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 255, 0);"&gt;%U&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;'&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;$filepath&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;`&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(0, 255, 255);"&gt;groupowner&lt;/span&gt;=&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;`stat -c &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;'&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 255, 0);"&gt;%G&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;'&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;$filepath&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 96, 96);"&gt;&lt;b&gt;`&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;[&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 255, 0);"&gt;rwxrwx---&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;!=&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;$perm&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;]&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;;&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;then&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;chmod&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(0, 255, 0);"&gt;770&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;$filepath&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;fi&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;[&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 255, 0);"&gt;root&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;!=&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;$owner&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;]&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;;&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;then&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      chown root &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;$filepath&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;fi&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;[&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;$groupname&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;!=&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;$groupowner&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;]&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;;&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;then&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      chgrp &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;$groupname&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt; &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 64, 255);"&gt;$filepath&lt;/span&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;"&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;fi&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(128, 128, 255);"&gt;&lt;b&gt;done&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Known Limitations: Following characters in filename, or directory path not supported. Such files will be silently ignored.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Comma (,)&lt;/li&gt;&lt;li&gt;BackSlash (\)&lt;/li&gt;&lt;li&gt;Double-quote (")&lt;/li&gt;&lt;li&gt;Single-quote (')&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;This is somewhat crude currently, but it will be modified as I get more feedback.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6949755262638406535-2994137175266172542?l=bingouv.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bingouv.blogspot.com/feeds/2994137175266172542/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6949755262638406535&amp;postID=2994137175266172542' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6949755262638406535/posts/default/2994137175266172542'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6949755262638406535/posts/default/2994137175266172542'/><link rel='alternate' type='text/html' href='http://bingouv.blogspot.com/2008/08/script-to-fix-directory-permission-and.html' title='Linux: Share files between two or more users'/><author><name>Bingo</name><uri>http://www.blogger.com/profile/13157100120237815021</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6949755262638406535.post-142606807724690981</id><published>2008-08-10T07:24:00.000-07:00</published><updated>2008-09-29T08:30:09.145-07:00</updated><title type='text'>Desktop linux performance comparison:32 bit vs 64 bit</title><content type='html'>It has been a long time since processors supporting 64 bit operating systems became commonplace. But desktop users have still not migrated en-masse to 64 bit operating systems, and with good reason:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1. &lt;span style="font-weight: bold;"&gt;Performance&lt;/span&gt; benefits were not compelling enough to trigger the move. The few reviews that have been conducted and publicly available, 64 bit did not come as unquestionably better performing.&lt;br /&gt;&lt;br /&gt;2. Distributions were saddled with &lt;span style="font-weight: bold;"&gt;compatibility&lt;/span&gt; issues. Flash, java, mplayer codecs were some items that needed workarounds to make them work in 64 bit. Most of these workarounds were to actually use a 32 bit executable running inside a 64 bit operating system. There were always alternatives, like &lt;a href="http://en.wikipedia.org/wiki/IcedTea"&gt;IcedTea&lt;/a&gt; for java and &lt;a href="http://www.gnu.org/software/gnash/"&gt;Gnash&lt;/a&gt; for flash.&lt;br /&gt;&lt;br /&gt;3. Most users had &lt;span style="font-weight: bold;"&gt;RAM&lt;/span&gt; well within the 4GiB limit for 32 bit. Moreover, 64 bit is not the only way to use more than 4GiB RAM anyway. There is always PAE, though with an overhead.You can use 64GiB RAM with PAE which is enough not only for most desktop users, but also for many servers.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Surprisingly, I did not find the internet infested with comparisons between 32 bit and 64 bit. &lt;a href="http://www.phoronix.com/scan.php?page=article&amp;amp;item=616&amp;amp;num=1"&gt;Phoronix&lt;/a&gt; did a review about 20 months ago, which can easily be termed obsolete.In that review, 32 bit was the winner in performance in most applications that mattered (to me, anyway). Add that to the compatibility issues encountered in the 64 bit flavour of most distributions, and 64 bit is just not justified. The categorical defeat of 64 bit in the last battle makes it all the more important that more battles be fought and users get to know the results so that they can make an informed decision as to whether to opt to x86_64 or x86 flavour of their favourite distribution.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Test Procedure:&lt;/span&gt;&lt;br /&gt;Var&lt;span&gt;ious&lt;/span&gt; programs were run on both Fedora 9 Live USB x86, and Fedora 9 Live USB x86_64. The time taken, and CPU cycles consumed by the programs were measured using the &lt;span style="font-style: italic;"&gt;time&lt;/span&gt; command&lt;span style="font-style: italic;"&gt;. &lt;/span&gt;The "real" time was measured in the majority of cases, unless an exception is noted in the detailed description below. In all the cases, difference between time readings for consecutive runs of the same test varied not more than 2%. The tests were run 3 times and the median readings were considered. After each run, the filesystem on which the tests were run was unmounted and mounted again so that filesystem caches are cleared and subsequent runs do not get an unfair advantage. The activities that were chosen for testing are such that I/O is not an overwhelming part of performing them.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Why Fedora?&lt;/span&gt;&lt;br /&gt;Well, I use fedora anyway. When released, Fedora generally includes cutting edge versions of software but now it is about 5 months since it was released. So Fedora 9 can be considered of intermediate cutting-edgedness at the time of testing.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Hardware&lt;/span&gt;&lt;br /&gt;It is a 18 months old self-assembled PC that I consider eligible for this testing because of being close to the average newness of PCs. Newer systems might take better advantage of 64 bit OS. You can judge for yourself whether the review is relevant to you by reading the below specifications:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Motherboard&lt;/span&gt;:     ASUS P5B-VM, Intel 965G chipset&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Graphics&lt;/span&gt;:        Intel Integrated X3000&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Processor&lt;/span&gt;:       Intel Core 2 Duo E6300, 1.86 GHz.&lt;br /&gt;&lt;span style="font-size:130%;"&gt;RAM&lt;/span&gt;:             Kingston 667 MHz, 2 sticks of 1GB each&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Hard disk&lt;/span&gt;:       Seagate 160GB SATA&lt;br /&gt;No component has been overclocked.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Software&lt;/span&gt;&lt;br /&gt;A detailed list of all software installed in a default Fedora 9 live CD can be obtained from &lt;a href="http://fedoraproject.org/"&gt;Fedora home page&lt;/a&gt;. I am listing the chief ingredients, and the additional software I used for testing.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Kernel&lt;/span&gt;:      2.6.25-&lt;span style="font-size:100%;"&gt;14&lt;/span&gt;.fc9.&lt;span style="font-size:100%;"&gt;i686&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;bc&lt;/span&gt;:          bc-1.06-33.fc9&lt;br /&gt;&lt;span style="font-size:130%;"&gt;mencoder&lt;/span&gt;:    &lt;a href="http://rpm.livna.org/"&gt;livna&lt;/a&gt;'s build,mencoder-1.0-0.94.20080531svn.lvn9&lt;br /&gt;&lt;span style="font-size:130%;"&gt;lame&lt;/span&gt;:        &lt;a href="http://rpm.livna.org/"&gt;livna&lt;/a&gt;'s build,lame-3.97-6.lvn8&lt;br /&gt;&lt;span style="font-size:130%;"&gt;gpg&lt;/span&gt;:     gnupg2-2.0.9-1.fc9&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="http://lh6.ggpht.com/right.ho/SKL1a3mUB0I/AAAAAAAAAEQ/0_F0hDuZ228/factorial.jpg&amp;amp;imgmax=640" /&gt;&lt;br /&gt;The bc function for factorial has been picked up from the man page of bc. Example code for factorial 20,000 is given below.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-family:arial;"&gt;define f (x) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;        if (x &lt;= 1) return (1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;            return (f(x-1) * x);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;f(20000)&lt;/span&gt;&lt;/blockquote&gt;A sample command to use the above bc code is given below. The output is redirected to null device because printing the huge factorial would be a mammoth exercise in I/O which is outside the scope of this review.&lt;br /&gt;&lt;br /&gt;&lt;blockquote style="font-family: arial;"&gt;time bc factorial20k.bc &gt; /dev/null&lt;/blockquote&gt;&lt;br /&gt;This is not to say that people love to calculate factorials of large numbers in their spare time, but the &lt;a href="http://en.wikipedia.org/wiki/64-bit#32_vs_64_bit"&gt;wikipedia article about 64 bit architecture&lt;/a&gt; mentions that factorial can be calculated approximately twice as fast in 64 bit as compared to 32 bit. This makes it an important metric about 64 bit operating system performance. You will note that we are far from realizing this potential of 2 times gain by 64 bit, but we get around 10% gain in all these factorial tests which is significant.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="http://lh3.ggpht.com/right.ho/SKLziQanoDI/AAAAAAAAAEI/hLZ3fZPsLOk/mencoder.jpg&amp;amp;imgmax=640" /&gt;&lt;br /&gt;&lt;br /&gt;A 700MB video was encoded using mencoder with the following options. Livna's build of mplayer was used.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-family:arial;"&gt;time mencoder $videoIn -oac lavc -ovc lavc -lavcopts \&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;    abitrate=112:vbitrate=736 -o $videoOut  &gt; /dev/null 2&gt;&amp;amp;1&lt;/span&gt;&lt;/blockquote&gt;Gain is about 10% with 64 bit.&lt;br /&gt;&lt;br /&gt;&lt;img src="http://lh6.ggpht.com/right.ho/SKfJUOCuOvI/AAAAAAAAAEs/q3vMZAbiZD0/gpg.jpg&amp;amp;imgmax=640" /&gt;&lt;br /&gt;&lt;br /&gt;A 700MB file was encrypted using default gpg algorithm, with a 4096 bit key.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-family:arial;"&gt;time gpg --encrypt --recipient 'my name' $inputFile&lt;/span&gt;&lt;/blockquote&gt;The same file was decrypted again. The time considered here is 'user' time + 'system' time as reported by the time command. This is because I had to type the password each time and a comparison of my typing speed under 32 bit vs 64 bit Fedora is outside the scope of this review. So the 'real' time is irrelevant for our purposes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;&lt;blockquote&gt;time gpg --output $outputFile --decrypt $inputFile&lt;/blockquote&gt;&lt;/span&gt;Gain with 64 bit is about 17% for encrypt, and an awesome 32% with for decrypt.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="http://lh5.ggpht.com/right.ho/SKfLHOtBndI/AAAAAAAAAE0/7XxGtTkXE7Q/lame.jpg&amp;amp;imgmax=640" /&gt;&lt;br /&gt;A 100 MB wav was encoded to mp3 using default settings of lame.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-family:arial;"&gt;time lame testIn.wav testOut.mp3&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;Gain with 64 bit was noted to be about 5%.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 102);"&gt;Coming soon: multi-tasking performance of 64 bit vs 32 bit&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Multi Tasking&lt;/span&gt;&lt;br /&gt;Now we know that factorial computation is 9.8% faster for 64 bit; and video encoding is 10.6% faster. What happens when we run many CPU intensive processes together? All processes have to do their own thing, but in addition to this, the kernel has to switch between processes. This switching has an overhead, and it might be helpful if we know whether this overhead is any lower on x86_64 as compared to x86. Admittedly the overhead is very small to measure in a small time experiment, but here is an attempt.&lt;br /&gt;&lt;br /&gt;I started 5 processes of factorial computation, and 5 processes of video encoding, all in parallel. I let them run for 20 minutes, and calculated how many times they finish their task in the given 20 minutes. Running this test again yielded identical results, I didn't try a third time. Results:&lt;br /&gt;x86:&lt;br /&gt;Calculated factorial of 20,000 &lt;span style="font-style: italic;"&gt;85&lt;/span&gt; times&lt;br /&gt;Encoded a 5 minute sample of the above video &lt;span style="font-style: italic;"&gt;45&lt;/span&gt; times&lt;br /&gt;&lt;br /&gt;x86_64:&lt;br /&gt;Calculated factorial of 20,000 &lt;span style="font-style: italic;"&gt;95&lt;/span&gt; times&lt;br /&gt;Encoded a 5 minute sample of the above video &lt;span style="font-style: italic;"&gt;50&lt;/span&gt; times&lt;br /&gt;&lt;br /&gt;Turns out, the context switching overhead is nearly identical in x86 and x86_64. The difference observed is within experimental error boundaries. Calculations?&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Factorial: Ratio of time taken x86/x86_64 = 13.4/12.1 = 1.11&lt;br /&gt;        Expected ratio of iterations in a fixed time: 12.1/13.4 = 0.90&lt;br /&gt;        Observed ratio = 85/95 = 0.89&lt;br /&gt;Encoding:  Ratio of time taken x86/x86_64 = 596.18/533.22 = 1.12&lt;br /&gt;        Expected ratio of iterations in a fixed time = 533.22/596.18 = 0.89&lt;br /&gt;        Observed ratio = 45/50 = 0.90&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;For factorial computation x86_64 had a slightly lower overhead, but it had slightly larger overhead for video encoding. Cannot conclude any great difference from these results. Admittedly, the multi-tasking test is the least convincing part of this review and there are surely other ways to test this better. Seems like the better methods involve more work,, but suggestions of all kinds are welcome.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Conclusion&lt;/span&gt;&lt;br /&gt;It can be safely concluded that performance gain by 64 bit OS has become significant for even a casual user to notice. It does not change the world, and most activities are anyway not processor bound these days. Support for 64 bit features must have improved significantly since the phoronix review where 64 bit took a beating from 32 bit.&lt;br /&gt;&lt;br /&gt;Note that if the gain is not up to the potential of x86_64 architecture, this could be the fault of application(including libraries), compiler or the kernel. The  activities tested are not a typical workload of an average user, but an attempt has been made to test the typical CPU intensive activities that a user is likely to expect from his computer.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6949755262638406535-142606807724690981?l=bingouv.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bingouv.blogspot.com/feeds/142606807724690981/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6949755262638406535&amp;postID=142606807724690981' title='82 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6949755262638406535/posts/default/142606807724690981'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6949755262638406535/posts/default/142606807724690981'/><link rel='alternate' type='text/html' href='http://bingouv.blogspot.com/2008/08/desktop-linux-performance-comparison32.html' title='Desktop linux performance comparison:32 bit vs 64 bit'/><author><name>Bingo</name><uri>http://www.blogger.com/profile/13157100120237815021</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/right.ho/SKL1a3mUB0I/AAAAAAAAAEQ/0_F0hDuZ228/s72-c/factorial.jpg&amp;imgmax=640' height='72' width='72'/><thr:total>82</thr:total></entry></feed>
