修改grub.cfg后update-grub 后系统不能启动了,进不了桌面,于是想重新写回原来的grub,在网上搜了好久最后一个老外的帖子灵了,老外nb啊,在这谢谢这个老外,原帖如下:
http://askubuntu.com/questions/88384/how-can-i-repair-grub-how-to-get-ubuntu-back-after-installing-windows
When you install Windows, Windows assumes it's the only OS on the machine--or at least it doesn't account for Linux. So, it replaces grub with its own boot loader. What you have to do is replace the Windows boot loader with grub. I've seen various instructions for replacing grub by mucking around with grub commands or some such, but to me the easiest way is to simply chroot
into your install and runupdate-grub
. chroot
is great because it allows you to work on your actual install, instead of trying to redirect things here and there. It's really clean.
Here's how:
/dev/sda2
, but make sure you use the correct partition number for your system!Mount your partition:
sudo mount /dev/sda2 /mnt # make sure that sda2 is correct!
Bind mount some other necessary stuff:
for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; done
chroot
into your Ubuntu install:
sudo chroot /mnt
At this point, you're in your install, not the live CD, and running as root. Update grub:
update-grub
If you get errors, go to step 7. (Otherwise, it is optional.)
Depending on your situation, you might have to reinstall grub:
grub-install /dev/sda
update-grub # I'm not sure if this is necessary, but it doesn't hurt.
If everything worked without errors, then you're all set:
exit
sudo reboot
At this point, you should be able to boot normally.
If you cannot boot normally, and didn't do step 7 because there were no error messages, try again with step 7.
之所以会去弄grub是因为想启动进入text模式,ubuntu启动进入text模式见如下贴:
For Ubuntu 11.10 and 12.04, 12.10
Edit /etc/default/grub with your favorite editor,
sudo nano /etc/default/grub
Find out this line:
GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”
Change it to:
GRUB_CMDLINE_LINUX_DEFAULT=”text”
Update Grub:
sudo update-grub
No need to remove / disable lightdm
upstart conf, it already does that for you.
lightdm.conf
# Check kernel command-line for inhibitors, unless we are being called
# manually
for ARG in $(cat /proc/cmdline); do
if [ "$ARG" = "text" ]; then
plymouth quit || :
stop
exit 0
fi
done
You will still be able to use X by typing startx
after you logged in.
ubuntu 修改主机名
Linux主机名是在安装Linux操作系统的过程中设定的,并作为网络中的某一台主机的唯一标志,但是在安装好Linux系统后,如果想修改主机名,该怎么办呢?本文介绍基于Ubuntu Desktop 9.04。
1、快速查看主机名
在Ubuntu系统中,快速查看主机名有两种方法:一是打开一个GNOME终端窗口,在命令提示符中可以看到主机名,主机名通常位于“@”符号后;二是在终端窗口中输入命令:hostname或uname –n,均可以查看到当前主机名。
2、临时修改主机名
修改主机名最为快速的方法就是使用命令“hostname 新主机名”来改变当前主机名,其中“新主机名”可以用任何合法字符串来表示。不过采用这种方式,新主机名并不保存在系统中,重启系统后主机名将恢复为原先的主机名称。
3、永久修改主机名
在Ubuntu系统中永久修改主机名也比较简单。主机名存放在/etc/hostname文件中,修改主机名时,编辑hostname文件,在文件中输入新的主机名并保存该文件即可。重启系统后,参照上面介绍的快速查看主机名的办法来确认主机名有没有修改成功。
值得指出的是,在其他Linux发行版中,并非都存在/etc/hostname文件。如Fedora发行版将主机名存放在/etc/sysconfig/network文件中。所以,修改主机名时应注意区分是哪种Linux发行版。
【ubuntu 11.10】
这个ubuntu啊默认是启动进入文本模式,然后要想进入桌面呢,如下:
在命令行里输入 sudo lightdm start 进入图形界面是对的,按回车后进入到登录界面,要求输入密码。
如果输入了登录密码后不能进入图形桌面,仍然回到登录界面,你可以按ctrl+alt+f1返回命令行,发现一个.Xauthority 的文件被拒绝写入,那么没办法了,只能改变这个文件的权限了,用命令:
sudo chmod 646 .Xauthority
完成后,再sudo lightdm restart,进入登录界面,输入密码后正常进入桌面