sontek ( John M. Anderson )

July 21, 2008

Firefox Plugin for Tomboy

Filed under: Firefox, Linux, Tomboy — Tags: , , — sontek @ 4:39 pm

A great new Firefox plugin has been created that allows you to create new Tomboy notes from selected text in Firefox, check it out here.

July 4, 2008

Advanced file permissions in Linux

Filed under: GNOME, Linux, SUSE — Tags: , , , , , , — sontek @ 2:06 pm

A lot of Linux/openSUSE users aren’t aware that there are more to file system permissions than the obvious Owner, Group, Other / Read, Write, Execute setup.

All major Linux file systems (ext3, reiserfs, etc) support access control lists (ACL) and its very easy to use them.

To see if a file or directory has an ACL set on it, you can use ls:

inspidell:~ # ls -ld /home/sontek

You’ll get output similar to this:

drwxr-xr-x+ 55 sontek users 4096 JulĀ  4 13:42 /home/sontek

The + at the end of the permissions means that we are using extended permissions (ACL’s). To get the list of ACL’s on the file/directory, run the getfacl <file> command.

inspidell:~ # getfacl /home/sontek
getfacl: Removing leading '/' from absolute path names
# file: home/sontek
# owner: sontek
# group: users
user::rwx
group::r-x
other::r-x
default:user::rwx
default:group:users:---
default:mask::r-x
default:other::r-x

This shows both the ACL’s and the basic Linux permissions.

To modify or set ACL’s you use the setfacl command. Here are a few examples of how to use it:

Grant a single user read access to a directory in your home directory.
setfacl -m u:mom:r /home/sontek/photos

Remove all access from a group on a file
setfacl -x g:developers payroll.xml

You can also copy a set of permissions from one file to another
getfacl file1 | setfacl --set-file=- file2

Remove all ACL’s
setfacl -k /home/sontek

For those of you who are not console jockey’s, you’ll realize quickly that the default nautilus setup doesn’t have a way to view, modify, or add any ACL’s, to get this support you’ll need to install two packages, with opensuse you do this with zypper:

inspidell:~ # zypper in eiciel nautilus-eiciel

Before the ACL permissions show up in nautilus, you’ll have to restart it:

inspidell:~ # pkill nautilus

After this, you’ll be greeted with a very easy to use dialog for modifying ACL’s:
Screenshot of FACL permissions

another great nautilus permissions tip I learned from Christer Edwards is to enable advanced permissions in nautilus, this is a much better UI for managing permissions and should probably be the default.

gconftool-2 --type bool --set /apps/nautilus/preferences/show_advanced_permissions True

A screenshot of this in action:

Screenshot of nautilus advanced permissions

I hope this helps you better secure and manage your computer with the more advanced features your Linux file systems both from console and inside GNOME.

July 2, 2008

Get the changelog of a package with rpm

Filed under: Linux, RPM, SUSE — Tags: , , , , — sontek @ 2:59 am

Ever run system updates in Linux (i.e openSUSE) and get a package that doesn’t seem to be changed and wonder why the update was pushed? Or just interested in following the latest changes to some of your favorite Linux packages?

With rpm you can view all the latest changes in an easily to read format. To get the changelog of a package with rpm you do the following:

$ rpm -q --changelog <package> | less

replace <package> with whatever ever package you would like to see the changelog for (i.e rpm -q –changelog banshee-1 | less)

This is for rpm based Linux distributions (i.e openSUSE, Redhat)

June 22, 2008

Achieve Zen with openSUSE 11.0 (i.e Get rid of pulse audio)

Filed under: Linux, SUSE — Tags: , , , , — sontek @ 3:23 pm

I’ve been having a lot of stability issues with openSUSE 11.0 lately and the majority of them boiled down to audio.

Here is a list of a few:

1. VLC required root to have audio, wtf?
2. Sound would crash after listening to any audio for an extended period of time (music, video, flash).
3. If my audio crashed, Firefox could not start up until I did rcalsasound restart
4. Some videos were slow/choppy.

So, you are probably asking, how did I fix all these issues?

zypper rm alsa-plugins-pulse
zypper addlock alsa-plugins-pulse

This removes the alsa plugin for pulse and locks it so it will never install again. Without the alsa plugin installed, the apps go back to using alsa directly. This has fixed every issue I’ve had with openSUSE 11.0 so far.

June 9, 2008

Official OpenSUSE Forums

Filed under: Linux, SUSE — Tags: , , — sontek @ 11:00 pm

Great news! The official openSUSE forums are finally here, combining the awesome communities from suseforums.net, suselinuxsupport.de and the openSUSE support forums at forums.novell.com.

If everyone could try to spend a half hour each day browsing the forums to help new users, it would benefit the whole community. openSUSE is growing fast and these forums fill a huge gap in our community for new users.

Without further adieu, http://forums.opensuse.org/

openSUSE 11.0 RC2 - Please do final testing!

Filed under: Linux, SUSE — Tags: , , — sontek @ 9:25 pm

Coolo was nice enough to leak us the RC2 LiveCD’s for openSUSE 11.0 RC2, please download and do final testing to make sure we have the best openSUSE release. Get them here

Features to test can be found here and as always, check most annoying bugs.

May 6, 2008

Utah openSUSE User Group meeting tonight!

Filed under: Linux, SUSE — Tags: , , — sontek @ 9:18 am

Tonight we are having our first openSUSE User Group meeting, we’ll be discussing 11.0 Beta 2.

* Date/Time: Tuesday, May 6, 2008 @ 7:00pm.
* Location: Applebees, 105 E 12300 S, Draper, UT
* Google Maps: Click Here

You can get more information on the group here.

April 16, 2008

Printing in GTK#

Filed under: .NET, Databases, Mono, Postgresql, Programming, Xorg, irssi — Tags: , , , , , — sontek @ 11:58 pm

I just finished porting Tomboy’s print code to GTK so that we would be more portable and I thought other Mono apps looking to move from libgnomeprint or wanting to add printing support might find a code example helpful.

First, To start printing you do something like:

private void PrintButtonClicked (object sender, EventArgs args)
{
Gtk.PrintOperation op = new PrintOperation ();
op.BeginPrint += new BeginPrintHandler (OnBeginPrint);
op.DrawPage += new DrawPageHandler(OnDrawPage);

op.Run (Gtk.PrintOperationAction.PrintDialog, this.Window);
}

after the PrintOperation is set off you need to handle the BeginPrint event. The main things that need to be done are finding out how many lines will fit on a page and how many lines you have:

public void OnBeginPrint(object sender, Gtk.BeginPrintArgs args)
{
PrintOperation op = (PrintOperation)sender;
lines_per_page = (int)Math.Floor ((double)args.Context.Height / (double)font_size);
Gtk.TextIter start_iter, end_iter;
this.Buffer.GetBounds (out start_iter, out end_iter);
lines = this.Buffer.GetText (start_iter, end_iter, false).Split ('\n');
op.NPages = (int)Math.Ceiling ((double)lines.Length / (double)lines_per_page);
}

Finally, now that you have the printing setup, you need to actually render the data to be printed:

public void OnDrawPage(object sender, Gtk.DrawPageArgs args)
{
PrintOperation op = (PrintOperation)sender;
Cairo.Context cr = args.Context.CairoContext;

int line = args.PageNr * lines_per_page;
int num_lines = 0;
if (args.PageNr+1 != op.NPages)
num_lines = line + lines_per_page;
else
num_lines = lines.Length;

cr.MoveTo (0, 0);

for (int i = 0; i < lines_per_page && line < num_lines; i++)
{
Pango.Layout layout = args.Context.CreatePangoLayout ();
Pango.FontDescription desc = Pango.FontDescription.FromString (”sans ” + font_size);
desc.Size = (int)(font_size * Pango.Scale.PangoScale);
layout.FontDescription = desc;

layout.SetText (lines[line]);
Pango.CairoHelper.ShowLayout (cr, layout);
cr.RelMoveTo (0, font_size);
line++;
}
}

This does not take into account styles but will give you the basic idea of what needs to be done.

March 20, 2008

My top 15 commands

Filed under: Bash, Linux — Tags: , — sontek @ 5:49 pm

My friend Sam posted a blog on his top 15 commands used from the commandline, so here are mine:

sontek@inspidell:~> history | awk ‘{print $2}’ | awk ‘BEGIN {FS=”|”} {print $1}’|sort|uniq -c | sort -n | tail -n 15 | sort -nr
143 ls
135 cd
84 vim
69 exit
57 ssh
56 su
35 svn
25 man
24 rm
24 python
22 sudo
22 jhbuild
18 make
17 grep
16 xrandr

You can tell a lot about a person by their top 15 commands and as you can see with mine, the majority of mine are used for coding!

You can see a break down of the command I used to list these here: http://czarism.com/my-top-ten-linux-comments-history

What are your top 15 commands?

Debugging with strace

Filed under: Bash, Linux, Programming — Tags: , , , — sontek @ 5:16 pm

I was helping a friend debug a problem with gksu (gnomesu alternative) today and we chose to use strace which allows you trace system calls an application makes.

To monitor all system calls an application makes you can redirect the output to a file like so:

strace <command> 2> <file name>
or
strace <command> -o <file name>

These commands return the exact same results, the first command redirects stderr (standard error, which has the file descriptor 2) to the file, strace sends all output to stderr by default, the second command uses the built in -o argument which is much cleaner.

One of the first things I like to do with strace is to check if it is having trouble accessing a file, which I see a lot because the file doesn’t exist or the user executing the command does not have permission to access it, you can do that with these commands:

strace <command> 2>&1 |grep open
or
strace <command> -e open

Again, these commands will return similar results. The first command redirects stderr to stdout so you can use grep to filter the output. The second command is the preferred method because it actually uses the built in -e argument which will trace only the named system call (this is a comma separated list so you can do strace -e open,read).

The only other arguments that I’ve found really helpful are -ff which when used with -o will append the pid (process id) to the file name and -F which will also trace children.

Newer Posts »

Powered by WordPress