Industry guru Dave Taylor offers tech support on technical and business topics, including iPhone, iPod, Microsoft Windows, Sony PSP, cellphones, online advertising, CSS, Web design, business, Unix, Linux, SEO, Mac OS X, and shell script programming.     


Getting the "adduser" script to work on Linux

A reader writes:
" Hi, I'm a very beginner at shell scripting and unix/linux. I have your book (Wicked Cool Shell Scripts) and it is really great. So far I've done two or three, Inpath is the one i use most. I'm going make a user for an ftp account so my friends can upload/download songs and other files. I decided to use your adduser script for the job but when i run the script i get an erorr like - /etc/passwd : permission denied. How do i give the script permission to write to /etc/passwd? Sorry if this is an obvious question but i couldn't find an answer. I used chmod 755 and ran it as root. By the way, i really like the site and book cover, i wish all linux/programming manuals had really cool covers."

Dave's Answer:
First off, thanks for the kind words!

In terms of your problem, I would want to see the permissions of both the file /etc/passwd, and, since it needs to add information to it too, /etc/shadow too.

If you're running as root, theoretically, all should be well, but Linux isn't 100% predictable, so...

Please respond with that information as a comment to this thread and we'll continue to debug your problem!


Related Shell Script Programming articles:
✔   Secretly capture screenshots on my Mac?
When I used to work on a Linux system, there was a utility we had that would let me take screen captures every...
✔   Parsing "id" strings in a Shell Script?
Hello Dave. I need a Bash shell script that creates a directories with the group names automatically when user logs in to the...
✔   Copy and Paste from the Mac OS X Command Line?
I am constantly running commands in Terminal.app on my MacBook and then copying and pasting the results into email messages or documents. Yes,...
✔   Script to test line lengths for Twitter compatibility?
I've been tasked with writing a series of tweets for a Black Friday marketing campaign and am finding it a bit tricky because...
✔   Shell script to convert lowercase to title case?
As part of a project I'm working on, I find myself deep in a Linux shell script, needing to have a subroutine that...

Let's stay in touch!
Sign up for my weekly AskDaveTaylor Newsletter and you'll receive even more tech and gadget help right to your inbox, along with exclusive news and industry updates. It's good stuff. I promise!
    Enter your name: and your email addr:  









Reader Comments To Date: 4

v said, on November 26, 2005 10:10 AM:

how to find root password using shell script?

Dave Taylor said, on November 26, 2005 2:38 PM:

Well, gosh, hmmm... if you want to learn how to hack into a Linux system, I think you've come to the wrong place. :-)

joey said, on July 24, 2008 5:27 AM:

I have the same error:


-rw-r--r-- 1 root root 1117 Jul 24 11:32 shadow
-rw-r--r-- 1 root root 1616 Jul 24 11:31 passwd

Vinit said, on September 3, 2008 3:24 PM:

Hi i wanted to know how will i write a post installation script in a kickstart file in linux to changes a few words in the inittab file for example "kernel" to kerne!" and also the grub.conf and the fstab entries as well. coz i want to create an automated troubleshooting situations for myself

Starbucks coffee cup I do have a lot to say, and questions of my own for that matter, but first I'd like to say thank you, Dave, for all your helpful information by buying you a cup of coffee!

I do have a comment, now that you mention it!











I will never send you any unsolicited email. Ever.






Check This Out Too...

 
Look for Answers
Need Help? Ask Dave Taylor!


Follow Me on Pinterest

Find Me on Google+
ADT on G+
© 2002 - 2013 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site. Further, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site. My lawyer says "Thanks".
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.