Tuesday, January 7, 2014

Fixing NIS Client/AutoFS Login Permission Error

Greetings, weary tech[no] traveler!

So...you've decided to make that shinny, new Ubuntu 12.04 server of yours into an NIS client.  You've gone through all the necessary steps to install and set up NIS, AutoFS, and NFS.  Yet for some reason (which will be made obvious soon), neither you nor anyone else with NIS credentials can:
  1. Edit, delete, create, or copy any files they owned before NIS was set up.
  2. Get their home directory (for example: /home/username) auto-mounted.
All they get is this error message (seen below) at the command line:

Could not chdir to home directory /home/username: Permission denied
-bash: /home/username/.bash_profile: Permission denied


Permission denied?!  What gives, brah?

Let's check the permissions of all the home directories.  At the command line, run the following command:

ls -l /home

You will get output that will look similar to this:

drwx--S--- 15 username username 4096 Dec 31 15:04 username/
                             :
                             :
                             :

Apparently, the permissions on the home directory are restrictive such that there are no read, write, or execute bits for group (g+rwx).  Since username (in your case might be something different) is most likely not a valid NIS group (depending on how you set up your NIS groups), there's no way you'll be able to access your home directory; let alone auto-mount it.

Let's check and compare one other thing; the User IDs (UID) of username on the NIS server we are trying to authenticate with and on our troublesome NIS client.   Alternatively, if you do not have access to the NIS server, you can check the UID of username on another NIS client that does work.  At the command line of both machines, run the following command:

getent passwd username

The output from our troublesome NIS client will look similar to this:

username:x:1000:1000:username,,,:/home/username:/bin/bash

The output from the same command, ran on our NIS server (or working NIS client), will look similar to this:

username:x:34528:1000:username,,,:/home/username:/bin/bash

Notice how the UIDs are different.  The UID, of username, on the NIS server is (in this case) 34528.  Whereas on our NIS client, the UID is 1000.  The UIDs of username do not match and they must be changed so that they do. Plus, the group called username, which is local to our troublesome NIS client must be deleted as well.  Otherwise, the local group (username) will be used instead of the appropriate group that is provided by our NIS server.

Before we start making changes to important files, let's back them up first.  Just in case!

sudo cp /etc/passwd /etc/passwd_BACKUP
sudo cp /etc/group /etc/group_BACKUP

Now, let's fix this problem. 
  1. sudo vim /etc/passwd [Personally, I like to use vim.  However, you can user whatever text editor your like.]
  2. Locate the line for the username in question.  In this case, it's username.
  3. Edit the UID of username so that it matches the UID of username from our NIS server.  In this case, the UID of 1000 should be changed to 34528.
  4. Save and exit your text editor. 
  5. Back at the command line, edit /etc/group:  sudo vim /etc/group
  6. Locate the line for the username group.  It should look like this:  username:x:1000:
  7. Delete this line.
  8. Save and exit your text editor.
  9. Reboot your NIS client:   sudo shutdown -r now
Once you have rebooted your NIS client, log into it.  To verify that our changes fixed the problem, check if you're currently in your home directory by running pwd at the command line.  Next, run ls -l.  Your files in your home directory should no longer be apart of the old username group.

Thursday, December 19, 2013

Update the locate database in OS X Mavericks (10.9)

Greetings, weary tech[no] traveler!

A great command to help find files via the Unix command line is "locate".  Not only is it simple to use:

locate <name of file>   (without the '<' and '>' characters)

but it is quick to return results too.

To do this, the "locate" command relies on a local database to index and, furthermore, return results to you quickly.  Therefore, this local database needs to be updated periodically.

Unlike most other Unix based operating systems, simply running "updatedb" in the OS X (10.9 mavericks) terminal won't work.  So how do we update the locate database for OS X Mavericks (OS 10.9)?  Like this:

1.  Launch terminal

2.  Change your user session to root:
     sudo su -  (then type your password)

3.  Go to the directory /usr/libexec/
     cd /usr/libexec/

4.  Run the following command to update the locate database:
     ./locate.updatedb

After a minute (or 5) your locate database will be updated, and you can continue to use your command line.

It should be noted that this will only work for those who have sudo privileges to their machine.  For good practice, remember to log out of root when you're done (by typing 'exit' at the command line).

FIRST POST!!~1! I mean...Welcome, wastland traveler!

Greetings, weary tech[no] traveler!

If you're reading this, chances are you've come across a tech problem in your travels throughout the techno wasteland, and you need help solving it.  Or perhaps, you're just interested in reading my first post ever.  Anyway....

This blog will be a survival guide dedicated to technological problems I have encountered and solved.  Here, you will find a growing collection of recipes and 'how-to' solutions related to DJing technologies,  coding (creative or otherwise), system administration (OS X, Linux, Windows, etc.), and various tips and tricks.


Like yourself, I've often turned to the internet to see if others have encountered the same problems, and if they have found solutions to those problems.  I believe it's finally time for me to give back to the technology and DJing community, via this blog.  I mean...survival guide.  :)

Feel free to leave (constructive) comments on these posts.  Perhaps your comment will correct an error in the post(s) and help someone else in the process.  That's part of what this blog is all about; helping each other out!

I hope you will find this blog useful and enjoyable to read.