Archive

Posts Tagged ‘linux’

Creating Hierarchical User Permissions Tutorial

May 11th, 2010

Dealing with multiple users on a single box can be frustrating at first. Especially when they edit the same files. I wanted to create a sort of hierarchy of users with my root and personal accounts at the top, and a pool of sub-accounts below. Here’s how I solved this problem in Ubuntu:

First, create a common group:

groupadd <group-name>

Next, make sure all of the sub-accounts use the new group as its default account.

For new users:

useradd -G <group-name> <username>

For existing users:

usermod -a -G <group-name> <username>

When a user creates a file or directory, they normally would use their own group. What we want is that any account in the common group to use the new group as its default:

usermod -g <group-name> <username>

Last, change the sub-users’ default umask settings so that it treats its own settings exactly the same as the group settings. Make sure to only run this command as one of the sub-accounts:

umask 0002

Now you have a list of accounts with limited permissions that your main account will always have access to. Now this is not an optimal, and probably secure solution, but since this only for my development environment, its good enough.

linux, programming , , , , , ,

Pure Linux DVD Ripping

April 10th, 2009

Whenever I wanted to rip DVD’s for longterm storage, I’ve always used Wine + DVDShrink. I just now discovered a pure linux program, Handbrake, for ripping DVD’s and so far, it has worked out really well This article does a really good job explaining it. Merry Ripping!

linux , , , , ,

Replacing Eclipse as My IDE With Vim

November 15th, 2008

Code editors are among the most important applications for a programmers. They are also the source of some the most heated debates online. Whether you use a full-fledged IDE like Eclipse or VisualStudios, or even a souped up text editors like Emacs or Vim, everybody has a favorite. My first IDE was Borland Turbo C and after a couple of months, “purchased” a free copy of VisualC++ (later known as VisualStudios). Finally paid for a student version when my parents found out I was really interested in programing.

VisualStudios was my main IDE until I started web development and moved to Linux. For more than a year now, I’ve been using Eclipse because their plugin system has enabled people to create really good editors for Java, PHP, Javascipt, Flex and HTML/CSS. Because it’s all in one program, the editor is really heavy and fairly bug prone. Recently, I’ve been making the switch from using Eclipse exclusively to moving most of my development to Vim.

Vim is a very good text editor and I chose it ahead of Emacs because in my opinion, the commands are simpler. Most of the common functionality of Eclipse can be found in Vim: search/replace, syntax highlighting, XDebug-ing, and much more. The debate between gui editors or vim/emacs is basically a moot point. They are just tools. Certain people’s thinking patterns are just more suited to one tool than the other. Since I use the command line for almost everything I do, using vim allows a much easier transition between editing files, writing scripts and interacting with remote hosts. For me, vim, along with all of the standard linux apps (find, grep, tail, ssh, scp, etc…), allows me to work more efficiently than any other tool so that is what I use.

linux, programming , , , , , , , , , , , , , , , , ,

Memcached Pool Bash Start Script

November 14th, 2008

If you installed Memcached using Yum under the RedHat flavor of Linux, they have this really nice init.d scripts for starting and stopping Memcache. I modified it in order to support creating a bunch memcache instances using contiguous ports. What’s great is that only the “start” script has to be modified since the “stop” script uses a special RedHat function, killproc, which can accept a program name or path and kill all instances of that program. I’m still a noob at bash scripts but here is my only changes:

NUMBUCKETS=3 #only new value needed
start() {
    for ((i=1;i<=$NUMBUCKETS;i+=1)); do
        FULLPORT=${PORT}${i}
        echo -n $"Starting $FULLPORT ($prog): \n"
        daemon $prog -d -p $FULLPORT -u $USER -c $MAXCONN -m $CACHESIZE $OPTIONS
        RETVAL=$?
    done
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
    return $RETVAL
}

linux, programming , , , , , , , , , ,

Vim Tips

September 23rd, 2008

Since switching to Linux, I have slowly fallen in love with Vim. I love how Vim makes it so that “your hands should never have to leave your keyboard” (Chris). The biggest drawback to using Vim, and Emacs, is that there’s a fairly steep learning curve. You pretty much have to abandon your comfort zone and force yourself to learn all of the different key bindings.

I’m very lucky in that I work with two vim gurus: Chris and Travis. Basically any question I have ever had with Vim, these two were able to answer them. But for times when they are not around I love using these sites:

This is a very short list because Vim is based on a few basic concepts and building on top of that. Once you get the basics, learning how to use buffers and macros gives you the ability to edit your files in any manner.

linux, programming , , , , , , , ,

Useful Linux Commands: Find and Search

September 1st, 2008

Learning Linux commands is probably the largest hump anybody new to Linux faces. Over the last year, I’ve compiled some useful, and somewhat non-obvious scripts that are really helpful to me on a weekly basis. Here are commands that deal with finding files and searching for text within a file:

Find and delete a directory:

find /PATH/TO/DIR -type d -name SEARCH -exec rm -rf {} \;

Find and delete a file:

find /PATH/TO/DIR -name SEARCH -exec rm -rf {} \;

Search within files:

 grep -r "SEARCH" *.EXTENSION /PATH/TO/DIR

Find and search within files:

find /PATH/TO/DIR -name "SEARCH" | xargs -I{} grep -H SEARCH {}

For more advanced options there’s always:

man find
man grep

linux , , , , , , , , , , , , ,

Removing Trackerd

August 27th, 2008

Trackerd is probably the least useful tool that comes with Ubuntu. While indexing, it maxes out cpu and memory. Of course it allows you to search, but the search never finds what I’m looking. In my experience, i’ve found that find and grep are much more useful, especially if its only within a subdirectory.

Trying to remove trackerd is much harder than one would think. Using apt/aptitude proved fruitless since trying to remove/purge trackerd or tracker-utils does absolutely nothing. From Travis, I use these two scripts to basically prevent trackerd from running:

killall trackerd
mv /usr/bin/trackerd /usr/bin/trackerd-old

You might want to use ‘whereis trackerd’ to find out where your trackerd binary is actually located before using the move command.

linux , , , , , , , ,

Ubuntu Sound and Video Problems

June 23rd, 2008

For the longest time, I’ve had terrible luck with sound and video problems with Ubuntu on a Dell Dimension E521 with nVidia sound and video cards. I thought it was terrible support by nVidia. Everytime I would update my computer, it would totally trash my video settings and sometimes, my sound settings.

Today after doing a bunch of updates, both my video and sound went to crap. With the help of my favorite Linux hacker, Travis, we figured out that I was actually running the server version of the Linux kernel. Next, I uninstalled all instances of the server kernels, uninstalled all nvidia drivers and modules, and rebooted. From there, I followed the basic steps to install nVidia drivers, configured my screen settings and now I am able to run all of the fancy Compiz visuals and my Ubuntu install has never been better.

linux , , , , , , , , , , ,

Sopcast and TVAnts: Stream Live TV or Movies From Home

June 22nd, 2008

I’m a really big sports fan, especially soccer. Living in the United States, this means that most international games are always 7 or more hours earlier than usual, and sometimes, they don’t even broadcast locally.

Using Sopcast and TVAnts, I’m able to watch any game I want, when I want. Granted, this is streaming P2P video so it is not the best quality and due to the latency, images can get choppy. For popular content like the current Euro 2008 or most UEFA Champions League matches, speed and quality can rival that of Vimeo or Youtube.

After painstakingly getting Sopcast to work on my linux box, I found this really easy to use tutorial on installing both Sopcast and TVAnts:
http://simonsmess.blogspot.com/2007/11/watching-sopcast-tvants-on-ubuntu.html

For TVAnts, get a link from a website or open the program under wine, double click a channel and write down link from popup box. This will start the stream on your local computer where you can use VLC or other capable media programs to view that stream.

With Sopcast, the method to start the stream is very similar. You can download the actual program and run it under wine or use the command line version which also creates a stream from your local computer like TVAnts.

Now that you have a link and you are streaming, use your favorite media play to stream or record that link. My favorite, VLC, makes it fairly easy to open and save that link. To just open the link, VLC has an option under “File” >> “Open Network Stream”. To save the stream is the same except you specifiy where you want your stream to be saved.

In order to provide Tivo-like recording, I use my crontabs to start and stop the stream. Here is a pretty good tutorial on using crontabs. Of course it would be much easier to use MythTV if the content was available on your tv, but Sopcast and TVAnts provide a way to accomplish almost the same functionality with a more work.

linux, tv shows, video , , , , , , , , , , ,