startx启动图形界面失败的几个解决方法startx无法进入图形界面




startx启动图形界面失败的几个解决方法startx无法进入图形界面

2022-07-20 21:06:59 网络知识 官方管理员

很多linux用户有如此一个惨痛经历。当你和平常一样登陆和输入这可爱的startx时,你只是接收到错误信息。

Manyofusgnu/linuxusershavehadsuchaterribleexperience.Whenyou
很多linux用户有如此一个惨痛经历。当你
loginandtypethesweetstartxasusual,youonlyreceivescrollinglines
和平常一样登陆和输入这可爱的startx时,你只是接收到
oferrormessages.Onecopyoftheerrormessageisusuallystoredin
错误信息。错误通常存储在
/var/log/XFree86.0.log.Ifyoucanaccessthelogfile,youwillnotice
/var/log/XFree86.0.log。如果你读取这个日志文件,你将会注意到
thelastlinesofthefilemaylooklikethis:
文件的最后一行通常如这样:
Couldnotinitfontpathelementunix/:7100,removingfromlist!
Fatalservererror:
couldnotopendefaultfont'fixed'

IhavetoadmitthatIwasinpanicwhenIsawthismessageinthefirst
我不得不承认我感到恐慌当我最初几次看到这些信息。
sever altimes.Asanintermediateuseroflinuxsystem,Iwasnotso
作为一个中级的linux系统用户,我感到用命令控制台拨号和用lynx冲浪不
comfortableusingtextconsoleformodemdialupandsurfingwithlynx.So
舒服冲浪。所以
IhadtospendalotoftimeonanotherboxanduseGoogletosearchfor
我不得不花费很多时间在另一台电脑的使用Google在网上搜索帮助。
helponweb.Itwasamazingthatsomanypeoplelikemehavethisexact
另人感到意外的是如此多人像我一样拥有如此
terribleexperienceandthoserepliesinwebforumsandmailinglists
恐怖的经历和那些网上论坛和邮件列表的答复
generallyoffermoresympathythanrealhelp.Usingourcommonsenseand
一般提供更多的同情心而不是真正的帮助。用我们一般的理解和
someresearch,mostofuscanfigureoutthisfailurehassomethingtodo
研究,我们大部分可以判断这是X字体服务的失败。
withXfontserver.

Afterhavingdonealittlemoreresearch,nowIbelievethatthisfailure
做完进一步的研究之后,我现在相信这
maynotbesoseriousasitlooks.Pleasefollowmebydoingthesteps
不像人们想象中的那么严重。请跟着我做下面的这些步骤,
below,inmostofthecasesyouwillgetyourXwindowsstartingupagain.
在大部分的案例中你将可以重新进入Xwindows。
Note:ThefollowingexamplesrunonmyRedHatbox.ButIbelievetheyare
注意:这些例子在我的RedHat系统上。但我相信他们
generalenoughtobeusedforotherdistributions.
通常足够应用在其它发行版上。

1.CheckiftheXfontserverisrunning.
1、检查X字体服务是否正在运行。

SomepeoplelikemetendtosuspectitiscausedbybugsintheXfont
一些人像我一样趋向于怀疑这是由X字体服务的bugs引起的,
server,butitturnedoutthatXfontserverisquiterobust.Wecanrun
但它证明这X字体服务是良好的。我们可以运行
thexfsscriptunder/etc/init.dtoseeifthefontserverisrunning.
这xfs格本文件夹在/etc/init.d去看是否字体服务正在运行。

[root@localhost/root]#/etc/init.d/xfsstatus
xfs(pid1385)isrunning...

Insomecases,theonlyreasonforthefailureisthatthefontserveris
在一些案例,唯一失败的原因是字体服务停止
dead.So,youneedtorestartfontserverlikethis:
所以,你需要重新启动字体服务象这样:
[root@localhost/root]#/etc/init.d/xfsstart
Startingxfs:[OK]

Well,mylearnedlessonisdon'ttakethis'[OK]'forgranted.Youhaveto
好,我的学习课程不承认OK是真的。你必须
checkthestatusagaintoseeifitisrunning.Ifitdoesrun,youcan
再次检查状况去看看是否正在运行。如果它不运行,你可以尝试
trystartxtoseeifyoucanstartXwindows.IfyoustillcannotstartX
startx去看看是否可以开始Xwindows。当字体服务运行时,如果你仍然不可以运行X
serverwhenthefontserverruns,itmeansyouarehavingmoreserious
服务,它意味着你拥有更严重的错误。
trouble.Youneedtowastealittlemoretimereadingonthefollowing
你需要花费更多的一点时间阅读以下的步骤。
steps.

Note:Inaweirdcase,myrootpartitionwasfullyfilledbytwohugelog
注意:在一个古怪的案例,我的根目录是被两个大于2GB的信息文件所占据满的。
filesoccupyingmorethan2GB.Thefontserverdieswhenitcannotwrite
当它不可能写进/tmp字体服务停止。
to/tmp.Sothesimplesolutionwasfindingthehugefilesanddeleting
因此一些例子的解决办法是寻找巨大文件的删除掉他们。
them.

2.Checkifthefont'fixed'isaccessible.
检查是否字体fixed可以理解的。

Nowitistimetoensurethatthefont'fixed'isaccessible.First,we
现在是时侯确保字体fixed是受影响的。首先
canusecommandfslsfontstoseeiffont'fixed'existsinthesearch
我们可以运行命令fslsfonts去看是否字体存在在所寻找的路径
path:

[root@localhostalex]#fslsfonts-serverunix/:7100-ll-fnfixed
DIRMINMAXEXISTDFLTASCDESCNAME
-->0255some0112fixed
FONTNAME_REGISTRY
FOUNDRYMisc
FAMILY_NAMEFixed
WEIGHT_NAMEMedium
SLANTR
SETWIDTH_NAMESemiCondensed
ADD_STYLE_NAME
PIXEL_SIZE13
POINT_SIZE120
RESOLUTION_X75
RESOLUTION_Y75
SPACINGC
AVERAGE_WIDTH60
CHARSET_REGISTRYISO8859
CHARSET_ENCODING1
COPYRIGHTPublicdomainfont.Shareandenjoy.
CAP_HEIGHT9
X_HEIGHT6
FONT-Misc-Fixed-Medium-R-SemiCondensed--13-120-75-75-C-60-ISO8859-1
WEIGHT10
RESOLUTION103
QUAD_WIDTH6

Thisisthenormaloutputwhen'fixed'isavailable.Here,wecanseethat
当fixed是可用的,这是通常输出的情况,我们可以看到
'fixed'isactuallyanaliasforthefont
fixed实际上是字体的别名。
'-Misc-Fixed-Medium-R-SemiCondensed--13-120-75-75-C-60-ISO8859-1'.If

thereisnofont'fixed',wefirstneedtogainknowledgeofthesearch
如果不是字体fixed,我们首先需要获得更多的信息在字体的所在路径。
pathforfonts.Wecanusecommandchkfontpathtolookatthosepaths:
我们可以运用命令chkfontpath去看那些路径:

[root@localhostalex]#/usr/sbin/chkfontpath
Currentdirectoriesinfontpath:
1:/usr/X11R6/lib/X11/fonts/misc:unscaled
2:/usr/X11R6/lib/X11/fonts/75dpi:unscaled
3:/usr/X11R6/lib/X11/fonts/100dpi:unscaled
4:/usr/X11R6/lib/X11/fonts/misc
5:/usr/X11R6/lib/X11/fonts/Type1
6:/usr/X11R6/lib/X11/fonts/Speedo
7:/usr/X11R6/lib/X11/fonts/CID
8:/usr/X11R6/lib/X11/fonts/75dpi
9:/usr/X11R6/lib/X11/fonts/100dpi
10:/usr/share/fonts/default/Type1
11:/usr/share/fonts/default/TrueType
12:/usr/share/fonts/ja/TrueType
13:/usr/X11R6/lib/X11/fonts/latin2/100dpi:unscaled
14:/usr/X11R6/lib/X11/fonts/latin2/100dpi
15:/usr/share/fonts/ISO8859-7/misc:unscaled
16:/usr/share/fonts/ISO8859-7/75dpi:unscaled
17:/usr/share/fonts/ISO8859-7/100dpi:unscaled
18:/usr/share/fonts/ISO8859-7/misc
19:/usr/share/fonts/ISO8859-7/Type1
20:/usr/share/fonts/ISO8859-7/75dpi
21:/usr/share/fonts/ISO8859-7/100dpi
22:/usr/share/fonts/ISO8859-9/misc:unscaled
23:/usr/share/fonts/ISO8859-9/100dpi:unscaled
24:/usr/share/fonts/ISO8859-9/misc
25:/usr/share/fonts/ISO8859-9/100dpi
26:/usr/share/fonts/KOI8-R/100dpi:unscaled
27:/usr/share/fonts/KOI8-R/100dpi
28:/usr/share/fonts/zh_CN/TrueType
29:/usr/share/fonts/zh_TW/TrueType
30:/usr/share/AbiSuite/fonts

Thesearethefontpathsonmybox.Itshowsthatxfslooksintothese
这些字体路径在我的电脑上。它显示当它被修复的时候xfs观察这些路径寻找一个特殊的字体。
pathsseekingaspecificfontwhenitisrequired.Therearetwotypesof
有两种类型的重要文件:
importantfiles:fonts.dirineachofthesepaths,andfonts.aliasinsome
fonts.dir在每一个路径中,和fonts.alias在一些路径中。
ofthepaths.Forexample,let'sgoto/usr/X11R6/lib/X11/fonts/100dpi,
例如,让我们进入/usr/X11R6/lib/X11/fonts/100dpi,
andopenthefiles.Thefileslooklikethis:
和打开文件。文件象这样:

[fonts.dir]


775
UTI___14.pcf.gz-adobe-utopia-regular-i-normal--19-140-100-100-p-104-iso10646-1
UTBI__14.pcf.gz-adobe-utopia-bold-i-normal--19-140-100-100-p-109-iso10646-1
UTI___12.pcf.gz-adobe-utopia-regular-i-normal--17-120-100-100-p-89-iso10646-1
UTI___24.pcf.gz-adobe-utopia-regular-i-normal--33-240-100-100-p-179-iso10646-1
courO08.pcf.gz-adobe-courier-medium-o-normal--11-80-100-100-m-60-iso10646-1
UTBI__12.pcf.gz-adobe-utopia-bold-i-normal--17-120-100-100-p-93-iso10646-1
...

Thefirstlinespecifiesthenumberoffontsundercurrentdirectory.
这第一行详细说明字体的数量在当前目录。
Followinglinesmapfilenamestofontnames.
以下几行是字体文件的名字。

[fonts.alias]

lucidasans-bolditalic-8-b&h-lucida-bold-i-normal-sans-11-80-100-100-p-69-iso8859-1
lucidasans-bolditalic-10-b&h-lucida-bold-i-normal-sans-14-100-100-100-p-90-iso8859-1
lucidasans-bolditalic-12-b&h-lucida-bold-i-normal-sans-17-120-100-100-p-108-iso8859-1
lucidasans-bolditalic-14-b&h-lucida-bold-i-normal-sans-20-140-100-100-p-127-iso8859-1
lucidasans-bolditalic-18-b&h-lucida-bold-i-normal-sans-25-180-100-100-p-159-iso8859-1
lucidasans-bolditalic-24-b&h-lucida-bold-i-normal-sans-34-240-100-100-p-215-iso8859-1
...

Thisfilemapsfontaliastofontnames.Soitisclearthatoncefont
这个文件显示字体文件的别名与原名。因此清楚知道从前字体的fixed是需要的,
'fixed'isneeded,thefontserversearchfonts.aliasineachfontpath
字体服务在比赛中寻找字体别名在每一字体路径中。
foramatch.Ifthematchexists,thecorrespondingfontfileisspecified
如果比赛是存在,那相应的字体文件是指定在fonts.dir。
infonts.dir.Ifnomatchexists,whichisararesituation,theXserver
如果比赛不存在,那是非常罕见的情形,字体服务不可以运行我们需要重建字体列表。
cannotstartandweneedtorebuildthefontlists.Therebuildingprocess
这重建的过程
willgeneratenewfonts.dirandfonts.aliasfiles.
将会产生新的fonts.dir和fonts.alias文件。

3.Rebuildfontlist.
重建字体列表。

Fontlistcanberebuiltusingthescriptfilexfsunder/etc/init.d.
运用格本文件xfs在/etc/init.d下,字体列表可以被重建
Followingisanexcerptofthescript:
以下是格本文件的摘录:

...
buildfontlist(){
pushd.&>/dev/null
fordin$(/usr/sbin/chkfontpath--list|cut-f2-d':');do
if[-d"$d"];then
cd$d
#Checkifweneedtorerunmkfontdir
NEEDED=no
if![-efonts.dir];then
NEEDED=yes
elif["$(find.-typef-cnewerfonts.dir2>/dev/null)"!=""];then
NEEDED=yes
fi
if["$NEEDED"="yes"];then
...
}
...
start(){
if[-L/usr/X11R6/bin/X];then
echo-n$"Starting$prog:"
[-x/usr/sbin/chkfontpath]&&buildfontlist
rm-fr/tmp/.font-unix
daemonxfs-droppriv-daemon
ret=$?
[$ret-eq0]&&touch/var/lock/subsys/xfs
echo
return$ret
fi
}
...

Forreadersnotfamiliarwithshellprogramming,thisexcerptmeansthat
因为读者不熟悉运行命令程序,这格本文件的意思是每次xfs格本在运行,
eachtimexfsscriptisrun,itwillcheckwhetherthereisafonts.dir
它将会检查是否有fonts.dir在列表中的每一个字本路径中。
fileineachlistedfontpath.Iffonts.dirismissinginapath,font
当fonts.dir在路径中消失,字体列表需要重建。
listneedstoberebuilt.Ifafonts.dirdoesexistforeachpath,itwill
如果fonts.dir不存在于每一路径中,它将会
checkifthestatusofanyfileinthefontdirectoryischangedafterthe
检查是否所有文件在字体目录是被改变在fonts.dir最后一次改变。
lastchangeoffonts.dir.Ifthisistrue,thefontlistalsoneedstobe
如果这是真实的,字体列表也需要被重建。
rebuilt.

Fornewbiesnotinterestedinlearningshellprogramming,weplayasmall
作为网络新手是对学习命令不感兴趣的,我们玩一个小窍门在子程序buildfontlist()。
trickinthesubroutinebuildfontlist().Wecanset"NEEDED=yes"inthe
我们可以设置"NEEDED=yes"在第一情况下强制重建字体列表。
firstinstancetoforcetherebuildingoffontlist.

4.Fontsreallymissing?
字体确实不见了?

Ifallstepsabovefail.Mylastsuggestionistocheckifthefontfile
如果以上所有的步骤都失败了。我的最后一个意见书是检查是否字体文件
isreallyremovedbysomeprocesses.Thenyouneedtoreinstallthefont.
真正地被一些程序删去。然后你们需要重新设置字体.'


发表评论:

最近发表
网站分类
标签列表