Ubuntu 12.04

启用root用户:sudo passwd root 注:输入密码是不会回显的

修改主机名:vi /etc/hostname 修改 hosts:vi /etc/hosts

查看所有用户(每行开头就是):cat /etc/passwd 创建用户:useradd username 设置密码:passwd username 删除密码:passwd -d username 删除用户:userdel -r username(-r 包括邮件和工作目录)

linux卸载软件 当我们知道软件的名称,那么我们就直接在终端命令窗口中输入命令就可以了: sudo apt-get remove --purge 软件名 注:--purge 选项表示彻底删除改软件和相关文件

修改显示语言:vi /etc/default/locale LANG="zh_CN.UTF-8" LANG="en_US.UTF-8"

注销:exit,logout 关机:shutdown -h 0,init 0,halt,poweroff 重启:shutdown -r 0,reboot,init 6

查看已登录用户:who 注:tty1是本机终端号,pts/0是远程终端 查看自己是哪个:tty 强制用户下线:pkill -t tty1

个性化命令:vi ~/.bashrc

开机自启:/etc/rc.local

查看是否安装了ssh server: ssh -version

设置ip:vi /etc/network/interfaces 环回网卡:

动态:

静态:

子接口:

DNS: 在开机自启:/etc/rc.local文件中添加 echo "nameserver 208.67.220.220″ >> /etc/resolv.conf

DNS服务器地址,开机时会写入到 /etc/resolv.conf nameserver 58.22.96.66

查看DNS: nslookup domain [dns-server] 前2行就是DNS服务器 root@ubuntu:~# nslookup www.baidu.com Server: 127.0.0.53 Address: 127.0.0.53#53

启动网卡: ifconfig eth0 up 关闭网卡为: ifconfig eth0 down

重启网络服务: 1./etc/init.d/networking restart 2.service networking restart 3.ifconfig eth0 down && ifconfig eth0 up.

 

创建临时网卡子接口:

ip addr add 192.168.1.249/24 dev eth0 label eth0:0

ifconfig eth0:0 192.168.1.249/24

 

源的位置: /etc/apt/sources.list

更新deb包路径: /var/cache/apt/archives

[解决]E: Sub-process /usr/bin/dpkg returned an error code (1)

本帖最后由 bunny 于 2013-8-28 17:16 编辑

安装包的时候会报错 E: Sub-process /usr/bin/dpkg returned an error code (1)错误。

第一种方法: mv /var/lib/dpkg/info /var/lib/dpkg/info2 mkdir /var/lib/dpkg/info apt-get update -f apt-get -f install 第二种方法: for i in /usr/share/fonts/X11/* /usr/share/fonts/truetype/* do sudo touch "$i" done 第三种方法: sudo apt-get update --fix-missing sudo apt-get autoremove && sudo apt-get clean && sudo apt-get install -f http://www.ubuntukylin.com/ukylin/forum.php?mod=viewthread&tid=3789

E: Sub-process /usr/bin/dpkg returned an error code (1)错误解决

在用apt-get安装软件时出现了类似于 install-info: No dir file specified; try --help for more information.dpkg:处理 gettext (--configure)时出错: 子进程 post-installation script 返回了错误号 1 在处理时有错误发生: findutils E: Sub-process /usr/bin/dpkg returned an error code (1) 办法如下: 1.$ sudo mv /var/lib/dpkg/info /var/lib/dpkg/info_old //现将info文件夹更名 2.$ sudo mkdir /var/lib/dpkg/info //再新建一个新的info文件夹 3.$ sudo apt-get update, $ apt-get -f install //不用解释了吧 4.$ sudo mv /var/lib/dpkg/info/* /var/lib/dpkg/info_old //执行完上一步操作后会在新的info文件夹下生成一些文件,现将这些文件全部移到info_old文件夹下 5.$ sudo rm -rf /var/lib/dpkg/info //把自己新建的info文件夹删掉 6.$ sudo mv /var/lib/dpkg/info_old /var/lib/dpkg/info //把以前的info文件夹重新改回名字 到此问题顺利解决 http://www.cnblogs.com/jary-wang/archive/2013/05/28/3103829.html

Ubuntu:解决非官方源导致的GPG error

当我们在/etc/apt/sources.list中加入非Ubuntu官方源来安装、更新部分软件时,sudo apt-get update会有错误提示。 W: GPG error: http://ppa.launchpad.net precise Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 976B5901365C5CA1

做两部操作可以解决

gpg --keyserver keyserver.ubuntu.com --recv 16126D3A3E5C1192;\ gpg --export --armor 16126D3A3E5C1192 | sudo apt-key add -

subkeys.pgp.net

Recovery mode(不安全的单体模式) 在grub界面选择第二项修复,但没有grub可以参考: 1、重启ubuntu,随即长按shirft进入grub菜单; 2、选择recovery mode,按"e"键进入编辑页面; 3、将ro recovery nomodeset/ro single替换为rw single init=/bin/bash; (上述的界面中将改为rw single init=/bin/bash) 4、按ctrl+x进入单用户模式,当前用户即为root; 5、按ctrl+alt+del重启;

waiting for network configuration waiting 60s for network configuration /etc/init/failsafe.conf文件中给这两个sleep函数注释掉就行了。不过可能导致不能自动连接,可以改成5或者10。

解决Ubuntu/debian的Apt-get 由于依赖关系安装失败的问题

由于ubuntu/debian软件库中有时候不同的库更新速度不一致,apt-get 出出现如下的错误提示

The following packages have unmet dependencies:

......

这个时候应该请令一个工具出马了:"aptitude"

使用这个工具,当某个库依赖的库与当前版本不一致时,aptitude 会尝试降级当前这个库的版本,同时解决降级这个库对其它软件的依赖性的影响, 最终成功安装apt-get 没法安装的软件

PS:apt-get -f install中的-f参数只是强制安装,无视依赖,并不是说解决依赖。能自动解决的还要你加毛选项。 除非你知道自己在做什么,否则永远不要用 -f 选项!

Ubuntu 14.04

默认网卡名不再是eth0,eth1。 所以,要用ifconfig -a查看网卡设备,再改IP。

静态:

重启网络: ifdown p5p1 && ifup p5p1

Ubuntu Server 14.04 下root无法ssh登陆 原来新版本里面sshd_config里面有了限制

Ubuntu 18.04

nmtui nmcli