Linux dpkg Software Report

Christian Schult cschult at gmx.de
Fri Dec 25 09:02:16 UTC 2009


Hello Ray,

Ray Parrish wrote:

> Christian Schult wrote:

> > Tim Frost wrote:

> >> On Tue, 2009-12-22 at 21:25 -0800, Ray Parrish wrote:

> >>> I hope I won't get flamed for this, but I have just completed my most 
> >>> ambitious script to date, and have completed the Linux dpkg Software 
> >>> Report script which takes output from dpkg, and formats it into html 
> >>> pages sorted by package section, such as Games, Editors, etc... and also 
> >>> generates an alphabetical index to the packages.

> >> This allows an admin to install the scripts in a system directory such
> >> as /usr/bin, without needing to compromise system security.

> > Sorry for beeing a bit nitpicking, of course one can install files where
> > one wants to. According to FHS [1] it's recommended to put executables
> > not installed by the systems package management into /usr/local/bin.

> I did not know this since I'm fairly new to Linux, and did not think 
> that I could install to such a location without having root privileges. 

Of course you need root permissions to install to /usr/local. If you
install the script as a normal user you could install it to $HOME/bin
which probably already is set in the users PATH environment variable,
but it should be left to the users discretion where he installs inside
his home dir.

> Do I need to write another script which requires root permissions to 
> install the script to that location?

$ sudo cp -i YourScript.sh /usr/local/bin
$ sudo chown root:root /usr/local/bin/YourScript.sh
$ sudo chmod 755 /usr/local/bin/YourScript.sh

should be all to do. Btw, you can't give a script root permissions,
scripts always run with the rights of the invoking user. You need to be
root, or use sudo, to run a script with root permissions.

> > This ensures that locally installed files do not overwrite files
> > installed by package management or aren't overwritten by them in future.
> > Also backup is easy because you only have to backup /usr/local.

> That sounds good, but I will need to determine a good place to write the 
> output files of the script to, as I am sure no one wants them in a 
> folder hanging off of /usr/local/bin, and the script as written is 
> designed to add a folder, and write it's output files into the folder 
> where it is ran from. Not too difficult a change, just need to know 
> where to write the output... is it still kosher to write it to the 
> user's home folder structure as some programs do with their 
> configuration files and things?

Temporary files only needed at runtime by the script should be written
to /tmp or $TMPDIR - if set. Let the script create a folder under the
tmpdir where to place your temporary files, so you can delete that
folder when the script ends an don't risk to accidentally delete other
files.

Generated output like that html files your script produces should
be placed into the users home. If run by root and all users shall be
able to read the output you could place it into - hm -
/usr/local/lib/YourScriptName. Set appropriate permissions for everyone
to read the files.

Merry Christmas!

Christian




More information about the ubuntu-users mailing list