LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 10-10-2005, 01:27 PM   #1
twb2005
LQ Newbie
 
Registered: Oct 2005
Posts: 9

Rep: Reputation: 0
groups and users


I am new to linux. I am trying to get a display of all the users that have been created as well as groups. This is being done at the terminal.I believe the folder is etc/group. Any help would be great Thanks
TWB
 
Old 10-10-2005, 01:34 PM   #2
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
Code:
#cat /etc/passwd
#cat /etc/group
 
Old 10-10-2005, 01:41 PM   #3
twb2005
LQ Newbie
 
Registered: Oct 2005
Posts: 9

Original Poster
Rep: Reputation: 0
groups and users

This gives me a file that has a extreme amount of data. I am looking to just display the users and groups. In this case I have about 5 users and 2 groups. Thanks
 
Old 10-10-2005, 05:13 PM   #4
init100
LQ Newbie
 
Registered: Oct 2005
Location: Europe
Distribution: Fedora Core 4
Posts: 20

Rep: Reputation: 0
You can always use the head and tail commands to limit the number of lines that are displayed. These commands display the first and last 10 rows of /etc/passwd and /etc/groups respectively:
Code:
# head -10 /etc/passwd
# tail -10 /etc/passwd
# head -10 /etc/group
# tail -10 /etc/group
In Fedora Core 4, which I am using, there is a GUI application under

Desktop->System Settings->Users and Groups

that probably does what you want. It displays (and allows you to edit) the ordinary users and groups on the system, without showing the various system users and groups.
 
Old 10-10-2005, 05:35 PM   #5
twb2005
LQ Newbie
 
Registered: Oct 2005
Posts: 9

Original Poster
Rep: Reputation: 0
groups and users

Thanks init100
The reason Im using the terminal is just to familiarize myself with the command line. I tried your command, however my problem is that when I open this file /ect/passwd or etc/group I get a lot of data that seems to be unrelated to what I am looking for. There is approx 70 or so lines, when all I really want is a list of the few or so users there is. Im trying to filter this all out so I just get a list of the users with their relevant data.
Thanks
twb2005
 
Old 10-10-2005, 05:55 PM   #6
Kristijan
Member
 
Registered: Sep 2003
Location: Melbourne, Australia
Distribution: NetBSD 3.0.1, Slackware 10.1
Posts: 394

Rep: Reputation: 30
twb2005,

You can try something like this;

Code:
awk -F: '{ print $1 }' /etc/passwd
A basic rundown on how it works.

awk bascially scans for patterns and sequences, and then handles the input accordingly.

-F: tells awk what to use as the field seperator. Take the following example of an /etc/passwd file.

Code:
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
As you can see, the field seperator in the /etc/passwd file is the semicolon (:). This is what we need to tell awk to use as a seperator.

'{ print $1 }' tells awk to print the first column (The user column).

/etc/passwd is the file we want processed by awk.

This should help get you on your way.

Regards,
-Kristijan

Last edited by Kristijan; 10-10-2005 at 06:10 PM.
 
Old 10-10-2005, 06:08 PM   #7
init100
LQ Newbie
 
Registered: Oct 2005
Location: Europe
Distribution: Fedora Core 4
Posts: 20

Rep: Reputation: 0
twb2005,

Familiarizing yourself with the command line is a very good idea, for several reasons:
  • The command line is a very powerful tool in its own right
  • Using the command line is almost necessary to take advantage of the powerful remote-login capabilities using e.g. SSH
  • Knowing the command line allows you to repair the system if your graphical display stops working
  • It allows you to administer headless (screenless) servers
 
Old 10-10-2005, 06:21 PM   #8
twb2005
LQ Newbie
 
Registered: Oct 2005
Posts: 9

Original Poster
Rep: Reputation: 0
groups and users

Thanks Kristijan
That looks like a good start for me, thanks for the detailed information.

Thanks init100
Thats why Im doing it. I have a remote loginin set up on a small home N/W and learning with it
 
  


Reply



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
users and groups twb2005 Linux From Scratch 2 10-10-2005 01:47 PM
users and groups twb2005 Red Hat 1 10-10-2005 01:47 PM
users, groups, and permissions mcd Linux - Newbie 3 05-26-2004 09:06 PM
users and groups Red Squirrel Linux - Newbie 2 02-22-2004 07:37 PM
users and groups krfulton Linux - Security 1 01-05-2004 03:43 AM

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

All times are GMT -5. The time now is 02:55 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
Open Source Consulting | Domain Registration