家目录下
1. ~/.bash_history 记录用户使用的命令
命令history 可以显示历史命令
! n (n为命令命令编号) 运行命令
! le 执行匹配开头是le的命令
! ? ls 查找执行
ctrl+r 出现提示符(reverse-i-search)`': 后输入命令,会显示匹配到的已使用命令
2. ~/.bash_logout 用户退出时执行的脚本
3. ~/.bash_profile 用户设置的一些重要信息
[lemon@localhost ~]$ cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin #设置用户使用命令的搜索路径 , :为分割符
export PATH # 将前面的环境变量输入到系统中,若不使用此命令,设置是无效的。
4. ~/.bashrc 设置一些环境变量,并指向/etc/bashrc
linux编辑一个shell脚本,
比如mytest,
[lemon@localhost ~]$ cat mytest
# !/bin/bash
echo "hello,mytest~~~"
运行方法有以下:
[lemon@localhost ~]$ bash mytest
hello,mytest~~~
[lemon@localhost ~]$ sh mytest
hello,mytest~~~
若要直接输入脚本名,或者脚本完整路径,或使用 ./ 就可运行脚本,需为脚本添加可执行权限并放到 家目录下的bin目录下
[lemon@localhost ~]$ mkdir bin
[lemon@localhost ~]$ mv mytest bin
[lemon@localhost ~]$ mytest
-bash: /home/lemon/bin/mytest: Permission denied
[lemon@localhost ~]$ ./mytest
-bash: ./mytest: No such file or directory
[lemon@localhost ~]$ cd bin
[lemon@localhost bin]$ ll
total 8
-rw-rw-r-- 1 lemon lemon 33 Oct 2 21:59 mytest
[lemon@localhost bin]$ chmod 775 mytest
[lemon@localhost bin]$ ./mytest
hello,mytest~
[lemon@localhost bin]$ mytest
hello,mytest~
使用PAM验证,可以设定只用某些用户才能使用终端切换到root
[lemon@localhost pam.d]$ vi /etc/pam.d/su
1 #%PAM-1.0
2 auth sufficient pam_rootok.so
3 # Uncomment the following line to implicitly trust users in the "wheel" grou p.
4 #auth sufficient pam_wheel.so trust use_uid
5 # Uncomment the following line to require a user to be in the "wheel" group.
#启动第6行,表示只有wheel组的用户才可以使用su 切换到root
6 #auth required pam_wheel.so use_uid
7 auth include system-auth
8 account sufficient pam_succeed_if.so uid = 0 use_uid quiet
9 account include system-auth
10 password include system-auth
11 session include system-auth
12 session optional pam_xauth.so
[root@localhost ~]# su - lemon
[lemon@localhost ~]$ su -
Password:
启动之后,就不能用非wheel组用户切换到root
[root@localhost ~]# su - lemon
[lemon@localhost ~]$ su -
Password:
su: incorrect password
解决办法,将lemon添加为wheel组用户
[root@localhost ~]# vi /etc/group
将wheel组信息修改为:
wheel:x:10:root,lemon
阅读(290) | 评论(0) | 转发(0) |