shell编程实现用户管理系统?shell编程100例
- 数据库
- 2023-08-13
- 94

各位老铁们,大家好,今天由我来为大家分享shell编程实现用户管理系统,以及shell编程100例的相关问题知识,希望对大家有所帮助。如果可以帮助到大家,还望关注收藏下...
各位老铁们,大家好,今天由我来为大家分享shell编程实现用户管理系统,以及shell编程100例的相关问题知识,希望对大家有所帮助。如果可以帮助到大家,还望关注收藏下本站,您的支持是我们最大的动力,谢谢大家了哈,下面我们开始吧!
windowspowershell怎么运行代码
WindowsPowerShell运行代码的方法非常简单。使用WindowsPowerShell可以轻松运行代码。使用WindowsPowerShell可以运行各种类型的脚本,包括Python、JavaScript和C#等。要运行代码,请首先打开WindowsPowerShell,然后输入代码文件的路径并按Enter键。除了运行代码,您还可以使用WindowsPowerShell执行各种系统管理任务,包括但不限于安装软件程序、查看系统信息和管理文件和文件夹等。作为一名程序员或系统管理员,了解和掌握这个工具可以提高工作效率和工作质量。
shell是编程语言吗
shell不是编程语言,而是一种编程的方法。
shell是操作系统的最外层。shell合并编程语言以控制进程和文件,以及启动和控制其它程序。shell通过提示您输入,向操作系统解释该输入,然后处理来自操作系统的任何结果输出来管理您与操作系统之间的交互。
shell提供了与操作系统通信的方式。此通信以交互的方式(来自键盘的输入立即操作)或作为一个shell脚本执行。shell脚本是shell和操作系统命令的序列,它存储在文件中。
linux中sh命令用法
sh是Linux中的一种Shell,通过它可以执行命令行操作、写Shell脚本,用于实现系统管理和自动化任务。sh命令的基本用法是:sh[选项][脚本文件],其中选项可以是-e、-x、-v等,分别表示:
-e:在脚本中遇到错误时立即退出;
-x:显示执行的每条命令;
-v:显示脚本中每一行。
在学习shell,要不要转python编程呢这两个专业的前景怎么样
shell是Linux运维的时候必须的一种语言,我在工作中经常用到,python在平时一些小工具,选择学习Shell或者Python这两个编程语言之前,需要先考虑自己的学习目标、需求和兴趣。Shell适合于处理管道、重定向、文件操作等系统级别的任务,而Python则更为通用,可以用来编写各种类型的应用程序、网站和算法等。
对于这两种编程语言的前景,从已有的就业市场情况看,Python的需求量正在逐渐上升,成为了最受欢迎的编程语言之一,而Shell编程虽然在系统管理领域有一定的优势,但是并不是一个很广泛使用的编程语言。所以,在职业发展方面,如果想要进入互联网行业,学习Python可能更为有利。
如何在linux上用命令实现用户和组的管理
Linux上用命令实现本地用户和组的管理
本地用户和组:管理文件和进程等等
本地用户和组:
1)root:超级管理员系统创建的第一个账户
特点:
id为:0
家目录:/root
具有系统的完全控制权:小心使用。
[root@servera~]#id
uid=0(root)gid=0(root)groups=0(root)context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[root@servera~]#
2)普通用户:不具有管理员权限
特点:
id范围:
1000<=id<=60000
家目录:/home/用户名
[root@servera~]#idstudent
uid=1000(student)gid=1000(student)groups=1000(student),10(wheel)
[root@servera~]#
3)服务用户:为服务提供权限
特点:
id范围:
0<id<1000
家目录:应用程序服务目录
[root@servera~]#idapache
uid=48(apache)gid=48(apache)groups=48(apache)
[root@servera~]#
如果是yum,rpm安装的软件:由rpm包中的脚本创建服务账户
Includeconf.modules.d/*.conf
#
#Ifyouwishhttpdtorunasadifferentuserorgroup,youmustrun
#httpdasrootinitiallyanditwillswitch.
#
#User/Group:Thename(or#number)oftheuser/grouptorunhttpdas.
#Itisusuallygoodpracticetocreateadedicateduserandgroupfor
#runninghttpd,aswithmostsystemservices.
#
Userapache
Groupapache
#'Main'serverconfiguration
#
本地组:
1)主组:一个用户一定要属于某个主组中。当些用户在创建文件时,给文件的归属组
2)从属组:用户容器,组织和管理用户权限管控
作用:
文件:
进程:
[student@servera~]$ps-ux
USERPID%CPU%MEMVSZRSSTTYSTATSTARTTIMECOMMAND
student321780.00.4930529360?Ss15:000:00/usr/lib/system
student321820.00.32537767072?S15:000:00(sd-pam)
student321880.00.21594124980?S15:000:00sshd:student@p
student321890.00.22339124864pts/0Ss15:000:00-bash
student322930.30.21594085192?D15:430:00sshd:student@p
student322940.30.22339124924pts/1Ss15:430:00-bash
student323190.50.22339404804pts/1S15:430:00/bin/bash
student323410.00.22693123876pts/1R+15:430:00ps-ux
[student@servera~]$
账户文件:
1)/etc/passwd:保存用户信息
[root@serveratmp]#cat/etc/passwd|grepstudent
student:x:1000:1000:StudentUser:/home/student:/bin/bash
用户名密码uid主组ID描述家目录登录shell
[root@serveratmp]#
[root@serveratmp]#cat/etc/passwd|grep-wroot:x
root:x:0:0:root:/root:/bin/bash
[root@serveratmp]#
[root@serveratmp]#cat/etc/passwd|grepapache
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
服务账号无法登录系统
[root@serveratmp]#
2./etc/shadow:保存用户密码的HASH,密码的有效性信息,密码修改时间,账户有效期。
[root@serveratmp]#
[root@serveratmp]#ls-l/etc/shadow
----------.1rootroot1014Mar2911:39/etc/shadow
[root@serveratmp]#
[root@serveratmp]#
[root@serveratmp]#cat/etc/shadow|grepstudent
student:$6$8oIjLCsc$/n1iQXYh1E6.uOEuJKgioqAtmqm2TQmkJGF2RwyteIr1tIfrPdiRYgWe6Sjen5/eMij2uHM/a1tue/QRlo3X80:18038:0:99999:7:::
[root@serveratmp]#
密码的HASH:sha512
8oIjLCsc$/n1iQXYh1E6.uOEuJKgioqAtmqm2TQmkJGF2RwyteIr1tIfrPdiRYgWe6Sjen5/eMij2uHM/a1tue/QRlo3X80
18038:天数密码最后一次修改的时间从1970-01-01+18038天之后那一天
0:密码最少使用天数0没有限制用户随时可以改密码
99999:天数,密码最大修改时间永久200多年
7:warning警告时间,当密码快到最后修改时间前7天,通知用户修改。
::天数失效时间inactive用户密码过了最后修改时间,未改变密码,再过多少天,账户将被锁定
::账户有效期
创建用户和组:
创建时,没有密码:
[root@servera~]#useraddzhangsan
[root@servera~]#useraddlisi
[root@servera~]#idzhangsan
uid=1001(zhangsan)gid=1001(zhangsan)groups=1001(zhangsan)
[root@servera~]#idlisi
uid=1002(lisi)gid=1002(lisi)groups=1002(lisi)
[root@servera~]#
无法登录:与PAM有关
[student@servera~]$
[student@servera~]$su-zhangsan
Password:
Password:
su:Authenticationfailure
[student@servera~]$
设置密码:
[root@servera~]#
[root@servera~]#cat/etc/passwd|grepzhangsan
zhangsan:x:1001:1001::/home/zhangsan:/bin/bash
[root@servera~]#cat/etc/shadow|grepzhangsan
zhangsan:!!:18350:0:99999:7:::#!!未设置密码
[root@servera~]#
[root@servera~]#passwdzhangsan
Changingpasswordforuserzhangsan.
Newpassword:
BADPASSWORD:Thepasswordisshorterthan8characters
Retypenewpassword:
passwd:allauthenticationtokensupdatedsuccessfully.
[root@servera~]#
[root@servera~]#
[root@servera~]#cat/etc/shadow|grepzhangsan
zhangsan:$6$3wxuXomVbQ58wQcK$oQW6injgldxa2N/Pt4tCPDVRqWRVGw.UNZdxE4R0nhEt8K/3UDKzxap6ReIReEvDpG.GdwjpMiiDh7.f6DJNQ0:18350:0:99999:7:::
[root@servera~]#
chage可以查看用户密码属性
[root@servera~]#chage-lzhangsan
Lastpasswordchange:Mar29,2020
Passwordexpires:never
Passwordinactive:never
Accountexpires:never
Minimumnumberofdaysbetweenpasswordchange:0
Maximumnumberofdaysbetweenpasswordchange:99999
Numberofdaysofwarningbeforepasswordexpires:7
[root@servera~]#
创建组:从属组
[root@servera~]#
[root@servera~]#groupaddit
[root@servera~]#
[root@servera~]#
[root@servera~]#groupaddsales
[root@servera~]#
[root@servera~]#
[root@servera~]#
[root@servera~]#cat/etc/group
root:x:0:
bin:x:1:
daemon:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
disk:x:6:
lp:x:7:
mem:x:8:
kmem:x:9:
wheel:x:10:student
cdrom:x:11:
mail:x:12:postfix
man:x:15:
dialout:x:18:
floppy:x:19:
games:x:20:
tape:x:33:
video:x:39:
ftp:x:50:
lock:x:54:
audio:x:63:
users:x:100:
nobody:x:65534:
dbus:x:81:
utmp:x:22:
utempter:x:35:
input:x:999:
kvm:x:36:
render:x:998:
systemd-journal:x:190:
systemd-coredump:x:997:
systemd-resolve:x:193:
tss:x:59:
polkitd:x:996:
rpc:x:32:
unbound:x:995:
ssh_keys:x:994:
sssd:x:993:
setroubleshoot:x:992:
rpcuser:x:29:
insights:x:991:
cockpit-ws:x:990:
sshd:x:74:
chrony:x:989:
tcpdump:x:72:
student:x:1000:
printadmin:x:988:
libstoragemgmt:x:987:
slocate:x:21:
postdrop:x:90:
postfix:x:89:
apache:x:48:
zhangsan:x:1001:
lisi:x:1002:
it:x:1003:组成员列表
sales:x:1004:
[root@servera~]#
[root@servera~]#idstudent
uid=1000(student)gid=1000(student)groups=1000(student),10(wheel)
[root@servera~]#
将用户添加进组:zhangsan,加入it组,lisi,sales组
[root@servera~]#idstudent
uid=1000(student)gid=1000(student)groups=1000(student),10(wheel)
[root@servera~]#usermod-aGitzhangsan
[root@servera~]#
[root@servera~]#
[root@servera~]#usermod-aGsaleslisi
[root@servera~]#
[root@servera~]#
[root@servera~]#idzhangsan
uid=1001(zhangsan)gid=1001(zhangsan)groups=1001(zhangsan),1003(it)
[root@servera~]#idlisi
uid=1002(lisi)gid=1002(lisi)groups=1002(lisi),1004(sales)
[root@servera~]#
删除用户:
[root@servera~]#useraddandy
默认删除,保留用户的文件:
[root@servera~]#
[root@servera~]#userdelandy
[root@servera~]#
[root@servera~]#
[root@servera~]#useraddandy#重建andy会不一样,uid会不同
useradd:warning:thehomedirectoryalreadyexists.
Notcopyinganyfilefromskeldirectoryintoit.
Creatingmailboxfile:Fileexists
[root@servera~]#
[root@servera~]#useradduser1
[root@servera~]#useradduser2
[root@servera~]#idandy
uid=1003(andy)gid=1005(andy)groups=1005(andy)
[root@servera~]#userdel-rany
userdel:user'any'doesnotexist
[root@servera~]#
[root@servera~]#userdel-randy#不保留用户的文件。家目,邮箱文件,skel文件都会
[root@servera~]#
[root@servera~]#
[root@servera~]#idandy
id:‘andy’:nosuchuser
[root@servera~]#useraddandy
[root@servera~]#idandy
uid=1006(andy)gid=1008(andy)groups=1008(andy)
[root@servera~]#
从组中移除用户:
[root@servera~]#
[root@servera~]#idzhangsan
uid=1001(zhangsan)gid=1001(zhangsan)groups=1001(zhangsan),1003(it)#zhangsan主组,it从属组
[root@servera~]#
命令:
[root@servera~]#gpasswd-dzhangsanit
Removinguserzhangsanfromgroupit
[root@servera~]#
[root@servera~]#
[root@servera~]#idzhangsan
uid=1001(zhangsan)gid=1001(zhangsan)groups=1001(zhangsan)
[root@servera~]#
[root@servera~]#
[root@servera~]#usermod-aGitzhangsan
[root@servera~]#
[root@servera~]#
[root@servera~]#idzhangsan
uid=1001(zhangsan)gid=1001(zhangsan)groups=1001(zhangsan),1003(it)
[root@servera~]#
[root@servera~]#
[root@servera~]#
[root@servera~]#groupszhangsan
zhangsan:zhangsanit
[root@servera~]#
直接修改文件:
[root@servera~]#vim/etc/group
[root@servera~]#cat/etc/group|grepit:
it:x:1003:
[root@servera~]#
删除组:
[root@servera~]#groupaddtest
[root@servera~]#
[root@servera~]#
[root@servera~]#groupdeltest
创建自定义用户和组:
实验:用户名mary,指定用户id2000,家目录/maryhome,不用登录系统描述thisismaryuser
[root@servera~]#
[root@servera~]#useradd-u2000-d/maryhome-s/sbin/nologin-c"thisismary"mary
[root@servera~]#
[root@servera~]#idmary
uid=2000(mary)gid=2000(mary)groups=2000(mary)
[root@servera~]#cat/etc/passwd|grepmary
mary:x:2000:2000:thisismary:/maryhome:/sbin/nologin
[root@servera~]#
[root@servera~]#su-mary
Lastlogin:SunMar2916:48:49CST2020onpts/0
Thisaccountiscurrentlynotavailable.
[root@servera~]#
创建自定义组:指定组id
[root@servera~]#groupadd-g3000group1
[root@servera~]#cat/etc/group|grepgroup1
group1:x:3000:
[root@servera~]#
在南方CASS软件中"shell"程序是什么意思
shell的中文意思即是“壳”,它管理着用户和操作系统之间的交互,可以把他理解成一个命令解释器。
它接收用户命令,然后调用相关的应用程序来执行。
文章分享结束,shell编程实现用户管理系统和shell编程100例的答案你都知道了吗?欢迎再次光临本站哦!
本文链接:http://www.xinin56.com/su/3158.html