LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-19-2012, 06:53 PM   #1
onyxneeds
LQ Newbie
 
Registered: Mar 2012
Posts: 3

Rep: Reputation: Disabled
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
 
Old 03-19-2012, 07:12 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
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

Last edited by chrism01; 03-19-2012 at 07:13 PM.
 
1 members found this post helpful.
Old 03-19-2012, 07:30 PM   #3
onyxneeds
LQ Newbie
 
Registered: Mar 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Unhappy

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.
 
Old 03-19-2012, 08:31 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
/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
 
Old 03-19-2012, 08:38 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
Definitely try
Code:
cat /etc/passwd
Maybe that will help clarify what Tinkster & I are saying
 
Old 03-19-2012, 08:44 PM   #6
onyxneeds
LQ Newbie
 
Registered: Mar 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks guys that helps alot i appreciate your help

Take Care
onyx
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a bash script that verifies an existing directory? AB1826 Linux - Newbie 11 12-13-2011 10:49 AM
Script to add a secondary group to all users except system default users Tekken Linux - Server 5 06-29-2009 05:02 PM
Writing a script to kill users logged in twice scrizo Programming 7 10-10-2007 01:01 PM
writing a script to perform a function on each users mail folder jhill Linux - Newbie 2 08-24-2004 08:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration