为什么rc.local里写alias ll="ls -l"无效

启动讨论 grub/grub2/syslinux/grub4dos/Lilo
回复
id_joyride
帖子: 5
注册时间: 2009-07-21 22:14

为什么rc.local里写alias ll="ls -l"无效

#1

帖子 id_joyride » 2009-08-24 0:01

我知道去掉 /etc/bash.bashrc 或 ~/bashrc 中的 语句“# alias ll='ls -l' ”的注释即可实现。 但是rc.local也是在启动时运行的,为什么加入alias ll="ls -l"语句无效?想不通,望指点。
头像
adagio
论坛版主
帖子: 22110
注册时间: 2008-02-17 23:47
来自: 美丽富饶的那啥星球

Re: 为什么rc.local里写alias ll="ls -l"无效

#2

帖子 adagio » 2009-08-24 10:02

你搞错了,如果要做全局变量的话应该写入/etc/profile
明天就换大三八!
——8核CPU、8G内存、8T硬盘……
8卡交火,80寸大屏放8个……
IPv8的光纤要8条……

---------------------------------------------------------------------------------
[图片版]新手当自强(续)FAQ
[新手进阶]挂载、fstab、调整linux分区
[图片版]E17桌面环境配置手把手
id_joyride
帖子: 5
注册时间: 2009-07-21 22:14

Re: 为什么rc.local里写alias ll="ls -l"无效

#3

帖子 id_joyride » 2009-08-24 11:12

多谢2楼的回答,当然写在/etc/profile里也可以(可参考 http://hi.baidu.com/id_joyride/blog/ite ... 7dab1.html)。

不过并没有解决我的疑问。为什么写在rc.local里不行?
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: 为什么rc.local里写alias ll="ls -l"无效

#4

帖子 eexpress » 2009-08-24 11:14

看baidu的帖子。。。这文件废弃了。老套的。去改.bashrc吧。
● 鸣学
id_joyride
帖子: 5
注册时间: 2009-07-21 22:14

Re: 为什么rc.local里写alias ll="ls -l"无效

#5

帖子 id_joyride » 2009-08-24 11:20

回4楼

不管是否过时了,应该能起作用啊!下面是我修改后的rc.local。除了红字部分开机启动无效外,其他都能起来,为什么?

#!/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

# 设定 ll 命令
alias ll='ls -l'


exit 0
id_joyride
帖子: 5
注册时间: 2009-07-21 22:14

Re: 为什么rc.local里写alias ll="ls -l"无效

#6

帖子 id_joyride » 2009-08-24 15:59

自己顶上去,应该是个基础问题,望达人不吝赐教,先谢了。
头像
自由建客
帖子: 13468
注册时间: 2008-07-30 23:21
系统: Debian stable AMD64

Re: 为什么rc.local里写alias ll="ls -l"无效

#7

帖子 自由建客 » 2009-08-25 9:54

rc.local 中 alias 也是有效的,但作用域只在 rc.local 中,看 rc.local 最后以行是什么。
id_joyride
帖子: 5
注册时间: 2009-07-21 22:14

Re: 为什么rc.local里写alias ll="ls -l"无效

#8

帖子 id_joyride » 2009-08-25 12:24

昨天在linuxsir论坛里有人指点了。因为rc.local的执行环境是在系统shell里,所以进入用户shell后失效了。
回复