file-max与ulimit的关系与差别
2015-08-25 17:01
369 查看
先說好,跟往常一樣.. 到我Pixnet的網誌看會比較不頭痛:P
版本1可以不用寫群組名稱,但是程式碼好醜ˊˋ
版本2必須要有群組名稱,適用於學校(?)
版本1下載
版本2下載
版本1:
#!/usr/bin/env ruby
File.open(ARGV[0]) do |file|
while a = file.gets
a = a.chomp.split(/ /)
print "username => #{a[0]} ", "password => #{a[1]} ", "group => #{a[2]}", "\n"
a[2].nil? ? `useradd -m #{a[0]}` : `useradd -m -G #{a[2]} #{a[0]}`
`echo #{a[0]}:#{a[1]} | chpasswd`
end
end
exec "pwconv"
使用者清單寫法:
帳號 密碼 群組
版本2:
#!/usr/bin/env ruby
require 'yaml'
YAML.load_file(ARGV[0]).each{ |grp|
grp.each{ |usr|
usr.each{ |i|
info = i.chomp.split(/ /)
`useradd -m -G #{grp[0]} #{info[0]}`
`echo #{info[0]}:#{info[1]} | chpasswd`
}
}
}
`pwconv`
使用者清單寫法:
grp1:
- usr1 pwd1
- usr2 pwd2
grp2:
- usr3 pwd3
- usr4 pwd4
grp3:
- usr5 pwd5
- usr6 pwd6使用方式都是:
./account list
程式授權.. 隨便啦
版本1可以不用寫群組名稱,但是程式碼好醜ˊˋ
版本2必須要有群組名稱,適用於學校(?)
版本1下載
版本2下載
版本1:
#!/usr/bin/env ruby
File.open(ARGV[0]) do |file|
while a = file.gets
a = a.chomp.split(/ /)
print "username => #{a[0]} ", "password => #{a[1]} ", "group => #{a[2]}", "\n"
a[2].nil? ? `useradd -m #{a[0]}` : `useradd -m -G #{a[2]} #{a[0]}`
`echo #{a[0]}:#{a[1]} | chpasswd`
end
end
exec "pwconv"
使用者清單寫法:
帳號 密碼 群組
版本2:
#!/usr/bin/env ruby
require 'yaml'
YAML.load_file(ARGV[0]).each{ |grp|
grp.each{ |usr|
usr.each{ |i|
info = i.chomp.split(/ /)
`useradd -m -G #{grp[0]} #{info[0]}`
`echo #{info[0]}:#{info[1]} | chpasswd`
}
}
}
`pwconv`
使用者清單寫法:
grp1:
- usr1 pwd1
- usr2 pwd2
grp2:
- usr3 pwd3
- usr4 pwd4
grp3:
- usr5 pwd5
- usr6 pwd6使用方式都是:
./account list
程式授權.. 隨便啦
相关文章推荐
- POSIX多线程程序设计(第7章:Real code)
- ASP.Net视频总结
- C++中类对象所占空间的大小
- Excel VBA编程的常用代码(备用待查)
- java socket编程学习笔记
- 华为OJ 名字的漂亮度
- 论文提要“Fast Feature Pyramids for Object Detection”
- Android Studio NDK 学习之接受Java传入的Int数组
- 观察者——对象行为模式
- 排序算法(七)希尔排序
- Kth Smallest Element in a BST
- CocoaAsyncSocket 文档2:常见陷阱
- (leetcode)Search for a Range
- java生成UUID通用唯一识别码 (Universally Unique Identifier)
- [scrapy] scrapy 使用goose作为正文提取
- 权限表设计
- Unity中英文字长度
- UIButton文字居左显示
- POSIX多线程程序设计(第6章:POSIX针对线程的调整)
- if doesn't support the "condition"attribute 问题解决