LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-17-2006, 07:01 PM   #1
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Rep: Reputation: 30
how to list system users


how to list existing users??
i try to write a bash script to remove thumbnails from $HOME directory...
and i need a way to list users
 
Old 08-17-2006, 07:14 PM   #2
Ehwaz
Member
 
Registered: Aug 2006
Distribution: FC, Mandriva, Suse
Posts: 52

Rep: Reputation: 15
Logged in users or all users?

Logged in users would be easy, not all users. Still, you could check the /etc/shadow file and retrieve the users from there.
 
Old 08-17-2006, 07:26 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
i try to write a bash script to remove thumbnails from $HOME directory...
Why that complicated?
Code:
find /home -name ".thumbnails" -exec rm -rf {} \;
No need to hunt for names (unless some users have their home
not under home but in some strange location), in which case you
could just go
Code:
awk -F: '$3 > 99 {print $6}' /etc/passwd
to find them ...

Cheers,
Tink

Last edited by Tinkster; 08-17-2006 at 07:27 PM.
 
Old 08-17-2006, 07:34 PM   #4
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Original Poster
Rep: Reputation: 30
awk -F: '$3 > 99 {print $6}' /etc/passwd
what is "'$3 > 99" ??
 
Old 08-17-2006, 07:40 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Make sure that it only lists users that are "human". In Slackware,
all system users (not people) have a UID < 100 ... may vary for
your system, have a look at /etc/passwd. But if you DON'T have people's
in other directories than home, why bother? :) Just use the find.

Or, even more easy (just thought of that now) :}
Code:
rm -rf /home/*/.thumbnails

Cheers,
Tink
 
Old 08-17-2006, 07:46 PM   #6
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Original Poster
Rep: Reputation: 30
i like this one -
find /home -name ".thumbnails" -exec rm -rf {} \;
 
Old 08-17-2006, 08:26 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
I'm curious: why do you prefer the more I/O and CPU intense solution over
the plain one that uses shell globbing?


Cheers,
Tink
 
Old 08-17-2006, 08:31 PM   #8
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Original Poster
Rep: Reputation: 30
wanna learn commands
 
Old 08-17-2006, 08:34 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Good enough reason, I guess. And: good on yah!


Cheers,
Tink
 
Old 08-17-2006, 08:48 PM   #10
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Original Poster
Rep: Reputation: 30
i try to delete files not accessed for 7 or more days
 
Old 08-17-2006, 08:57 PM   #11
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Code:
find /home/ -atime +7 -type f -regex ".+\/.thumbnails/.+" -exec rm {} \;

Cheers,
Tink
 
Old 08-17-2006, 09:04 PM   #12
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Original Poster
Rep: Reputation: 30
+\/.thumbnails/.+" means include path??
 
Old 08-17-2006, 10:23 PM   #13
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
It's a regular expression against which all found files (including
their path) are matched; you said you only wanted to delete files which
hadn't been accessed in a week from the .thumbnail directory of any user.

What our find does is to search for all files (-type f) under /home that
have the component /.thumbnails/ in their path (.+ means one or more character)
and that have and access time of over a week (-atime +7).

It does NOT search for a path that looks like that.


Cheers,
Tink
 
Old 09-13-2006, 06:22 AM   #14
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Original Poster
Rep: Reputation: 30
combined these two
rm -rf /home/*/.thumbnails
find /home -name ".thumbnails" -exec rm -rf {} \;

find /home/*/.thumbnails -atime +7 -type f -exec rm -rf {} \;

Last edited by ygloo; 09-13-2006 at 06:26 AM.
 
  


Reply

Tags
find



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
HowTo list all users in system ALInux Linux - Newbie 27 04-17-2018 02:59 AM
How to sort regular users and system users from /etc/passwd joeyBig Red Hat 9 05-29-2008 12:59 AM
Return a list of all users in the system krystian Linux - General 6 02-01-2006 10:08 AM
command to list all users of the system?? simi_544 Linux - Networking 9 09-29-2005 03:00 AM
How to get list of system users from command line? tictocdoc Linux - General 3 03-12-2004 03:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:56 AM.

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
Open Source Consulting | Domain Registration