登录式shell的执行顺序及简单应用

登录shell:用户登录linux主机时取得的shell。

非登录shell:用户登录linux主机后(取得了登录shell)由于需要启动执行的shell,如:用su切换用户后取得的shell;在登录shell中。

这两者在配置文件的执行顺序有着很大区别:

   1、 登录shell配置文件执行顺序
          /etc/profile-->/etc/profile.d/*.sh-->~/.bash_profile-->~/.bashrc-->/etc/.bashrc
   2、非登录shell配置文件执行顺序
        ~/.bashrc-->/etc/.bashrc-->/etc/profile.d/*.sh


再来看看简单应用:ls 和 ls -ahl是两个很常用的命令,如果你长期敲ls -ahl 会不会烦呢,可以把敲ls 变为 敲 ls -ahl 一样的效果

appledeMacBook-Pro:~ apple$ alias ls='ls -ahl'
appledeMacBook-Pro:~ apple$ ls
total 148848
drwxr-xr-x+  51 apple  staff   1.7K  3 30 14:56 .
drwxr-xr-x    6 root   admin   204B 11 19 14:44 ..
-r--------    1 apple  staff     9B 11 18 17:09 .CFUserTextEncoding
-rw-r--r--@   1 apple  staff    14K  3 31 17:35 .DS_Store
写在/.bashrc上可以永久生效,

appledeMacBook-Pro:~ apple$ vim ~/.bashrc
alias ls='ls -ahl'

appledeMacBook-Pro:~ apple$ source ~/.bashrc  
appledeMacBook-Pro:~ apple$ ls
total 148856
drwxr-xr-x+  51 apple  staff   1.7K  3 31 22:12 .
drwxr-xr-x    6 root   admin   204B 11 19 14:44 ..
-r--------    1 apple  staff     9B 11 18 17:09 .CFUserTextEncoding
-rw-r--r--@   1 apple  staff    14K  3 31 17:35 .DS_Store

其中 

source ~/.bashrc 使环境变量生效

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值