LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   I am writing a script that checks or verifies users on an Ubuntu system (https://www.linuxquestions.org/questions/linux-newbie-8/i-am-writing-a-script-that-checks-or-verifies-users-on-an-ubuntu-system-935364/)

onyxneeds 03-19-2012 05:53 PM

I am writing a script that checks or verifies users on an Ubuntu system
 
Can someone please help ? I need to write or creat a script in bash that checks a users existance and then backs up the users home directories.
I am using Ubuntu 10.10.ver 4 and i'm brand new to linux.
Any help would be appreciated
Thanks in advance,
onyxneeds

chrism01 03-19-2012 06:12 PM

Well, what do you mean by a user's existence?
If a user acct exists, it's in /etc/passwd, a plain text file.
The user's name is the first field, the unique id ( 'uid' ) is the 3rd field of each record.
What kind of backup did you have in mind?
There's no (need to) chk; it's either there or its not..
Usually home for a user is

/home/username/

For a newbie, read & digest http://rute.2038bug.com/index.html.gz to start with.
For more bash cmds http://tldp.org/LDP/Bash-Beginners-G...tml/index.html http://www.tldp.org/LDP/abs/html/

HTH & Welcome to LQ :)

onyxneeds 03-19-2012 06:30 PM

Thanks for the information and sorry for the mis-communication.
My first intent was to write a shell script that by putting in a username would first check to see if that user exist and if it does exist backs up that users /home/username using the tar command
I'm confused: I know of the /etc/passwd command but i'm not sure how to incorporate that into the script.

Tinkster 03-19-2012 07:31 PM

/etc/passwd is not a command, it's a text file.

It holds a list of colon-separated values; the user name is in the first
column, the sixth column holds the users home.


Does that help?



Cheers,
Tink

chrism01 03-19-2012 07:38 PM

Definitely try
Code:

cat /etc/passwd
Maybe that will help clarify what Tinkster & I are saying :)

onyxneeds 03-19-2012 07:44 PM

Thanks guys that helps alot i appreciate your help

Take Care
onyx


All times are GMT -5. The time now is 06:57 AM.