You could simply echo (with elevated privileges, of course) directly to the /etc/sudoers file:
nickw444@laptop ~ $ sudo -i
nickw444@laptop ~ $ echo 'nickw444 ALL=(ALL:ALL) ALL' >> /etc/sudoers
(note the tab character between the username and the first ALL)
Or, for a script:
#!/bin/bash
sudo echo 'nickw444 ALL=(ALL:ALL) ALL' >> /etc/sudoers
Then save to somefile.sh and run ./somefile.sh from a terminal window.
To add multiple users, change the script to this;
#!/bin/bash
while [[ -n $1 ]]; do
sudo echo "$1 ALL=(ALL:ALL) ALL" >> /etc/sudoers;
shift # shift all parameters;
done
Then, run the script like this (assuming you saved it as addsudousers.sh):
nickw444@laptop ~ $ sudo ./addsudousers.sh username1 username2 somenewadmin bob
that is, space-separated.
To read the names from a file:
nickw444@laptop ~ $ sudo ./addsudusers.sh `cat listofusers.txt`
listofusers.txt should also be space-separated.
分享到:
相关推荐
描述 "A tutorial on adding columns to Explorer’s details view via a column handler shell extension." 提到,这个教程是通过使用列处理程序外壳扩展来实现这一功能的。外壳扩展是Windows系统中的一种机制,它...
"Adding Classifications to Web Services"这个过程涉及到将Web服务在SAP NetWeaver Developer Studio中进行分类,以符合SAP的分类系统。 分类(Classifications)的主要目的是让Web服务在服务注册表(Services ...
标题中的"A class for adding icons to the system tray"指的是在计算机操作系统中,特别是在Windows环境下,创建一个能够将图标显示在任务栏系统托盘区域的程序或类。系统托盘区域是位于任务栏右下角的区域,通常...
标题“Taking the pain out of adding a horizontal scrollbar to a listbox”指向的就是这样一个问题:如何优雅地为列表框添加水平滚动条,以提升用户体验。这里我们将详细探讨这个主题,并提供一些实践技巧。 ...
"A pure Python library for adding tables to a Tkinter application" 指的是一款专门用于在 Tkinter 应用程序中添加表格功能的库。这个库为 Tkinter 提供了强大的数据展示和交互能力,使得开发者可以方便地构建...
Adding feature flags to hide features from users 196 Implementing Socialite to allow users to login with Facebook 201 Adding custom middleware to protect user admin area 206 Using Laravel to set up a ...
Adding Password Management to Your Templates(cloudstack)
在IT领域,尤其是在软件开发中,"Adding filters to the Open File dialog"是一个常见的需求,它涉及到用户界面(UI)的设计和用户体验(UX)优化。Open File dialog是大多数应用程序中的一个基本组件,允许用户选择...
这篇教程“Adding Security to Spring Petclinic”旨在帮助开发者了解如何将安全特性整合到 Spring Petclinic 示例应用中。Spring Petclinic 是一个基于 Spring Boot 开发的开源项目,它展示了 Spring 框架的各种...
ActiveX Script脚本组件 The ActiveX Script Components is a small collection of native Delphi VCL components that are designed to make adding scripting to your programs as easy as possible.
Adding white noise to a signal with fixed SNR
It starts off by building a basic IMDB clone and adding users who can register, vote on their favorite movies, and upload associated pictures. You will learn how to use the votes that your users have...
The shell is a fundamental tool in Linux, allowing users to interact with the operating system through commands. This chapter teaches readers how to: - **Understanding the Command Line**: Basic ...
在MATLAB编程环境中,我们经常会绘制各种数据图表来可视化我们的研究成果。然而,这些图表往往显得过于正式和标准化,缺乏个性和趣味性。"XKCDIFY!" 是一个针对MATLAB的创新工具,它能为你的Matlab图表添加一种类似...
信息安全_数据安全_Adding Social Intelligence to Smart Devices 应急响应 内外威胁 工控安全 web安全 数据脱敏
Administrators can manage users, including adding users, deleting users, modifying users, etc. the system can be transplanted to any developed LabVIEW software, with strong practicability.)
USB4 1.0工程变更通知(Engineering Change Notice,ECN)主要涉及的是在特定情况下关闭RS-FEC(Reed-Solomon Forward Error Correction)编码的功能。RS-FEC是一种用于纠正数据传输过程中可能出现错误的编码技术,...
Matlab+YALMIP+CPLEX解决带储能的微电网优化调度问题,以微电网运行成本最小为目标函数,能量设备包含风电、光伏以及蓄电池,同时考虑到电价和与电网的交互,约束条件包含蓄电池SOC约束、交换功率约束、功率平衡等...