Ubuntu安装配置

1 解锁apt(一般不会有)

如果出现无法运行apt命令,提示E: Could not get lock /var/lib/dpkg/lock(无法获得锁),可以运行以下命令:

sudo rm /var/cache/apt/archives/lock sudo rm /var/lib/dpkg/lock 

2 更改至清华源

1) 执行命令:

sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak sudo touch /etc/apt/sources.list sudo gedit /etc/apt/sources.list 

2) 添加内容如下:

ubuntu16

deb http://mirrors.aliyun.com/ubuntu/ xenial main deb-src http://mirrors.aliyun.com/ubuntu/ xenial main deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main deb http://mirrors.aliyun.com/ubuntu/ xenial universe deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe deb http://mirrors.aliyun.com/ubuntu/ xenial-security main deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe 

ubuntu18

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse 

ubuntu20

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse 

ubuntu22

deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse 

3) 添加完毕后执行命令:

sudo apt-get update sudo apt-get upgrade 

3 安装vim

sudo apt-get purge vim-common sudo apt-get update sudo apt-get upgrade sudo apt-get install vim 

4 VIM配置

1) VIM插件
链接:https://pan.baidu.com/s/1LeMfAr6_3suClaWjFpi-5w
提取码:3bvf
2) VIM背景颜色配置
颜色文件存放于/usr/share/vim/vim73/colors/,比如:

blue.vim default.vim desert.vim evening.vim koehler.vim murphy.vim peachpuff.vim ron.vim slate.vim azellner.vim darkblue.vim delek.vim elflord.vim industry.vim morning.vim pablo.vim shine.vim torte.vim 

可以在vim中可以用 :colorscheme 命令查看当前配色模式,用 :colorscheme default修改(default模式),也可以在.vimrc文件中添加语句 colors default,一直生效。

5 安装ssh

1) 执行命令:

sudo apt-get install openssh-server 

2) 在 /etc/ssh/sshd_config 文件后面添加:

PermitRootLogin yes 

3) 用下面的命令查看ssh是否启动,有sshd,说明ssh服务已经启动:

ps -e|grep ssh sudo service ssh start  

4) ssh服务端的默认端口时22,所以要确保22号端口对客户机时开放的,如果打开了防火墙,需要将该端口设为开放,可以参考另一篇文章中的1.4节内容,也可以参照下面的命令:

sudo ufw status  sudo ufw allow 22   

6 cmake

sudo apt install cmake sudo apt install cmake-qt-gui 

执行 cmake-gui 即可启动 cmake 的图形界面;

7 禁用设备

方法一:

在/etc/modprobe.d/下创建文件usb.conf,添加内容install usb-storyage /bin/true;

方法二:

重命名驱动文件名,即/lib/modules/…/kernel/drivers/usb/storage/usb_storge.ko,禁用时把这个文件重命名为其他的名称就行,取消禁用就把名字改回来,重启生效;

执行lshw指令,列出当前设备信息,找到network那一栏,下面有configuration的描述,记下driver所对应的值,如:r8188eu,然后在/etc/modprobe.d/blacklist.conf文件中添加语句:blacklist r8188eu,重启生效;

注:lspci -tv列出所有pci设备,lsusb -tv列出所有usb设备;

8 添加、删除用户

  • 创建用户
    useradd -m -s /bin/bash tanrui 
  • 更改密码
    passwd tanrui 
  • 设置权限
    如果要给用户管理员权限,可以修改 /etc/sudoers 文件:
    tanrui ALL=(ALL:ALL) ALL 
sudo userdel xxx  

在文件 /etc/passwd 中查看该用户是否被删除

Linux将用户名修改后,还需要修改 组名 + 家目录 + UID;
注意: 你需要从要改名的帐号中登出并杀掉该用户的所有进程,要杀掉该用户的所有进程可以执行下面命令:

$ sudo pkill -u 旧用户名 $ sudo pkill -9 -u 旧用户名 
  • 1 修改用户名

    $ usermod -l 新用户 旧用户 

    这只会更改用户名,而其他的东西,比如用户组、家目录、ID 等都保持不变。

  • 2 修改家目录

    $ sudo usermod -d /home/新用户名 -m 新用户名 
  • 3 修改组名

    $ groupmod -n 新用户名 旧用户名 
  • 4 修改UID

    $ sudo usermod -u 1000 新用户名 
  • 5 检查

    $ id 新用户名 

原文链接:https://blog.csdn.net/qq_33236581/article/details/91308974

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享