Questions tagged [etcpasswd]
35 questions
82
votes
12 answers
Safely change home directory
I'm trying to safely update the home directory as specified in /etc/passwd,
but the standard Linux utils - usermod and vipw - for doing so aren't provided
by Cygwin.
Could anyone tell me how they changed this in Cygwin?

sblundy
- 60,628
- 22
- 121
- 123
9
votes
1 answer
How can you run a GIT container as the current user?
I want to use GIT from within a Docker container. The usage as documented on https://hub.docker.com/r/alpine/git/ is quite simple:
docker run -it --rm -v ${HOME}:/root -v $(pwd):/git alpine/git clone ...
This works. One big downside of this is…
user8870331
5
votes
2 answers
Can not add new user in docker container with mounted /etc/passwd and /etc/shadow
Example of the problem:
docker run -ti -v my_passwd:/etc/passwd -v my_shadow:/etc/shadow --rm centos
[root@681a5489f3b0 /]# useradd test # does not work !?
useradd: failure while writing changes to /etc/passwd
[root@681a5489f3b0 /]# ll /etc/passwd…

Nemanja Trifunovic
- 3,017
- 1
- 17
- 20
4
votes
2 answers
How do I get user and group information in Perl on Windows?
Perl has several built-in functions for accessing /etc/passwd on Unix systems (and elsewhere when supported) for user and group information. For instance,
my $name = getpwuid($uid);
will return the user name given the user ID, or undef if there is…
Ville Koskinen
2
votes
0 answers
Check password using awk on /etc/shadow running as root on Linux
I am on an embedded linux box where I am the root user. I have set a password which is present in /etc/shadow file.
Now running as root user and using the following logic in a shell script, I am able to check if a password is set or not.
if [ `awk…

AdeleGoldberg
- 1,289
- 3
- 12
- 28
2
votes
2 answers
Getting length of single string in two-dimensional dynamic allocated array of strings
I'm trying to find all groups to which user belongs in my UNIX system, and that for each user.Implementation has to be in C. Here is my code:
#include
#include
#include
#include
#include…

mk1024
- 119
- 3
2
votes
3 answers
How do I extract the biggest UID value from /etc/passwd?
I want to predict the next UID before creating a new user.
Since the new one will take the biggest ID value yet and adds 1 to it, I thought of the following script:
biggestID=0
cat /etc/passwd | while read line
do
if test [$(echo $line | cut -d:…

engineering student
- 233
- 1
- 3
- 14
2
votes
0 answers
How can I assign a group description, and other group information, in linux
QUESTION: /etc/password has a comment field for the users, which is great because it allows a comma separated list of variables that can be used for other purposes. /etc/group does not, so where can I store a group description and additional…

gunslingor
- 1,358
- 12
- 34
2
votes
1 answer
Where & How is user group information stored in Ubuntu?
Mirror Question: https://unix.stackexchange.com/questions/217300/where-how-is-user-group-information-stored-in-ubuntu. (I'll remove one of them after I got the answer)
Two places possible: /etc/group and /etc/passwd.
If I use command: adduser…

songyy
- 4,323
- 6
- 41
- 63
2
votes
2 answers
See who is currently logged in and get their information from /etc/passwd
I wanted to be able to see who is currently logged in into the server and then search /etc/passwd file based on their username and find their ID (column3) and full name (column5) and display them together.
For example:
$ who
USER …

endri
- 57
- 6
2
votes
3 answers
How do I delete users that have uid 0?
I am supposed to clear all users that have the ID of 0 other than root. For example, my passwd file contains a user root with ID 0 and a user homer with ID 0.
I tried something like
grep :x:0: passwd | grep -v root:x: | awk -F : '{ print $1 }' |…

k.schroeder31
- 801
- 2
- 8
- 15
1
vote
1 answer
vulnerability check on Ubuntu 18.04 Bash Shell Script
MY Code
vuln=0 # initialize FLAG variable
test -f /etc/shadow # Check exist /etc/shadow
if [ $? == 1 ]
then
vuln=1 # Not exist /etc/shadow File -> FLAG ON
else
cat /etc/passwd | while read pass_protection # Read 1 Line
do
…

lkrr
- 15
- 5
1
vote
0 answers
Postgresqll 10: Postgres User /sbin/nologin preventing initdb setup
I'm attempting to install postgresql 10 for the first time and need to run the initdb setup. Unfortunately, this fails and returns an error from the nologin shell.
server# /usr/pgsql-10/bin/postgresql-10-setup initdb
Initializing database ...…

Ryan Fisher
- 35
- 6
1
vote
1 answer
How to read awk from one file and compare it with awk from another file
The script I have is outputting $1 the most often logged users in the past $2 days
#var[$i]=$(awk -F: '{print $5}' /etc/passwd);
last -s -$2days | awk '{users[$1]++} END{for(i in users){print users[i], i}}' | sort -r | head -$1 | awk '{print $2 " --…

Flamenco
- 71
- 1
- 7
1
vote
2 answers
Bash Script - get User Name given UID
How - given USER ID as parameter, find out what is his name? The problem is to write a Bash script, and somehow use etc/passwd file.

PaulW
- 29
- 1
- 6