每次输入用户名/密码登录比较烦人,于是便寻找一个自动登录工具,而gdm和kdm依赖关系一大堆.试用了一下xdm和slim.
使用xdm时,不知道为什么环境变量总会被改,比如locale和PATH什么的,google半天,没有找到原因.
slim比较漂亮,可以选择session,可以设置默认登录的用户,不过还要输入密码.
Google查到可以实现自动登录login shell,下面介绍一下步骤:
源代码 autologin.c
int main() {
execlp( "login", "login", "-f", "your_user_here", 0);
}
your_user_here 是你的用户名
编译,安装
gcc autologin.c -oautologin
sudo cp autologin /usr/sbin/autologin
配置 /etc/inittab
确保默认运行级别为3
id:3:initdefault:
修改
c1:2345:respawn:/sbin/agetty 38400 vc/1 linux
为
c1:2345:respawn:/sbin/agetty -n -l /usr/sbin/autologin 38400 vc/1 linux
配置 ~/.bash_profile
增加if [ -z "$DISPLAY" ] && [ $(tty) == /dev/vc/1 ]; then
startx
fi
本文参考: http://ubuntuforums.org/archive/index.php/t-31310.html 该文章如下:
Are you tired off typing logins? Don't want to load heavy/waste of time login managers?
This guide let's you have autologin and autostart for your XFCE: :razz:
Let's open a console and then create the file autologin.c
sudo nano autologin.c
and paste this code inside (middle mouse button will paste the text you underline):
int main() {
execlp( "login", "login", "-f", "your_user_here", 0);
}
replace the string: your_user_here with the user you want to autologin. (ctrl+X to save) btw, use your prefered editor.
Let's compile.. you will need to have gcc installed:
sudo gcc -o autologin autologin.c
copy the compiled autologin file into /usr/local/sbin
sudo cp autologin /usr/local/sbin
now we need to edit the file /etc/inittab
sudo nano /etc/inittab
search for this:
1:2345:respawn:/sbin/getty 38400 tty1
put a # to comment this line and add this new line:
1:2345:respawn:/sbin/getty -n -l /usr/local/sbin/autologin 38400 tty1
it will look like this:
#1:2345:respawn:/sbin/getty 38400 tty1
1:2345:respawn:/sbin/getty -n -l /usr/local/sbin/autologin 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
this will make the autologin stuff...
let's make the autostart:
nano .bash_profile
put this code on the bottom and save it
if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
startxfce4
fi
then you just have to remove your login manager :
sudo apt-get remove gdm xdm kdm
reboot your machine
I used this page as guide:
http://www.dicas-l.unicamp.br/dicas-l/20030129.shtml
This guide let's you have autologin and autostart for your XFCE: :razz:
Let's open a console and then create the file autologin.c
sudo nano autologin.c
and paste this code inside (middle mouse button will paste the text you underline):
int main() {
execlp( "login", "login", "-f", "your_user_here", 0);
}
replace the string: your_user_here with the user you want to autologin. (ctrl+X to save) btw, use your prefered editor.
Let's compile.. you will need to have gcc installed:
sudo gcc -o autologin autologin.c
copy the compiled autologin file into /usr/local/sbin
sudo cp autologin /usr/local/sbin
now we need to edit the file /etc/inittab
sudo nano /etc/inittab
search for this:
1:2345:respawn:/sbin/getty 38400 tty1
put a # to comment this line and add this new line:
1:2345:respawn:/sbin/getty -n -l /usr/local/sbin/autologin 38400 tty1
it will look like this:
#1:2345:respawn:/sbin/getty 38400 tty1
1:2345:respawn:/sbin/getty -n -l /usr/local/sbin/autologin 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
this will make the autologin stuff...
let's make the autostart:
nano .bash_profile
put this code on the bottom and save it
if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
startxfce4
fi
then you just have to remove your login manager :
sudo apt-get remove gdm xdm kdm
reboot your machine
I used this page as guide:
http://www.dicas-l.unicamp.br/dicas-l/20030129.shtml