I need to list users in /etc/passwd with root's GID or UID or /root as home directory
If we have these entries in /etc/passwd
The sed/awk operation should list out only badusers, as they hold either, roots UID or GID or /root as home directory.
So, The UID & GID for the root account are both zero. The fields are separated by : so you can:
Does that give you a starter? Have a look at the cut manual page if you need to slice up the output to give you just the names.
Thank you, but it should not list
root:x:0:0:root:/root:/bin/bash
and also, should list
baduser3:x:500:500:root:root:/bin/bash
as baduser3 has home directory set as /root
You said you want to use sed or awk, cut (as suggested by rbatte1) is another possibility. I would guess that awk will be better for this job than sed.
You've been watching what we have been doing here for more than 1.5 years.
Can you show us how to use awk (or grep and cut) to get the UID, GID, and home directory for root out of /etc/passwd?
Once you have those values, can you show us how to use awk or cut to find other users with the same UID as root, the same GID as root, or the same home directory as root?
Show us that you have made an attempt to solve this problem by showing us what you have tried so far. Tell us what is working and what you can't get to work yet.
Operation ---------- Post updated at 07:14 AM ---------- Previous update was at 07:00 AM ----------
Quote:
Originally Posted by Don Cragun
You've been watching what we have been doing here for more than 1.5 years.
Can you show us how to use awk (or grep and cut) to get the UID, GID, and home directory for root out of /etc/passwd?
Operation ---------- Post updated at 07:14 AM ---------- Previous update was at 07:00 AM ----------
I have attempted.
With cut
Good. You're learning how to use the tools.
Note that your output doesn't include the login names of the users whose entries are failing your tests. You might want to add that to your output.
If you'd like to get root's UID, GID, and login directory from the password file instead of assuming that they will be 0, 0, and /root, respectively, (and you're willing to live with the limitation that root's information must appear on the 1st line in the passwd file), you could consider something like:
which produces the output:
Note also that baduser3's login directory (root) is not identical to root's login directory (/root), so I'm not sure if that line should be included in your output or not. (However, all login directories in /etc/passwd should have absolute pathnames. Should you add a check to verify that each user's login directory starts with a /?)
If you don't want to print the entire line from the passwd file for lines that fail your tests, you've already shown that you know how to print just the fields you want.
I would like to get an opinion for my solution for this task and get feedback about better approach or mistakes I have made.
1. The problem statement, all variables and given/known data:
The task is to create a script which prints information about users whose names are specified in the... (2 Replies)
Hi all
I have a strange problem on one my my AIX machines. We have created a user called testroot with the same UID as root (uid=0) by changing the uid of that user in the /etc/passwd file. I know that this is a security breach but this is a test system.
Now the strange thing that happens is that... (3 Replies)
Hi Unix Gurus .
I have requirement where in which - I would like create duplicate root equivalent account with all the privileges equal to root. Is it possible to create this duplicate account with different UID. ?
this id i would like give it to my teams - who does multiple activities using... (2 Replies)
Hi All
After downloading ZFS documentation from oracle site, I am able to successfully migrate UFS root FS without zones to ZFS root FS. But in case of UFS root file system with zones , I am successfully able to migrate global zone to zfs root file system but zone are still in UFS root file... (2 Replies)
Present
/home/dsadm# id dsadm
uid=0(root) gid=0(root)
----------------------------------
needs to be
/home/dsadm> id dsadm
uid=23186(dsadm) gid=16284(gdstage)
Please provide the command/steps for the above uid, gid value change
Thanks in advance for all your support .
... (3 Replies)
> id root
0(root) 1(other)
From CIS scanning result"it should make sure the root's gid is equal to 0", so I don't know what's the impact for that change to whole system? BTW, why is there a group named other under solaris? what does group "other" do ?
Thanks very much! (3 Replies)
Hi, yesterday, I changed root's shell in /etc/passwd, cause a mistake then I can not log in root account (can't find correct shell). I attempted to log in single-mode, however, it prompted for single-mode's password then I type root's password but still can not log in.
I'm using AIX 5L version 5.2... (2 Replies)
Hi,
I have a program with the following suid setup
-rwsr-sr-x 1 root other 653 Aug 16 17:00 restart_server
It basically starts up a service that has to be started by root. I just want the normal users to be able to restart the service using the script above.
But when the... (7 Replies)
All,
I want to run a non-root script as the root user with non-root environment variables with crontab. The non-root user would have environment variables for database access such as Oracle or Sybase. The root user does not have the Oracle or Sybase enviroment variables. I thought you could do... (2 Replies)