首页  

linux系统管理常用命令实战     所属分类 linux 浏览量 1221
查看所有的用户
cat /etc/passwd 


创建admin组和用户

groupadd admin 
useradd -g admin admin -m  
-m 自动建立用户的登入目录
passwd admin
输入admin密码

用户组文件 /etc/group 

第一字段:用户组名称;
第二字段:用户组密码;
第三字段:GID
第四字段:用户列表,每个用户之间用,号分割;本字段可以为空;如果字段为空表示用户组为GID的用户名;



给admin 赋予 管理员 权限
默认只读需要加写权限
-r--r-----   1 root root     3907 6月  23 2017 sudoers
chmod +w /etc/sudoers 
-rw-r-----   1 root root     3907 6月  23 2017 sudoers

增加sudo权限
vi /etc/sudoers
admin	ALL=(ALL) 	ALL

chmod -w /etc/sudoers 


如果不把admin 写入 sudoers ,则无法使用 sudo
admin 不在 sudoers 文件中。此事将被报告。



修改用户密码
passwd admin
更改用户 admin 的密码 。
新的 密码:
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。




查看系统的所有限制
 ulimit -a 


/etc/sysconfig/iptables 
文件不存在 

sudo  service iptables start 
[sudo] password for admin: 
Redirecting to /bin/systemctl start  iptables.service
Failed to start iptables.service: Unit not found.

无法启动


随便写一条iptables命令配置个防火墙规则:
sudo iptables -P OUTPUT ACCEPT
保存iptables修改

sudo service iptables save

The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

sudo yum install iptables-services



sudo cat /etc/sysconfig/iptables

启用禁用防火墙自动启动
sudo systemctl enable iptables
sudo systemctl disable iptables
启动关闭防火墙
sudo systemctl start iptables
sudo systemctl stop iptables

sudo service iptables start
sudo service iptables stop

查看防火墙状态
service iptables status

查看所有服务列表 
systemctl list-unit-files


开启防火墙之后导致网站无法访问 先关掉


id # Display the user and group ids of your current user. 
last # Display the last users who have logged onto the system. 
who # Show who is logged into the system. 
w # Show who is logged in and what they are doing.

 who
admin    pts/0        2018-09-04 15:48 (183.129.232.234)
root     pts/1        2018-09-04 15:40 (183.129.232.234)

[admin@VM_0_16_centos ~]$ last
admin    pts/0        183.129.232.234  Tue Sep  4 15:48   still logged in   
root     pts/1        183.129.232.234  Tue Sep  4 15:40   still logged in   
root     pts/0        183.129.232.234  Tue Sep  4 13:19 - 15:47  (02:28)    
root     pts/0        183.129.232.234  Tue Sep  4 09:49 - 12:23  (02:34)    
root     pts/0        123.157.153.130  Mon Sep  3 18:05 - 20:17  (02:12)  

id 
uid=1001(admin) gid=1001(admin) 组=1001(admin)

id centos
uid=1000(centos) gid=1000(centos) 组=1000(centos),4(adm),10(wheel),190(systemd-journal)

上一篇     下一篇
Linux查找命令使用及其区别

分布式id生成方案

linux常用命令实战

jdk代理与cglib代理的区别

几个经济学段子

linux性能监控常用命令