启动文件rc.local、/etc/bash.bashrc、~/bashrc、/etc/profile、~/.profile【转载from joyride】值得
来源:互联网 发布:c语言二维数组定义 编辑:程序博客网 时间:2024/05/07 14:04
系统启动文件
1. /etc/rc.local
系统启动需要加载的守护进程(服务)和执行的程序。该文件只有一条“exit 0”语句,用户可加入自己的启动程序,但需要保证最后的返回是0。如下:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
#启动SSHD
/usr/sbin/sshd
#启动Telnet
service openbsd-inetd start
#启动WEB服务器lighttpd
cd /home/usr948/lighttpd-1.4.19/usr/bin
./lighttpd -f ./lighttpd.conf
#启动xdm,xmanager需要使用它来进行远程登录到桌面。
/usr/bin/xdm
exit 0
注意,该文件中不能加入用户shell下的脚本,例如加入 alias ll="ls -l" 无效,因为该文件的执行环境是在系统shell下,系统尚未进入用户shell环境。原来我一直搞不懂为什么加入上面的alias语句无效,该问题我在www.linuxsir.org/bbs 里发帖得到达人指点如下:
要 加入启动脚本,可修改 /etc/bash.bashrc 或 ~/bashrc 或 /etc/profile 或 ~/.profile。将文件中的语句“ # alias ll='ls -l' ”中的“#”号去掉即可。关于ubuntu的bash启动文件从网上查到下面资料:
转自http://hi.baidu.com/afantihome/blog/item/21ca5edda40b02df8c102957.html
bash的几个初始化文件 - [Ubuntu]
(1)/etc/profile
全局(公有)配置,不管是哪个用户,登录时都会读取该文件。
(2)/ect/bashrc
Ubuntu没有此文件,与之对应的是/ect/bash.bashrc
它也是全局(公有)的
bash执行时,不管是何种方式,都会读取此文件。
(3)~/.profile
若bash是以login方式执行时,读取~/.bash_profile,若它不存在,则读取~/.bash_login,若前两者不存在,读取~/.profile。
另外,图形模式登录时,此文件将被读取,即使存在~/.bash_profile和~/.bash_login。
(4)~/.bash_login
若bash是以login方式执行时,读取~/.bash_profile,若它不存在,则读取~/.bash_login,若前两者不存在,读取~/.profile。
(5)~/.bash_profile
Unbutu默认没有此文件,可新建。
只有bash是以login形式执行时,才会读取此文件。通常该配置文件还会配置成去读取~/.bashrc。
(6)~/.bashrc
当bash是以non-login形式执行时,读取此文件。若是以login形式执行,则不会读取此文件。
(7)~/.bash_logout
注销时,且是longin形式,此文件才会读取。也就是说,在文本模式注销时,此文件会被读取,图形模式注销时,此文件不会被读取。
下面是在本机的几个例子:
1. 图形模式登录时,顺序读取:/etc/profile和~/.profile
2. 图形模式登录后,打开终端时,顺序读取:/etc/bash.bashrc和~/.bashrc
3. 文本模式登录时,顺序读取:/etc/bash.bashrc,/etc/profile和~/.bash_profile
4. 从其它用户su到该用户,则分两种情况:
(1)如果带-l参数(或-参数,--login参数),如:su -l username,则bash是lonin的,它将顺序读取以下配置文件:/etc/bash.bashrc,/etc/profile和~ /.bash_profile。
(2)如果没有带-l参数,则bash是non-login的,它将顺序读取:/etc/bash.bashrc和~/.bashrc
5. 注销时,或退出su登录的用户,如果是longin方式,那么bash会读取:~/.bash_logout
6. 执行自定义的shell文件时,若使用“bash -l a.sh”的方式,则bash会读取行:/etc/profile和~/.bash_profile,若使用其它方式,如:bash a.sh, ./a.sh,sh a.sh(这个不属于bash shell),则不会读取上面的任何文件。
7. 上面的例子凡是读取到~/.bash_profile的,若该文件不存在,则读取~/.bash_login,若前两者不存在,读取~/.profile。
- 启动文件rc.local、/etc/bash.bashrc、~/bashrc、/etc/profile、~/.profile【转载from joyride】值得了解
- 启动文件rc.local、/etc/bash.bashrc、~/bashrc、/etc/profile、~/.profile【转载from joyride】值得了解
- 启动文件rc.local、/etc/bash.bashrc、~/bashrc、/etc/profile、~/.profile【转载from joyride】值得
- Linux 配置文件 启动文件rc.local、/etc/bash.bashrc、~/bashrc、/etc/profile、~/.profile加载顺序
- /etc/rc.d/rc.local 与 /etc/profile .bash_profile .bashrc 文件执行顺序
- 关于ubuntu9.04启动文件rc.local、/etc/bash.bashrc、~/bashrc、/etc/profi...
- 关于Debian中的/etc/.profile, /etc/bash.bashrc, ~/.bashrc, ~/.profile,
- Linux中的~/.profile,~/.bashrc,/etc/profile,/etc/bash.bashrc
- /etc/bash.bashrc、/etc/profile、终端 设置
- Bash初始化文件/etc/profile .bash_pro-file .bash_login .profile .bash_logout /etc/bashrc .bashrc
- 详解/etc/profile、/etc/bash.bahsrc、~/.profile、~/.bashrc的用途
- 详解/etc/profile、/etc/bash.bahsrc、~/.profile、~/.bashrc的用途
- .bashrc和/etc/profile
- /etc/profile ~/.bashrc区别
- 关于bash启动脚本/etc/profile /etc/bashrc ~/.bash_profile ~/.bashrc的区别
- /etc/bashrc和/etc/profile
- shell的初始化文件:/etc/profile和/etc /bashrc(bash.bashrc)
- shell的初始化文件:/etc/profile和/etc/bashrc(bash.bashrc)
- VirtualBox 文件(.vdi)修改UUID
- NYOJ 35 表达式求值
- Java成员变量的一些特点
- Leetcode Reverse String
- XXX事件
- 启动文件rc.local、/etc/bash.bashrc、~/bashrc、/etc/profile、~/.profile【转载from joyride】值得
- spring mvc 框架简易示例
- Unity3D之与根据动态的两个轨迹点绘制面详解
- 欢迎使用CSDN-markdown编辑器
- Python修饰器的函数式编程
- 微擎之一元夺宝之随机生成兑奖码并插入数据库
- 资料分享
- sso cas4.0改造历程--分布式部署实现
- poj1611The Suspects