Ubuntu常见问题收集

[TOC]

命令比较长的时候命令不会换行

  1. 特征: 在命令行输入的命令比较长的时候(并不是特别长),命令换行的时候并不是另起一行.而是在当前行从头开始,把当前行的命令覆盖掉继续输入.

原因: PS1变量设置不对,可以通过echo $PS1查看设置的结果.

# 不仅有PS1,还有PS2,PS3,PS4等待
# 主要是默认提示符用.而PS1配置中
# 这里仅用PS1做演示, PS2...等知道就行了不做演示也不做深究.


# 最初的时候,PS1配置为下面时,命令较长时则无法自动换行,会在同一行的开头开始覆盖,虽然还能执行但是很影响视觉和删除命令的操作
# 而且调用vim 的时候vim的窗口也非常非常的小
root@96e6800ffbe4:~# echo $PS1
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$
aaaaaaaaaaaaafbe4:~# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa


# PS1 为以下时,这时候命令比较长时也是会正常换行的,只是root@96e6800ffbe4:~#不会高亮而已
# PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
echo PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' >> ~/.bashrc
source .bashrc
root@96e6800ffbe4:~# ll
total 32
drwx------ 1 root root 4096 Aug 25 21:15 ./
drwxr-xr-x 1 root root 4096 Aug 25 20:02 ../
-rw------- 1 root root 1253 Aug 25 20:32 .bash_history
-rw-r--r-- 1 root root 3177 Aug 25 21:15 .bashrc
-rw-r--r-- 1 root root  148 Aug 17  2015 .profile
-rw------- 1 root root 8657 Aug 25 21:15 .viminfo
root@96e6800ffbe4:~# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

# PS1 为以下时,这时候命令比较长时也是会正常换行的,只是root@96e6800ffbe4:~#变成了绿色高亮而已
# PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
echo PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' >> ~/.bashrc
source ~/.bashrc
root@96e6800ffbe4:~# ll
total 32
drwx------ 1 root root 4096 Aug 25 21:18 ./
drwxr-xr-x 1 root root 4096 Aug 25 20:02 ../
-rw------- 1 root root 1253 Aug 25 20:32 .bash_history
-rw-r--r-- 1 root root 3108 Aug 25 21:18 .bashrc
-rw-r--r-- 1 root root  148 Aug 17  2015 .profile
-rw------- 1 root root 8914 Aug 25 21:18 .viminfo
root@96e6800ffbe4:~# vim .bashrc
root@96e6800ffbe4:~# source .bashrc
root@96e6800ffbe4:~# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

# 知乎网友Chang Liu提供的PS1配置, 这是我比较喜欢的配置了
export PS1="\[\033[38;5;87m\]\u\[$(tput bold)\]\[$(tput sgr0)\]\[\033[38;5;15m\]@\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;119m\]\h\[$(tput sgr0)\]\[\033[38;5;15m\] [\[$(tput sgr0)\]\[\033[38;5;198m\]\t\[$(tput sgr0)\]\[\033[38;5;15m\]] {\[$(tput sgr0)\]\[\033[38;5;81m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\]}\n\[$(tput sgr0)\]\[\033[38;5;2m\]--\[$(tput sgr0)\]\[\033[38;5;118m\]>\[$(tput sgr0)\]\[\033[38;5;15m\]\\$ \[$(tput sgr0)\]"
# 当设置为该配置时的效果
root@96e6800ffbe4 [21:30:41] {~}
--># ll
total 32
drwx------ 1 root root 4096 Aug 25 21:29 ./
drwxr-xr-x 1 root root 4096 Aug 25 20:02 ../
-rw------- 1 root root 1253 Aug 25 20:32 .bash_history
-rw-r--r-- 1 root root 3109 Aug 25 21:25 .bashrc
-rw-r--r-- 1 root root  148 Aug 17  2015 .profile
-rw------- 1 root root 8607 Aug 25 21:28 .viminfo
root@96e6800ffbe4 [21:31:33] {~}

# 论坛http://forum.ubuntu.org.cn/viewtopic.php?f=180&t=466064用户<恒河沙数1>提供的PS1配置, 也是我比较喜欢的一种配置
echo 'PS1="\[\033[01m\][\[\033[01;32m\]\t\[\033[00m\]\[\033[01m\]@\[\033[01;34m\]\w\[\033[00m\]\[\033[01m\]]\n\$\[\033[00m\] "' >> ~/.bashrc
souce ~/.bashrc
[10:35:29@~]
$ ll
total 36
drwx------ 1 root root 4096 Aug 27 10:33 ./
drwxr-xr-x 1 root root 4096 Aug 25 22:09 ../
-rw------- 1 root root 6814 Aug 27 10:32 .bash_history
-rw-r--r-- 1 root root 3894 Aug 27 10:34 .bashrc
-rw-r--r-- 1 root root  148 Aug 17  2015 .profile
-rw------- 1 root root 8628 Aug 27 10:33 .viminfo
[10:35:32@~]
$


# 最初出问题的时候通过下面步骤,发现PS1 和~/.bashrc中的64行的配置一致,
# 于是将64行的配置换成了别的PS1配置结局了这个问题...
# 但是其实后来我单独测试的时候, 将整个文件中的所有PS1配置全部删掉值保留case "$TERM" in xterm*|rxvt*)中的一段后发现也没问题...MMP
# 总而言是如果遇到命令不换行的时候, 换一下PS1 就对了.........

aaat@96e6800ffbe4:~# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
root@96e6800ffbe4:~# cat .bashrc | grep -in 'PS1'
6:[ -z "$PS1" ] && return
53:    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
56:    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
64:    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
root@96e6800ffbe4:~# echo $PS1
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$

# 查看系统~/.bashrc中的系统默认PS1 配置
# 这里可以发现PS1会根据不同的配置选择不同的配置方式.....

 59 if [ "$color_prompt" = yes ]; then
 60     PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
 61 else
 62     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
 63 fi
 64 unset color_prompt force_color_prompt
 65
 66 # If this is an xterm set the title to user@host:dir
 67 case "$TERM" in
 68 xterm*|rxvt*)
 69     PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
 70     ;;
 71 *)
 72     ;;
 73 esac

无法使用sudo命令

xxx is not in the sudoers file.This incident will be reported.的解决方法

1.切换到root用户下,怎么切换就不用说了吧,不会的自己百度去.

2.添加sudo文件的写权限,命令是:
chmod u+w /etc/sudoers

3.编辑sudoers文件
vim /etc/sudoers
找到这行 root ALL=(ALL) ALL,在他下面添加xxx ALL=(ALL) ALL (这里的xxx是你的用户名)

ps:这里说下你可以sudoers添加下面四行中任意一条
youuser            ALL=(ALL)                ALL
%youuser           ALL=(ALL)                ALL
youuser            ALL=(ALL)                NOPASSWD: ALL
%youuser           ALL=(ALL)                NOPASSWD: ALL

第一行:允许用户youuser执行sudo命令(需要输入密码).
第二行:允许用户组youuser里面的用户执行sudo命令(需要输入密码).
第三行:允许用户youuser执行sudo命令,并且在执行的时候不输入密码.
第四行:允许用户组youuser里面的用户执行sudo命令,并且在执行的时候不输入密码.

4.撤销sudoers文件写权限,命令:
chmod u-w /etc/sudoers

这样普通用户就可以使用sudo了.

nginx: error while loading shared libraries: XXXXX: cannot open shared object file: No such file or directory

比如我在安装NGINX时添加lua扩展时, 启动nginx报错

nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory

我使用这个命令进行解决

# /usr/local/luajit/lib是我编译luajit时通过make install PREFIX=/usr/local/luajit指定的目录
echo "/usr/local/luajit/lib" >> /etc/ld.so.conf
# 然后执行如下命令:
ldconfig

之所以报这个错是因为由于编译时没有生成动态链接库,只能手动链接

/etc/ld.so.conf详解

/etc/ld.so.conf 此文件记录了编译时使用的动态库的路径,也就是加载so库的路径。
默认情况下,编译器只会使用/lib和/usr/lib这两个目录下的库文件,而通常通过源码包进行安装时,如果不指定--prefix会将库安装在/usr/local目录下,而又没有在文件/etc/ld.so.conf中添加/usr/local/lib这个目录>。
这样虽然安装了源码包,但是使用时仍然找不到相关的.so库,就会报错。也就是说系统不知道安装了源码包。

对于此种情况有2种解决办法:
    (1)在用源码安装时,用--prefix指定安装路径为/usr/lib。这样的话也就不用配置PKG_CONFIG_PATH
    (2)直接将路径/usr/local/lib路径加入到文件/etc/ld.so.conf文件的中。在文件/etc/ld.so.conf中末尾直接添加:/usr/local/lib(这个方法给力!)

然后使用ldconfig 更新动态链接库的配置信息

ldconfig
再来看看ldconfig这个程序,位于/sbin下,它的作用是将文件/etc/ld.so.conf列出的路径下的库文件缓存到/etc/ld.so.cache以供使用,因此当安装完一些库文件,或者修改/etc/ld.so.conf增加了库的新的搜索路径,需要运>行一下ldconfig,使所有的库文件都被缓存到文件/etc/ld.so.cache中,如果没做,可能会找不到刚安装的库

Ubuntu系列下fcitx系列输入法突然失效

fcitx输入法无效,既不能用快捷键切换输入法.又不能选择输入法,备选输入法中一片空白,重装搜狗输入法也不行.

查看 /var/log/syslog系统日志,发现一堆fcitx的ERROR信息

其中包括很多,这里只列举了一个比价重要的

GDBus.Error: org.freedesktop.DBus.Error.ServiceUnknown: The name org.fcitx.Fcitx-0 was not provided by any .service files

研究了很長時間,現在終於解決了,刪除`/.config文件夾裏面的fcitx即可,

在终端里面敲fcitx -d如果出现了DBus Service Already Exists的报错,重新安装sudo apt-get install --resintall fcitx-fontend-gtk2 fctix-fontend-gtk3就行了

转载于:https://my.oschina.net/chinaliuhan/blog/3065298

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值