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:
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:
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
bash, groupadd, linux, tutorial, ubuntu, useradd, usermod
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
bash, howto, linux, linux tutorial, memcache, memcached, programming, redhat, scripting, scripts, tutorial
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:
linux
bash, bash scripting, commandline, commands, find, grep, linux, linux scripting, linux terminal, scripting, scripts, search, terminal, zsh