Creating a New User

Creating a user in Linux is a simple task. Well, kinda. You can quickly create a user without specifying much of it’s characteristics, or you can get much more in depth with security, default shells and other customizations. I recommend taking the time to learn beyond the basics or you may find yourself making a simple mistake. For the longest time I created my user’s with a command like this:

sudo useradd -d /home/username -m username
sudo passwd username

I had thought for a long time this was sufficient. It created their home directory with the -m parameter and specified that location with the -d parameter. After that I set the password and the user was now able to login to the system with basic privileges. But after a while I began to notice some quirks with those users. They didn’t act like the initial admin user that was created by the installation process.  I found that the prompt was a bit less informative.  It also lacked a history, and the ability to hit tab to complete a directory as you typed it.  I even found myself copying over the root .bashrc and trying to figure out what ws different between the users.  Then I typed in the following command just to make sure it was using bash:

echo $SHELL

I looked at the response.

/bin/sh

*face-palm*

No wonder .bashrc didn’t do anything, I was using a completely different shell for my subsequent users.  I had never taken the time to learn the difference between the various shells, most systems use bash by default so that is what I learned and got used to.  So I never even realized they were using sh instead of bash.

To quickly change the shell for an established user to bash just run the command:

chsh -s /bin/bash username

Since then I’ve adjusted my create user command to include bash as my default shell.

sudo useradd -d /home/username -m username -s /bin/bash

There are many more parameters that you can add on to this command. If you’d like to read up on those then just type man useradd and read through the documentation.  Or if you want a very verbose and easy to use command to create your users you can always try adduser.  Instead of passing in which parameters you want to specify it will prompt you on every possibility.  Great for if you don’t know which options exist, but also somewhat overwhelming in the beginning.

mradmin@microsoft$ sudo adduser username
Password: ******
Adding user `username’…
Adding new group `username’ (1337).
Adding new user `username’ (1337) with group `username’.
Creating home directory `/home/username’.
Copying files from `/etc/skel’
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for username
Enter the new value, or press ENTER for the default
Full Name []: Example User
Room Number []: 0
Work Phone []: 604-6122
Home Phone []: 604-6222
Other []:
Is the information correct? [y/N] 

The choice of which two methods to use is a mater of preference. In the long run, what matters is that you educate yourself on what all of the available options do. And remember, man useradd and man adduser are your friends!

Tags: , , , , , , , , , , , , , ,

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS
read comments

Top Ten Web Design Pet Peeves

There’s some trends on the Internet that just wont die. I swear sometimes I don’t even know what decade it is when I click on a link and find an archaic HTML 3.2 driven site layered with frames and animated gifs. But what is even more disturbing is when you stagger into a site that was written only weeks ago and it looks like something you made in Grade 9 on your Packard Bell desktop.
Every day I find my way on to some terribly produced site that makes me gag. Here’s a short list of web design mistakes that drive me up the wall:

10 – JavaScript Links

This one isn’t always noticeable, when you use the website the way the designer expected you to use it.  What they did not expect was for you to ctrl+click or middle click a link to open it in a new tab. Perhaps you just wanted to copy the URL so you can send it to a friend?  Unfortunately far too many developers leave off the href attribute when they use an onClick, or they needlessly make their links use JavaScript in order to do something silly like open it as a popup.

9 – Denying Right Click

I can’t help but laugh every time I see this one.  Almost all browsers these days override the developer’s attempt to stop you from right clicking.  Instead what happens is they get an alert saying its not allowed at the same time as the right click menu.  If you are that worried about me stealing your image, there are better ways to stop it.  Trying to deny right clicks just annoys the user, and provides them no benefit.

8 – Under Construction
Under Construction

Virtually every website is under construction, they continue to evolve and add content.  Putting an Under Construction header (or worse, an animated gif of some stick men construction workers) on your site is like putting a Caution – Hot sticker on a stove.  What makes this problem even worse is when you eventually abandon your website, because you got bored of it or ran out of clip art, it will permanently bear this Under Construction warning until the end of time.

7 – Splitting Content

I appreciate the fact that you might be trying to break up the article to make it seem less intimidating to read, but you can solve that issue by just adding some white space.  I can handle more than three paragraphs at a time.  We all know the real reason you broke your single page article into six pages was just so you could get more ad impressions.  But guess what, when I got the “continued on page 2″ link I just closed the page.

6 – All Flash Websites

You’re a graphic designer, not a web designer.  Stop trying to be both.  Not only is the noise and “flashiness” of your website annoying, but it’s extremely hard to navigate your site.  How am I supposed to know that if I hover my mouse over bird another the link to the gallery will appear.  To make matters worse, once I find the section I need I can’t even bookmark it because your whole page exists as one URL.  So each time I come here I have to watch your long and useless intro, then stumble through your horrible menu system.

5 – Splash Pages

Wow, you know Photoshop or Flash.  I’m not impressed.  In fact, I’m annoyed because I just had to perform yet another click to get to the content of your page.  To make matters worse, you tried to be creative with your placement of the enter button and I can’t find it on your splash page at all.

4 – Resizing the Window

I like my window the size it is.  If its maximized, it’s because I wanted it maximized.  If it’s only taking up half my screen, it’s most likely because I needed the other half for something else.  Yes, your crappy flash page was meant to be viewed at 800×600, but I will resize it myself if I need to.

3 – Videos that Auto Play

Chances are that I have no interest in the videos you’ve put on your site.  If I wanted to find a video I would have searched on Youtube or a similar engine.  Your video may be relavent and useful to me, but please give me the option to start it when I’m ready.  I often open many tabs at once and don’t get to them for some time.  Having to click on each one, scroll through pages of posts and try and find the source of the talking I hear, and then stopping it is really annoying.  What’s even more annoying is when you have 10 videos on your main page that all start playing at once — seriously, what made you think that would be a good idea?

2 – Music

Even more annoying than videos is background music.  We all have very different tastes in music, I probably don’t like what you like.  In fact, I probably hate it.  And what I’d probably hate even more is for it to scare the living crap out of me when I open your site at 3 am and have neglected to turn my speakers off.  I have never seen a website that needed background music, never.  I don’t care if it’s a website for your favourite band, it doesn’t need to auto play.  If you feel you need sound on your site, follow this one simple rules  give the user the option of if and when they’d like to hear it.

1 – Click Here…

Some of you will think it’s silly that I put this on the top of my list.  But this one is huge for me because it is a plague that has infested the majority of the Internet.  It’s become so popular and normal to see on a website that I continuously have intelligent, highly educated clients handing me text full of “click here…” links.  There is no need for this, link the title or action as you mention it, you will look far more professional if you do.

So, what are your pet peeves?

Tags: , , , , ,

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS
read comments

JavaScript – Hide or Show an Element

Just about every site I’ve designed has made use of this code block. It utilizes a combination of JavaScript, CSS and some HTML DOM knowledge to get the job done.  Most often I use this to make dynamic menus however the uses are endless.  For this example I will use it for something more simple.

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras dignissim, quam sed pellentesque eleifend, nisi erat facilisis quam, a viverra lorem arcu ut dolor. Morbi in magna mi, vel malesuada diam. Proin pulvinar ultricies aliquam. Sed tellus neque, facilisis eget sagittis eu, cursus in turpis. Phasellus vestibulum turpis nibh. Nam porta congue tellus bibendum sodales. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Duis tellus tortor, aliquet vel mattis vel, sagittis id eros. Ut lacinia lobortis volutpat. Nunc rhoncus sem eu augue mollis dapibus.<br />
<a href="javascript:;" onClick="showLayer('more_content')">Show</a></p>
<p id="more_content">
Fusce sit amet diam odio. Quisque mattis sagittis dui ut malesuada. Curabitur felis velit, varius id scelerisque a, facilisis eu felis. Cras placerat urna ut nulla vulputate quis dignissim arcu tempor. Aliquam laoreet varius sollicitudin. Pellentesque feugiat vehicula risus, ut tristique massa hendrerit ac. Nulla facilisi. Phasellus et nulla erat, sed viverra enim. Curabitur faucibus mi eget quam ultrices non hendrerit tortor consectetur. Etiam iaculis massa et mauris vulputate rhoncus. Proin dapibus mauris in dolor sagittis ut elementum purus mattis.
<br /><a href="javascript:;" onClick="hideLayer('more_content')">Hide</a>
</p>

At this point your page will render both paragraph blocks. In order to hide the second by default we have to add some CSS styling. I could have done this inline for the example however since I consider that to be bad coding practice I will create a style block for that.

p#more_content {
display: none;
}

Now your second paragraph will be hidden by default and the user will have to hit the Show link in order to expand the content. In order to make that functional you will need to add the following JavaScript code.

function hideLayer(whichLayer) {
var menuGroup;
if (document.getElementById) {
// Standard method for modern browsers
menuGroup = document.getElementById(whichLayer).style;

} else if (document.all) {
// For Old IE versions
menuGroup = document.all[whichLayer].style;

} else if (document.layers) {
// For Netscape Navigator 4
menuGroup = document.layers[whichLayer].style;
}
menuGroup.display = "none";
}

function showLayer(whichLayer) {
var menuGroup;
if (document.getElementById) {
// Standard method for modern browsers
menuGroup = document.getElementById(whichLayer).style;
} else if (document.all) {
// For Old IE versions
menuGroup = document.all[whichLayer].style;
} else if (document.layers) {
// For Netscape Navigator 4
menuGroup = document.layers[whichLayer].style;
}
menuGroup.display = "block";
}

This code block could be simplified considerably by using only the getElementById() method, however that will remove it’s backwards compatibility with older browsers. Though the percentage of users visiting with Netscape Navigator 4 or Internet Explorer 4 are extremely low, it could happen, so I have always left those extra lines in just to make sure.

You can also build on this a bit and make it one function that alternates between showing and hiding the div by changing the last line of code to menuGroup.display = menuGroup.display? “”:”block”;.

See it in action

Tags: , , ,

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS
read comments
 Page 1 of 15  1  2  3  4  5 » ...  Last »