HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

entering 3000 lines in vi editor

 
SOLVED
Go to solution
Vishu
Trusted Contributor

entering 3000 lines in vi editor

Hi guys,

i have to add 3000 users in a group as a secondary group. when i am doing vi and try to save the file after entering these users against their group. it gives an error:-

line too long

Please help on this as how can i enter my users in the group file.
9 REPLIES
James R. Ferguson
Acclaimed Contributor
Solution

Re: entering 3000 lines in vi editor

Hi:

This must be an early (< 11.0) release.

You have reached 'vi' limits or for that matter the system's LINE_MAX.

There is nothing to prevent you from declaring the same group multiple times with differing lists of users where the whole line remains in limits.

Regards!

...JRF...
OldSchool
Honored Contributor

Re: entering 3000 lines in vi editor

Vishu
Trusted Contributor

Re: entering 3000 lines in vi editor

well, actually i have to update those users in NIS groups. i tried that also by creating multiple groups, but when i update the NIS maps, it takes only one group and leave others.

and when i do with one group and all users, it gives "Line too long" error.

i am able to enter groups by having same GID, but different groupname...but it does not solve my purpose.

Any parameter, command or environment variable, i have to edit to do this.

Please suggest..

Hein van den Heuvel
Honored Contributor

Re: entering 3000 lines in vi editor

You don't actually like to enter 3000+ users using 'vi' do you? That's nasty!

So why don't you do something convenient for yourself, like EXCEL or a VI for shorter lines and then use a tool like AWK or PERL or a script to glue it together. We have computers to help no?!

If you used a convention of potentially repeated group name in column 1 followed by a list of user then you could use something like:

$ cat tmp.txt
aap one two three
aap een twee drie
noot four
mies five six seven
mies vijf zes zeven
mies cinque six sept

$ perl -ne 'chomp; m/(\S+)(\s+\S.*)/;if ($1 ne $x) {print qq($x $y\n) if $x; $x=$1; $y=$2}
.=$2}; print "$x $y$2" if eof' tmp.txt

aap one two three een twee drie
noot four
mies five six seven vijf zes zeven cinque six sept cinque six sept

BYu can use any format you like.
Like "--- name" to start a fresh group, and the users 'naked' on the next lines.

But where do those names come from? Surely from some computer output? How about using that form input?

hth.
Hein.
Suraj K Sankari
Honored Contributor

Re: entering 3000 lines in vi editor

Hi,

If you are not able to open your passwd file into vi then do one think ftp your passwd file into your desktop open in excel and add secondry group save as the file as suppose npasswd.csv
now open your npasswd.csv file into a notepad find and replace all , with ; and save it

put again into /tmp/npasswd.csb
make a cp of your passwd file
cp /etc/passwd /etc/passwd.today's date
then mv /tmp/npasswd.csv /etc/passwd

Suraj

Re: entering 3000 lines in vi editor

>entering 3000 character lines in vi editor

You can use vim instead.
OldSchool
Honored Contributor

Re: entering 3000 lines in vi editor

"You can use vim instead."

you could, but, IIRC, you still run into issues with the max length of a line in the group file itself.
Atul Ram Sahu
Occasional Advisor

Re: entering 3000 lines in vi editor

try vipw command , its exclusively for passwd file
Suraj K Sankari
Honored Contributor

Re: entering 3000 lines in vi editor

HI Atul,
>>try vipw command , its exclusively for passwd file

insted of giving vi /etc/passwd, vipw is for edit /etc/passwd into vi editor no need to give /etc/passwd again.

just give vipw it will open your /etc/passwd file.


Suraj