Number of home directories in children of /
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have to count the number of children directories of / that contain one or more home directories.
For instance, if john, emily and rick have their home directories in /home/john , /home/emily and /var/lib, the answer would be 2.
I assume I have to use a pipe with cut and grep, but I do not know exactly how.
grep directory pipe home
New contributor
add a comment |Â
up vote
0
down vote
favorite
I have to count the number of children directories of / that contain one or more home directories.
For instance, if john, emily and rick have their home directories in /home/john , /home/emily and /var/lib, the answer would be 2.
I assume I have to use a pipe with cut and grep, but I do not know exactly how.
grep directory pipe home
New contributor
I don't understand how /var/lib is different from /home/john or /home/emily in this regard. None of them are direct children of/
; two of them contain/home
, if that's what you're checking...?
â Jeff Schaller
40 mins ago
Is the algorithm that "/home" contains two homedirs and /var contains one, so there are two unique top-level directories that contain home directories?
â Jeff Schaller
39 mins ago
Are the paths to test predetermined or are you reading them from the/etc/passwd
file? And would 3 the answer to this list:/home/john , /home/emily , /varlib , /home/sally/Documents/Earth , /var/www
?
â RubberStamp
29 mins ago
1
You only need to find out where the home directory is set which you can get fromgetent passwd | awk - F : 'print $6'
. It is most likely/home
for everyone unless it's been set as a different location for some of the users. Assuming that it is, you can usefind /home -maxdepth 1 -type d | awk 'END print $NR'
and that will give you the total number. You can swap out/home
if it's elsewhere.
â Nasir Riley
28 mins ago
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have to count the number of children directories of / that contain one or more home directories.
For instance, if john, emily and rick have their home directories in /home/john , /home/emily and /var/lib, the answer would be 2.
I assume I have to use a pipe with cut and grep, but I do not know exactly how.
grep directory pipe home
New contributor
I have to count the number of children directories of / that contain one or more home directories.
For instance, if john, emily and rick have their home directories in /home/john , /home/emily and /var/lib, the answer would be 2.
I assume I have to use a pipe with cut and grep, but I do not know exactly how.
grep directory pipe home
grep directory pipe home
New contributor
New contributor
New contributor
asked 43 mins ago
Teodora Argintaru
1
1
New contributor
New contributor
I don't understand how /var/lib is different from /home/john or /home/emily in this regard. None of them are direct children of/
; two of them contain/home
, if that's what you're checking...?
â Jeff Schaller
40 mins ago
Is the algorithm that "/home" contains two homedirs and /var contains one, so there are two unique top-level directories that contain home directories?
â Jeff Schaller
39 mins ago
Are the paths to test predetermined or are you reading them from the/etc/passwd
file? And would 3 the answer to this list:/home/john , /home/emily , /varlib , /home/sally/Documents/Earth , /var/www
?
â RubberStamp
29 mins ago
1
You only need to find out where the home directory is set which you can get fromgetent passwd | awk - F : 'print $6'
. It is most likely/home
for everyone unless it's been set as a different location for some of the users. Assuming that it is, you can usefind /home -maxdepth 1 -type d | awk 'END print $NR'
and that will give you the total number. You can swap out/home
if it's elsewhere.
â Nasir Riley
28 mins ago
add a comment |Â
I don't understand how /var/lib is different from /home/john or /home/emily in this regard. None of them are direct children of/
; two of them contain/home
, if that's what you're checking...?
â Jeff Schaller
40 mins ago
Is the algorithm that "/home" contains two homedirs and /var contains one, so there are two unique top-level directories that contain home directories?
â Jeff Schaller
39 mins ago
Are the paths to test predetermined or are you reading them from the/etc/passwd
file? And would 3 the answer to this list:/home/john , /home/emily , /varlib , /home/sally/Documents/Earth , /var/www
?
â RubberStamp
29 mins ago
1
You only need to find out where the home directory is set which you can get fromgetent passwd | awk - F : 'print $6'
. It is most likely/home
for everyone unless it's been set as a different location for some of the users. Assuming that it is, you can usefind /home -maxdepth 1 -type d | awk 'END print $NR'
and that will give you the total number. You can swap out/home
if it's elsewhere.
â Nasir Riley
28 mins ago
I don't understand how /var/lib is different from /home/john or /home/emily in this regard. None of them are direct children of
/
; two of them contain /home
, if that's what you're checking...?â Jeff Schaller
40 mins ago
I don't understand how /var/lib is different from /home/john or /home/emily in this regard. None of them are direct children of
/
; two of them contain /home
, if that's what you're checking...?â Jeff Schaller
40 mins ago
Is the algorithm that "/home" contains two homedirs and /var contains one, so there are two unique top-level directories that contain home directories?
â Jeff Schaller
39 mins ago
Is the algorithm that "/home" contains two homedirs and /var contains one, so there are two unique top-level directories that contain home directories?
â Jeff Schaller
39 mins ago
Are the paths to test predetermined or are you reading them from the
/etc/passwd
file? And would 3 the answer to this list: /home/john , /home/emily , /varlib , /home/sally/Documents/Earth , /var/www
?â RubberStamp
29 mins ago
Are the paths to test predetermined or are you reading them from the
/etc/passwd
file? And would 3 the answer to this list: /home/john , /home/emily , /varlib , /home/sally/Documents/Earth , /var/www
?â RubberStamp
29 mins ago
1
1
You only need to find out where the home directory is set which you can get from
getent passwd | awk - F : 'print $6'
. It is most likely /home
for everyone unless it's been set as a different location for some of the users. Assuming that it is, you can use find /home -maxdepth 1 -type d | awk 'END print $NR'
and that will give you the total number. You can swap out /home
if it's elsewhere.â Nasir Riley
28 mins ago
You only need to find out where the home directory is set which you can get from
getent passwd | awk - F : 'print $6'
. It is most likely /home
for everyone unless it's been set as a different location for some of the users. Assuming that it is, you can use find /home -maxdepth 1 -type d | awk 'END print $NR'
and that will give you the total number. You can swap out /home
if it's elsewhere.â Nasir Riley
28 mins ago
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
(export LC_ALL=C
getent passwd | cut -d: -f6 | sort -t/ -uk2,2 | grep -c ..)
Counts the number of unique second components of user's home directories.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
(export LC_ALL=C
getent passwd | cut -d: -f6 | sort -t/ -uk2,2 | grep -c ..)
Counts the number of unique second components of user's home directories.
add a comment |Â
up vote
0
down vote
(export LC_ALL=C
getent passwd | cut -d: -f6 | sort -t/ -uk2,2 | grep -c ..)
Counts the number of unique second components of user's home directories.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
(export LC_ALL=C
getent passwd | cut -d: -f6 | sort -t/ -uk2,2 | grep -c ..)
Counts the number of unique second components of user's home directories.
(export LC_ALL=C
getent passwd | cut -d: -f6 | sort -t/ -uk2,2 | grep -c ..)
Counts the number of unique second components of user's home directories.
answered 27 mins ago
Stéphane Chazelas
292k54543883
292k54543883
add a comment |Â
add a comment |Â
Teodora Argintaru is a new contributor. Be nice, and check out our Code of Conduct.
Teodora Argintaru is a new contributor. Be nice, and check out our Code of Conduct.
Teodora Argintaru is a new contributor. Be nice, and check out our Code of Conduct.
Teodora Argintaru is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f480447%2fnumber-of-home-directories-in-children-of%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
I don't understand how /var/lib is different from /home/john or /home/emily in this regard. None of them are direct children of
/
; two of them contain/home
, if that's what you're checking...?â Jeff Schaller
40 mins ago
Is the algorithm that "/home" contains two homedirs and /var contains one, so there are two unique top-level directories that contain home directories?
â Jeff Schaller
39 mins ago
Are the paths to test predetermined or are you reading them from the
/etc/passwd
file? And would 3 the answer to this list:/home/john , /home/emily , /varlib , /home/sally/Documents/Earth , /var/www
?â RubberStamp
29 mins ago
1
You only need to find out where the home directory is set which you can get from
getent passwd | awk - F : 'print $6'
. It is most likely/home
for everyone unless it's been set as a different location for some of the users. Assuming that it is, you can usefind /home -maxdepth 1 -type d | awk 'END print $NR'
and that will give you the total number. You can swap out/home
if it's elsewhere.â Nasir Riley
28 mins ago