centos lc ctype(centos7 failed to start LSB)
这篇文章给大家聊聊关于centos lc ctype,以及centos7 failed to start LSB对应的知识点,希望对各位有所帮助,不要忘了收藏本站哦。
CentOS7区域设置的方法
CentOS7区域设置
区域设置的配置文件在/etc/locale.conf,通过localectl命令进行设置;
systemd服务在启动的时候读取区域配置文件,完成系统的设置。
命令的几个常用方法如下:
1查看当前配置
[root@localhost~]# localectl status
System Locale: LANG=en_US.UTF-8
VC Keymap: us
X11 Layout: us
2查看可用的区域语言
[root@localhost~]# localectl list-locales|grep CN
bo_CN
bo_CN.utf8
ug_CN
ug_CN.utf8
zh_CN
zh_CN.gb18030
zh_CN.gb2312
zh_CN.gbk
zh_CN.utf8
3设置区域语音
localectl set-locale LANG=zh_CN.utf8
4键盘布局查看和配置使用以下命令,就不详细介绍了。
localectl list-keymaps
localectl set-keymap
localectl set-x11-keymap
5 localectl还可以配置远程系统的区域配置,加-H参数奇可以了。
-H--host=[USER@]HOST Operate on remote host
6 localectl命令的几个关键字:
关键字
LANG默认的系统语音
LC_COLLATE更改字母表
LC_CTYPE改变字符功能处理
LC_NUMERIC数字格式
LC_TIME时间格式,24小时格式,或者12小时格式。
LC_MESSAGES配置标准报错信息使用那种语言。
ubuntu修改了ssh配置后 putty 还是出现access denied
你可以从以下几点查看实验下。
首先,先备份一下配置文件。
mkdir~/backup
cp/etc/ssh/ssh_config~/backup/ssh_config
第二步,编辑文件:
vi/etc/ssh/ssh_config
使用“/”搜搜看下Allow/Deny开头的项目,全部注释掉。(我查看了下,有些文章说AllowUsers参数会限制访问用户,需要在后面添加root,才能使用root账户ssh登陆,但我在我的centos7的ssh_config文件中未看到此参数,虽然有一些其他Allow\Deny开头的参数,不过全部都是被注释状态。可以参考最后我的sshd_config文件。)
修改完成后,重启服务/etc/init.d/ssh start(参考的百度出来的文章结果,我实际实验结果是:守护进程里并没有ssh,无法运行此命令,chkconfig里也没有sshd进程,service也无法重启ssh,所以我直接reboot了系统)
如果,依然不行进行下一步。
第三步,同网段内其他windows主机打开cmd,查看主机ssh端口(如果修改了默认端口,得自行把22修改为正确端口)是否正常。
win+r,输入cmd
ping(ubuntu主机IP地址)#首先要保证网络通
telnet(ubuntu主机IP地址)22#查看端口是否通
如果正常,应该显示类似“SSH-2.0-OpenSSH_6.6.1”的消息,或者是纯黑屏,再次点击回车断开连接。
第四步,如果上一步显示不正常,可能是防火墙设置问题,关闭或设置防火墙
ufw disable(方法一:关闭防火墙)
ufw allow 22/tcp(方法二:打开端口22)
(注:我用的centos采用的是最小化安装,未安装防火墙,这一步骤是我参考的网上资料,未进行实验。具体可自行百度。)
最后附上我的ssh_config文件。
#$OpenBSD:sshd_config,v1.932014/01/1005:59:19djmExp$
#Thisisthesshdserversystem-wideconfigurationfile.See
#sshd_config(5)formoreinformation.
#ThissshdwascompiledwithPATH=/usr/local/bin:/usr/bin
#Thestrategyusedforoptionsinthedefaultsshd_configshippedwith
#OpenSSHistospecifyoptionswiththeirdefaultvaluewhere
#possible,butleavethemcommented.Uncommentedoptionsoverridethe
#defaultvalue.
#IfyouwanttochangetheportonaSELinuxsystem,youhavetotell
#SELinuxaboutthischange.
#semanageport-a-tssh_port_t-ptcp#PORTNUMBER
#
#Port22
#AddressFamilyany
#ListenAddress0.0.0.0
#ListenAddress::
#Thedefaultrequiresexplicitactivationofprotocol1
#Protocol2
#HostKeyforprotocolversion1
#HostKey/etc/ssh/ssh_host_key
#HostKeysforprotocolversion2
HostKey/etc/ssh/ssh_host_rsa_key
#HostKey/etc/ssh/ssh_host_dsa_key
HostKey/etc/ssh/ssh_host_ecdsa_key
HostKey/etc/ssh/ssh_host_ed25519_key
#Lifetimeandsizeofephemeralversion1serverkey
#KeyRegenerationInterval1h
#ServerKeyBits1024
#Ciphersandkeying
#RekeyLimitdefaultnone
#Logging
#obsoletesQuietModeandFascistLogging
#SyslogFacilityAUTH
SyslogFacilityAUTHPRIV
#LogLevelINFO
#Authentication:
#LoginGraceTime2m
#PermitRootLoginyes
#StrictModesyes
#MaxAuthTries6
#MaxSessions10
#RSAAuthenticationyes
#PubkeyAuthenticationyes
#Thedefaultistocheckboth.ssh/authorized_keysand.ssh/authorized_keys2
#butthisisoverriddensoinstallationswillonlycheck.ssh/authorized_keys
AuthorizedKeysFile.ssh/authorized_keys
#AuthorizedPrincipalsFilenone
#AuthorizedKeysCommandnone
#AuthorizedKeysCommandUsernobody
#Forthistoworkyouwillalsoneedhostkeysin/etc/ssh/ssh_known_hosts
#RhostsRSAAuthenticationno
#similarforprotocolversion2
#HostbasedAuthenticationno
#Changetoyesifyoudon'ttrust~/.ssh/known_hostsfor
#RhostsRSAAuthenticationandHostbasedAuthentication
#IgnoreUserKnownHostsno
#Don'treadtheuser's~/.rhostsand~/.shostsfiles
#IgnoreRhostsyes
#Todisabletunneledcleartextpasswords,changetonohere!
#PasswordAuthenticationyes
#PermitEmptyPasswordsno
PasswordAuthenticationyes
#Changetonotodisables/keypasswords
#ChallengeResponseAuthenticationyes
ChallengeResponseAuthenticationno
#Kerberosoptions
#KerberosAuthenticationno
#KerberosOrLocalPasswdyes
#KerberosTicketCleanupyes
#KerberosGetAFSTokenno
#KerberosUseKuserokyes
#GSSAPIoptions
GSSAPIAuthenticationyes
GSSAPICleanupCredentialsno
#GSSAPIStrictAcceptorCheckyes
#GSSAPIKeyExchangeno
#GSSAPIEnablek5usersno
#Setthisto'yes'toenablePAMauthentication,accountprocessing,
#andsessionprocessing.Ifthisisenabled,PAMauthenticationwill
#beallowedthroughtheChallengeResponseAuthenticationand
#PasswordAuthentication.DependingonyourPAMconfiguration,
#PAMauthenticationviaChallengeResponseAuthenticationmaybypass
#thesettingof"PermitRootLoginwithout-password".
#IfyoujustwantthePAMaccountandsessioncheckstorunwithout
#PAMauthentication,thenenablethisbutsetPasswordAuthentication
#andChallengeResponseAuthenticationto'no'.
#WARNING:'UsePAMno'isnotsupportedinRedHatEnterpriseLinuxandmaycauseseveral
#problems.
UsePAMyes
#AllowAgentForwardingyes
#AllowTcpForwardingyes
#GatewayPortsno
X11Forwardingyes
#X11DisplayOffset10
#X11UseLocalhostyes
#PermitTTYyes
#PrintMotdyes
#PrintLastLogyes
#TCPKeepAliveyes
#UseLoginno
UsePrivilegeSeparationsandbox#Defaultfornewinstallations.
#PermitUserEnvironmentno
#Compressiondelayed
#ClientAliveInterval0
#ClientAliveCountMax3
#ShowPatchLevelno
#UseDNSyes
#PidFile/var/run/sshd.pid
#MaxStartups10:30:100
#PermitTunnelno
#ChrootDirectorynone
#VersionAddendumnone
#nodefaultbannerpath
#Bannernone
#Acceptlocale-relatedenvironmentvariables
AcceptEnvLANGLC_CTYPELC_NUMERICLC_TIMELC_COLLATELC_MONETARYLC_MESSAGES
AcceptEnvLC_PAPERLC_NAMELC_ADDRESSLC_TELEPHONELC_MEASUREMENT
AcceptEnvLC_IDENTIFICATIONLC_ALLLANGUAGE
AcceptEnvXMODIFIERS
#overridedefaultofnosubsystems
Subsystemsftp/usr/libexec/openssh/sftp-server
#Exampleofoverridingsettingsonaper-userbasis
#MatchUseranoncvs
#X11Forwardingno
#AllowTcpForwardingno
#PermitTTYno
#ForceCommandcvsserver
Ubuntu系统修改Locale时出现错误怎么解决
问题描述
终端显示中文正常,应用程序里面显示中文异常。
错误表现
1$ sudo dpkg-reconfigure locales
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE=“zh_CN:zh:en_US:en”,
LC_ALL=“zh_CN.UTF-8”,
LANG=“zh_CN.UTF-8”
are supported and installed on your system.
perl: warning: Falling back to the standard locale(“C”)。
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
/bin/bash: warning: setlocale: LC_ALL: cannot change locale(zh_CN.UTF-8)
Generating locales.。。
en_US.UTF-8.。。/usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale(zh_CN.UTF-8)
up-to-date
Generation complete.
1$ man locale
man: can‘t set the locale; make sure$LC_* and$LANG are correct
1$ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=zh_CN.UTF-8
LANGUAGE=zh_CN:zh:en_US:en
LC_CTYPE=“zh_CN.UTF-8”
LC_NUMERIC=“zh_CN.UTF-8”
LC_TIME=“zh_CN.UTF-8”
LC_COLLATE=“zh_CN.UTF-8”
LC_MONETARY=“zh_CN.UTF-8”
LC_MESSAGES=“zh_CN.UTF-8”
LC_PAPER=“zh_CN.UTF-8”
LC_NAME=“zh_CN.UTF-8”
LC_ADDRESS=“zh_CN.UTF-8”
LC_TELEPHONE=“zh_CN.UTF-8”
LC_MEASUREMENT=“zh_CN.UTF-8”
LC_IDENTIFICATION=“zh_CN.UTF-8”
LC_ALL=
1$ localectl list-locales
C.UTF-8
en_US.utf8
zh_CN.utf8
问题解决办法
要想达到应用程序中正常显示中文字符的目的,要下面的三个变量应该如下,
1LANG=zh_CN.UTF-8
2LANGUAGE=zh_CN:zh:en_US:en
3LC_ALL=LC_ALL=zh_CN.UTF-8
但问题在于“LC_ALL to default locale: No such file or directory”和“LC_ALL: cannot change locale(zh_CN.UTF-8)”,因此重新安装中文语言包。
执行下面命令
1sudo apt-get-y install language-pack-zh-hans
或
1sudo apt-get-y install language-pack-zh-hans language-pack-zh-hans-base
如果想支持繁体字,则执行
1sudo apt-get-y install language-pack-zh-hant
或
1sudo apt-get-y install language-pack-zh-hant language-pack-zh-hant-base
再执行locale命令设置当前locale环境
1locale
相关的文件和参考
相关手册:man locale(1), locale(5), locale(7)
相关文件:/usr/share/i18n/SUPPORTED
相关命令:
locale--all-locales列出当前系统中所有支持的locale
localectl list-locales列出当前系统中所有可用的locale
localectl set-locales LOCALE.。。修改当前系统中的locale,与locale功能相同,与export上文提到的三个变量相同
对于CentOS,可以直接编辑/etc/sysconfig/i18n文件,将LANG=“en_US.UTF-8”设置成LANG=“zh_CN.UTF-8”,除此之外,CentOS下locale命令的显示结果如下:
1# locale
LANG=en_US.UTF-8
LC_CTYPE=“en_US.UTF-8”
LC_NUMERIC=“en_US.UTF-8”
LC_TIME=“en_US.UTF-8”
LC_COLLATE=“en_US.UTF-8”
LC_MONETARY=“en_US.UTF-8”
LC_MESSAGES=“en_US.UTF-8”
LC_PAPER=“en_US.UTF-8”
LC_NAME=“en_US.UTF-8”
LC_ADDRESS=“en_US.UTF-8”
LC_TELEPHONE=“en_US.UTF-8”
LC_MEASUREMENT=“en_US.UTF-8”
LC_IDENTIFICATION=“en_US.UTF-8”
LC_ALL=
其中,LC_ALL=为空,但并不是表示这里不对,而是LC_ALL=实际上等于LC_COLLATE、LC_CTYPE、LC_MONETARY、LC_MESSAGES、LC_NUMERIC、LC_TIME,参见locale(7)。