Linux下常见问题解决办法

Xterm 终端无法显示中文

今天在登录服务器时,发现所有的中文均显示???

这种问题的基本解决办法就安装中文字体,调整locale的设置。

我出现这个问题的原因时.在确认另一台电脑上登录服务器可以正确显示之后,我发现自己 的电脑上的locale设置不正确,中英文混合设置。因此我将我的电脑全部设置成en_US即可 。

cat /etc/default/locale
#  File generated by update-locale
LANG="en_US.UTF-8"
LANGUAGE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_MONETARY="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"

解压.Z文件

uncompress *.Z

Operation not Supported in Pcmanfm or Thunar

sudo apt-get install gvfs gvfs-backends

debian 无法休眠?无法挂起

很多文章建议大内存(4G+)、SSD硬盘的用户不使用swap分区,其实swap分区对于这些用户 真的没有必要。所以我选择禁用swap分区。但是禁用swap分区会造成无法正常休眠,休眠 后无法唤起等问题,所以干脆禁止系统休眠算了。

解决办法来自于http://my.oschina.net/emptytimespace/blog/101796

具体解决如下:

sudo vi /etc/default/acpi-support

里面有一行:

ACPI_SLEEP=true
ACPI_HIBERNATE=ture

注释掉这两句,或者将true改为false,就禁用了休眠和挂起。

ACPI_SLEEP=true
ACPI_HIBERNATE=ture

Do You Have a Strange Power Saving Mode Enabled?

登陆服务器,发现服务器提示一个错误。

    Uhhuh. NMI received for unknown reason 30.
    Dazed and confused, but trying to continue
    Do you have a strange power saving mode enabled?

    Uhhuh. NMI received for unknown reason 20.
    Dazed and confused, but trying to continue
    Do you have a strange power saving mode enabled?

搜索一番,有人说这个是bug,已经在kernel 4.0中修复了,

问题的原因是在服务器上长时间开启虚拟机导致的。

解决办法如下

How do I fix this error?

A. This is caused when the system is hanging under load. Add any one of the following to you /boot/grub.conf file:

Disable the NMI watchdog by adding “nmi_watchdog=0”
Disable the high precision event timer (HPET) by adding “nohpet”

Open grub.conf, type: vi grub.conf Make modification to kernel line as follows:

Save and close the file. Reboot the server:

xbacklight-no-outputs-have-backlight-property

这个错误可能导致无法使用键盘xbacklight调节屏幕亮度,可按以下步骤进行调整

  1. 生成Xorg.conf

进入tty模式,然后停止显示服务器

sudo service slim stop

然后重新生成xorg.conf

sudo Xorg -configure

然后生成了/root/xorg.conf.new,此处路径可能不一样。

然后将其覆盖/etc/X11/xorg.conf

我得到的原始xorg.conf.new如下,

Section "ServerLayout"
	Identifier     "X.org Configured"
	Screen      0  "Screen0" 0 0
	Screen      1  "Screen1" RightOf "Screen0"
	InputDevice    "Mouse0" "CorePointer"
	InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
	ModulePath   "/usr/lib/xorg/modules"
	FontPath     "/usr/share/fonts/X11/misc"
	FontPath     "/usr/share/fonts/X11/cyrillic"
	FontPath     "/usr/share/fonts/X11/100dpi/:unscaled"
	FontPath     "/usr/share/fonts/X11/75dpi/:unscaled"
	FontPath     "/usr/share/fonts/X11/Type1"
	FontPath     "/usr/share/fonts/X11/100dpi"
	FontPath     "/usr/share/fonts/X11/75dpi"
	FontPath     "built-ins"
EndSection

Section "Module"
	Load  "glx"
EndSection

Section "InputDevice"
	Identifier  "Keyboard0"
	Driver      "kbd"
EndSection

Section "InputDevice"
	Identifier  "Mouse0"
	Driver      "mouse"
	Option	    "Protocol" "auto"
	Option	    "Device" "/dev/input/mice"
	Option	    "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
	Identifier   "Monitor0"
	VendorName   "Monitor Vendor"
	ModelName    "Monitor Model"
EndSection

Section "Monitor"
	Identifier   "Monitor1"
	VendorName   "Monitor Vendor"
	ModelName    "Monitor Model"
EndSection

Section "Device"
        ### Available Driver options are:-
        ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
        ### <string>: "String", <freq>: "<f> Hz/kHz/MHz",
        ### <percent>: "<f>%"
        ### [arg]: arg optional
        #Option     "Accel"              	# [<bool>]
        #Option     "AccelMethod"        	# <str>
        #Option     "Backlight"          	# <str>
        #Option     "CustomEDID"         	# <str>
        #Option     "DRI"                	# <str>
        #Option     "Present"            	# [<bool>]
        #Option     "ColorKey"           	# <i>
        #Option     "VideoKey"           	# <i>
        #Option     "Tiling"             	# [<bool>]
        #Option     "LinearFramebuffer"  	# [<bool>]
        #Option     "HWRotation"         	# [<bool>]
        #Option     "VSync"              	# [<bool>]
        #Option     "PageFlip"           	# [<bool>]
        #Option     "SwapbuffersWait"    	# [<bool>]
        #Option     "TripleBuffer"       	# [<bool>]
        #Option     "XvPreferOverlay"    	# [<bool>]
        #Option     "HotPlug"            	# [<bool>]
        #Option     "ReprobeOutputs"     	# [<bool>]
        #Option     "XvMC"               	# [<bool>]
        #Option     "ZaphodHeads"        	# <str>
        #Option     "VirtualHeads"       	# <i>
        #Option     "TearFree"           	# [<bool>]
        #Option     "PerCrtcPixmaps"     	# [<bool>]
        #Option     "FallbackDebug"      	# [<bool>]
        #Option     "DebugFlushBatches"  	# [<bool>]
        #Option     "DebugFlushCaches"   	# [<bool>]
        #Option     "DebugWait"          	# [<bool>]
        #Option     "BufferCache"        	# [<bool>]
	Identifier  "Card0"
	Driver      "intel"
	BusID       "PCI:0:2:0"
EndSection

Section "Device"
        ### Available Driver options are:-
        ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
        ### <string>: "String", <freq>: "<f> Hz/kHz/MHz",
        ### <percent>: "<f>%"
        ### [arg]: arg optional
        #Option     "SWcursor"           	# [<bool>]
        #Option     "HWcursor"           	# [<bool>]
        #Option     "NoAccel"            	# [<bool>]
        #Option     "ShadowFB"           	# [<bool>]
        #Option     "VideoKey"           	# <i>
        #Option     "WrappedFB"          	# [<bool>]
        #Option     "GLXVBlank"          	# [<bool>]
        #Option     "ZaphodHeads"        	# <str>
        #Option     "PageFlip"           	# [<bool>]
        #Option     "SwapLimit"          	# <i>
        #Option     "AsyncUTSDFS"        	# [<bool>]
        #Option     "AccelMethod"        	# <str>
        #Option     "DRI"                	# <i>
	Identifier  "Card1"
	Driver      "nouveau"
	BusID       "PCI:2:0:0"
EndSection

Section "Screen"
	Identifier "Screen0"
	Device     "Card0"
	Monitor    "Monitor0"
	SubSection "Display"
		Viewport   0 0
		Depth     1
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     4
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     8
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     15
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     16
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     24
	EndSubSection
EndSection

Section "Screen"
	Identifier "Screen1"
	Device     "Card1"
	Monitor    "Monitor1"
	SubSection "Display"
		Viewport   0 0
		Depth     1
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     4
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     8
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     15
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     16
	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     24
	EndSubSection
EndSection
  1. 修改Xorg.conf
Section "ServerLayout"
	Identifier     "X.org Configured"
	Screen      0  "Screen0" 0 0
    #Screen      1  "Screen1" RightOf "Screen0" 注释掉该行
	InputDevice    "Mouse0" "CorePointer"
	InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

\* --------  *\

Section "Device"
        ### Available Driver options are:-
        ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
        ### <string>: "String", <freq>: "<f> Hz/kHz/MHz",
        ### <percent>: "<f>%"
        ### [arg]: arg optional
        #Option     "Accel"              	# [<bool>]
        #Option     "AccelMethod"        	# <str>
        #Option     "Backlight"          	# <str>
        #Option     "CustomEDID"         	# <str>
        #Option     "DRI"                	# <str>
        #Option     "Present"            	# [<bool>]
        #Option     "ColorKey"           	# <i>
        #Option     "VideoKey"           	# <i>
        #Option     "Tiling"             	# [<bool>]
        #Option     "LinearFramebuffer"  	# [<bool>]
        #Option     "HWRotation"         	# [<bool>]
        #Option     "VSync"              	# [<bool>]
        #Option     "PageFlip"           	# [<bool>]
        #Option     "SwapbuffersWait"    	# [<bool>]
        #Option     "TripleBuffer"       	# [<bool>]
        #Option     "XvPreferOverlay"    	# [<bool>]
        #Option     "HotPlug"            	# [<bool>]
        #Option     "ReprobeOutputs"     	# [<bool>]
        #Option     "XvMC"               	# [<bool>]
        #Option     "ZaphodHeads"        	# <str>
        #Option     "VirtualHeads"       	# <i>
        #Option     "TearFree"           	# [<bool>]
        #Option     "PerCrtcPixmaps"     	# [<bool>]
        #Option     "FallbackDebug"      	# [<bool>]
        #Option     "DebugFlushBatches"  	# [<bool>]
        #Option     "DebugFlushCaches"   	# [<bool>]
        #Option     "DebugWait"          	# [<bool>]
        #Option     "BufferCache"        	# [<bool>]
	Identifier  "Card0"
	Driver      "intel"
	BusID       "PCI:0:2:0"
    Option      "Backlight"         	# 此处增加<str>
EndSection

No presmission to write 文件没有写入权限

sudo chown $user $dir
sudo chgrp $user $dir

linux下查看进程运行的时间

ps -eo pid,tty,user,comm,lstart,etime | grep init

linux 下取进程占用内存(MEM)最高的前10个进程

linux 下取进程占用 cpu 最高的前10个进程

ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head

linux 下取进程占用内存(MEM)最高的前10个进程

ps aux|head -1;ps aux|grep -v PID|sort -rn -k +4|head

Transport endpoint is not connected 的解决办法

ls: cannot access 'shfs': Transport endpoint is not connected
total 135M
-rw-r--r--  1 lex lex    0 Mar  8 10:35 atex
drwxr-xr-x 15 lex lex 4.0K May 15 20:44 Documents
d?????????  ? ?   ?      ?            ? shfs
-rw-------  1 lex lex  13M May  9 22:58 nohup.out
drwxr-xr-x  3 lex lex 4.0K Mar  6  2017 R
drwxr-xr-x  3 lex lex 4.0K Feb 27 19:40 Software
drwxr-xr-x  5 lex lex 4.0K Apr 10 20:46 Temp
drwxr-xr-x  3 lex lex 4.0K Apr 30 16:56 tmp
drwxr-xr-x  6 lex lex 4.0K Mar  6 22:13 toDelete

I get this message when there’s been a bad disconnect from a fuse fs.

Unmounting and remounting the fs solves it

Code:

$ fusermount -u <mountpoint>
$ sshfs <mountpoint>
du -hT # 显示所有挂载点

https://www.linuxquestions.org/questions/slackware-14/transport-endpoint-is-not-connected-filesystem-error-817146/

VLC is unable to open the MRL

samba

如果是打开samba共享文件时出现的,主要的解决办法如下

参考链接1

参考链接2

ThinkPad T440p安装debian之显卡驱动篇

获取当前设备的显卡情况

lspci | grep VGA

ThinkPad T440p的显卡设备主要有以下

00:02.0 VGA compatible controller: Intel Corporation 4th Gen Core Processor Integrated Graphics Controller (rev 06)
02:00.0 VGA compatible controller: NVIDIA Corporation GK208M [GeForce GT 730M] (rev a1)

可以看出我们当前的显卡有两块,其中Intel的显卡可以不用管,Linux对Intel显卡的默认 支持非常好,当前的Nvidia显卡核心是GK208M,型号是GT730M,那么我们在软件库中搜索 相关软件包

sudo apt-get update
apt-cache search GT 730 # 此处不要搜索730M

搜索结果为

nvidia-legacy-304xx-driver - NVIDIA metapackage (304xx legacy version)
nvidia-legacy-304xx-kernel-dkms - NVIDIA binary kernel module DKMS source (304xx legacy version)
nvidia-legacy-304xx-kernel-source - NVIDIA binary kernel module source (304xx legacy version)
xserver-xorg-video-nvidia-legacy-304xx - NVIDIA binary Xorg driver (304xx legacy version)
nvidia-legacy-340xx-driver - NVIDIA metapackage (340xx legacy version)
nvidia-legacy-340xx-kernel-dkms - NVIDIA binary kernel module DKMS source (340xx legacy version)
nvidia-legacy-340xx-kernel-source - NVIDIA binary kernel module source (340xx legacy version)
xserver-xorg-video-nvidia-legacy-340xx - NVIDIA binary Xorg driver (340xx legacy version)

这说明现在库中包含你的显卡所要使用的驱动,那么我们可以从库中直接安装。使用库中 的软件的好处是显而易见的。但是我们搞不清到底使用哪种驱动

安装

下面安装nvidia-detect,然后运行它

sudo apt-get install nvidia-detect
nvidia-detect

运行结果如下

Detected NVIDIA GPUs:
02:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK208M [GeForce GT 730M] [10de:1290] (rev a1)

Checking card:  NVIDIA Corporation GK208M [GeForce GT 730M] (rev a1)
Your card is supported by the default drivers and legacy driver series 340.
It is recommended to install the
    nvidia-driver
package.

现在就很明显了,直接安装nvidia-driver即可。

sudo apt-get install nvidia-driver nvidia-legacy-340xx-driver xserver-xorg-video-nvidia-legacy-340xx
sudo apt-get install primus bumblebee bumblebee-nvidia
#此处是必须的,否则会出现类似GLX is not supported的问题

使用显卡

安装完了之后,nvidia显卡默认不起用,所以需要时要用primus包中的optirun启动

比如我要启动0ad这个游戏

optirun 0ad

查看显卡内存使用量

也许你可能想显卡到底启用没,那么可以使用nvidia-smi来查看。比如我玩游戏前, nvidia-smi的输出如下

Sun Oct 30 10:47:49 2016
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 367.44                 Driver Version: 367.44                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GT 730M     Off  | 0000:02:00.0     N/A |                  N/A |
| N/A   53C    P0    N/A /  N/A |      0MiB /   982MiB |     N/A      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID  Type  Process name                               Usage      |
|=============================================================================|
|    0                  Not Supported                                         |
+-----------------------------------------------------------------------------+

下面是启动游戏后的结果

Sun Oct 30 10:48:44 2016
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 367.44                 Driver Version: 367.44                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GT 730M     Off  | 0000:02:00.0     N/A |                  N/A |
| N/A   56C    P0    N/A /  N/A |     85MiB /   982MiB |     N/A      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID  Type  Process name                               Usage      |
|=============================================================================|
|    0                  Not Supported                                         |
+-----------------------------------------------------------------------------+

可以明显看到显卡内存占用增加了85m。另外,请自行删除旧的nouveau程序。

usermod -a -G bumblebee $USER

注:个人经验之言,仅供参考。