Archive for July, 2010

Managing Users in uBuntu

This post is a brief description of the very basic tools used to manage users and groups in uBuntu. Like many of my posts, this list is a quick reference of stuff you probably already know and have used before.

Add and Remove users

Add a new user. This command also creates a home directory at /home/username

adduser username

Delete a user. This command also removes the user’s home directory.

sudo deluser --remove-home username

Add and Remove Groups

Before creating a group, check if it exits

grep developers /etc/group

Then to create the group:

sudo addgroup superuberusergroup

Assign a user to groups

See what groups the user is in:

id username

Set a user’s primary group:

usermod -g primarygroup username

Add a user to another group:

usermod -a -G anothergroup username

Set resource permissions

Change ownership of resources. This command recursively sets the group owner of a file or folder to the specified group

sudo chown -R :GROUPNAME location_of_resources

Make resources group writeable. This command sets the ‘group writeable’ flag on a resource

chmod -R g+w location_of_resources

Essential Linux Commands

A brief dump of the linux commands that I can’t live without, and sometimes need a reminder on how to use. I use ubuntu, usually the latest ’stable’ release, so the example in this post and later updates will reflect that. Right now (last update) I’m running uBuntu 10.04

cat

Short for Concatenate. It’s designed for concatenating files. Use it like ‘type’ on windows for outputting file contents to the console.
Example: get the version of linux that you are running.

cat /proc/version

top

Top is the Task Manager of linux. Detailed description here. Use it to see what process is hogging your memory.

Example use:

top

wget

wget is for downloading files

Example use:

wget http://www.stuff.com/file.7z

rm

Delete stuff!

Example use: delete folder and contents

rm -f -r tempdir

find

Find stuff!

Example use: find ‘c’ files

find . -name '*.c'

Set JAVA_HOME in uBuntu

Many programs use the JAVA_HOME environment variable in Linux. Here’s how to ’set’ it permanently. Note that the paths mentioned are accurate for uBuntu 10.04, and mileage may vary with other Linux flavours.

The path to use for JAVA_HOME is ‘/usr/lib/jvm/java-6-sun‘. Check that the path exists before continuing.

Add the following line to /etc/environment. Remember to sudo to launch your text editor, as this is a privileged file.
JAVA_HOME=”/usr/lib/jvm/java-6-sun”

You’re done! If you are using a desktop environment, log out and log in again to get it to stick.

If you are connected over ssh or running on the console of the server version, run this command to get your changes to stick:
source /etc/environment