1. 增加用户ssh登录
adduser test
passwd test
vim
/etc/ssh/sshd_config
# 最后加入以下命令,同时允许新用户和root,一起ssh登录PermitRootLogin yes #注释发开
AllowUsers root test
#重启sshd
systemctl restart sshd
#赋予新用户权限
$chmod-vu+w/etc/sudoers(增加 sudoers 文件的写的权限,默认为只读)
$vi/etc/sudoers(修改 sudoers)
-------------------------------------------------------
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
sss ALL=(ALL) ALL (添加这一行)
-------------------------------------------------------
$chmod-vu-w/etc/sudoers(删除 sudoers 的写的权限)
#新用户登录后,操作需要加入sudo,之后输入下新用户的密码即可
2. 监控服务器所有用户操作:
转自linux下用户操作记录审计环境的部署记录 - 散尽浮华 - 博客园
把下面内容添加到/etc/profile文件底部
vim /etc/profile
........
#设置history格式
exportHISTTIMEFORMAT="[%Y-%m-%d %H:%M:%S] [`whoam i 2>/dev/null| \
awk'{print $NF}'|sed-e's/[()]//g'`] "
#登录时清空当前缓存
echo""> .bash_history
#记录shell执行的每一条命令
exportPROMPT_COMMAND='\
if[ -z"$OLD_PWD"];then
exportOLD_PWD=$PWD;
fi;
if[ ! -z"$LAST_CMD"] && ["$(history 1)"!="$LAST_CMD"];then
logger -t `whoami`_shell_cmd"[$OLD_PWD]$(history 1)";
fi;
exportLAST_CMD="$(history 1)";
exportOLD_PWD=$PWD;'
source /etc/profile
测试:
分别使用kevin,grace账号登陆这台服务器进行一些操作。
然后发现/var/log/message日志文件中已经记录了这两个用户的各自操作了~
tail -20 /var/log/messages
Oct 24 14:16:04 elk-node2 root_shell_cmd: [/root] 321 [2016-10-24 14:16:04] [gateway] tail -100 /var/log/messages
Oct 24 14:19:09 elk-node2 root_shell_cmd: [/root] 322 [2016-10-24 14:18:51] [gateway] vim /etc/profile
3. vim
/[pattern]:搜索 n:下一个匹配的搜索项
v:进入virsual block 模式!可以批量选中
批量注释:v和hjkl批量选中,ctrl+v 列选中,I并输入'//' 两次ESC
:%s/a/b/g 在文件中用b替换所有的a
yy:复制当行
nyy: 复制n行
p: 粘贴
#vim命令模式下 显示当前目录的所有文件
:Explore #当前窗口下打开
:Vexplore #竖直分割窗口打开
:Sexplore #水平分割窗口打开#vim . 打开当前目录所有文件
:vsp 1.txt 水平分屏打开1.txt
:ctrl + w + h/l 水平切换屏幕
#切换到1.txt所在的分屏
:n 2.txt
:n 1.txt 两个屏幕就可以完成多个文件的切换
4. 重做系统
做好U盘启动之后,进入bios选择u盘启动项。进入安装页面之后,选择镜像。

Tab按下之后,将最下方改成:vmlinuz initrd=initrd.img linux dd quiet 寻找出镜像盘。一般为sdb4.
重启之后,继续上步。将最下方文字改成:
vmlinuz initrd=initrd.img inst.stage2=hd:/dev/sdb4 quiet
等待进入图形安装界面。
5. httpd配置多应用
<VirtualHost *:80>
addDefaultCharset gbk
DocumentRoot /home/sites/xsx_tp
<Directory "/home/sites/weizhi_tp">
Options FollowSymLinks
AllowOverride ALL
Require all granted
</Directory>
DirectoryIndex index.html index.php
ServerName 192.168.1.110
ServerAlias 192.168.1.110
</VirtualHost>
Listen 8080
<VirtualHost *:8080>
addDefaultCharset gbk
DocumentRoot /home/sites/wordpress
<Directory "/home/sites/wordpress">
Options FollowSymLinks
AllowOverride ALL
Require all granted
</Directory>
DirectoryIndex index.html index.php
ServerName 192.168.1.110
ServerAlias 192.168.1.110
</VirtualHost>
本文介绍了如何在Linux系统中增加SSH登录用户、监控用户操作以及进行系统重做。首先,通过编辑`/etc/ssh/sshd_config`启用SSH登录,并设置sudo权限。接着,通过修改`/etc/profile`来记录用户的shell命令历史,实现用户操作审计。此外,还展示了在Apache服务器上配置多应用的方法,通过`VirtualHost`指令设置不同端口的网站。最后,简要提及了制作U盘启动和系统安装过程。
1756

被折叠的 条评论
为什么被折叠?



