linux常用命令
- yum安装
- vim编辑器
- sudo root身份
- su (用户名)进行切换用户
安装部分
安装Ubuntu正常安装
- 启动Ubuntu失败 ,提示 please remove the installation
右键选项卡 shut off 关机
在设置里把这个取消勾选
安装vmtools
- 左上角,vm-vmtools安装
- 右键复制到桌面,解压
cd vmware-tools-distrib sudo ./vmware-install.pl
- 重启之后右上角设置自适应
特点: 可以拖文件进去
前置安装
-
安装python3
sudo apt-get install python3.6
此时打开的默认是python2,需要改一下源
sudo cp /usr/bin/python /usr/bin/python_bak sudo rm /usr/bin/python sudo ln -s /usr/bin/python3.6 /usr/bin/python
- 通过执行倒数一二句命令可以换python版本
-
安装pip3
- 先安装pip脚本
这个链接可以根据接下来安装pip是否报错,若报错,则是版本不符合,按照提示的链接修改这条命令即可 curl https://bootstrap.pypa.io/pip/3.6/get-pip.py -o get-pip.py python get-pip.py
-
安装mysql、mariadb
apt-get install mariadb-server service mysql start
强制登录
-
安装yum步骤 先配置镜像源!:
1、sudo apt install yum
创建配置目录
2、sudo mkdir /etc/yum.repos.d
创建配置源
3、sudo vi /etc/yum.repos.d/CentOS-Base.repo
输入:
# CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-7.9.2009 - Base failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/7.9.2009/os/$basearch/ http://mirrors.aliyuncs.com/centos/7.9.2009/os/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/7.9.2009/os/$basearch/ https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/os/$basearch/ enabled=1 gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-7.9.2009 - Updates failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/7.9.2009/updates/$basearch/ http://mirrors.aliyuncs.com/centos/7.9.2009/updates/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/7.9.2009/updates/$basearch/ https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/updates/$basearch/ enabled=1 gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-7.9.2009 - Extras failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/7.9.2009/extras/$basearch/ http://mirrors.aliyuncs.com/centos/7.9.2009/extras/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/7.9.2009/extras/$basearch/ https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/extras/$basearch/ enabled=1 gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-7.9.2009 - Plus failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/7.9.2009/centosplus/$basearch/ http://mirrors.aliyuncs.com/centos/7.9.2009/centosplus/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/7.9.2009/centosplus/$basearch/ https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #contrib - packages by Centos Users [contrib] name=CentOS-7.9.2009 - Contrib - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/7.9.2009/contrib/$basearch/ http://mirrors.aliyuncs.com/centos/7.9.2009/contrib/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/7.9.2009/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
生成缓存 每次开机都要重新挂载
yum makecache
如果还报错:
- 先切换为root
- sudo apt-get install vim
- 查看当前有的版本号:whereis python
- vim /usr/bin/yum,修改第一行:#!/usr/bin/python,在后面加上系统种安装的python2版本号,保存。
- vim /usr/libexec/urlgrabber-ext-down 修改第一行:#!/usr/bin/python,在后面加上系统种安装的python2版本号,保存。 注:这一行没有就不改
-
yum gcc
按道理ubuntu是不yum的 很不合理,先用这个试试sudo apt update # 通过以下命令安装编译器和调试器,gdb是Linux下常用的程序调试器 sudo apt install build-essential gdb # 如果成功,则显示版本号 gcc --version g++ --version gdb --version
-
安装那几个包的时候用root安 (sudo -s)
-
改进Nginx安装方法:
-
sudo apt-get install nginx 就这一句
-
然后 nginx -v 查看版本是否安装成功
-
之后继续执行文档中的修改配置文件(最后一行需要加个"}")等内容
-
报错
解决方法:sudo useradd nginx -G www-data (加上conf文件里第一行后user的内容) -
文件夹作用
Nginx安装报错(文档方法)
修改Nginx包下/objs/Makefile 大概第二三行,有一个-Werror,把这个删除
要把安装命令拆分成三个部分./config 执行完config之后,开两个终端,一个终端vim修改makefile,然后esc :w保存不退出,另一个终端执行make即可 make make install
make之后要执行下图第一个语句,之后语句检验出当下结果则正确
ln -s /usr/local/nginx/sbin/nginx /usr/bin/ ll /usr/bin/nginx
此时访问localhost:80会500,是用户的问题,去刚才配置的那个地方把第一行user改为root
修改以后会报403forbidden,是因为配置文件里index目录没加上,在var/www/html里找到加到配置文件index之后即可,这个别改,用用户手册里的 不然之后还要改之后每次重启都要这么一下
-
启动部分
-
pipnv需要 pip install pipnv一下
-
在运行环境里
-
sudo pip install flask ;
-
pymysql;
-
requests;
-
tldextract;
-
numpy;
-
scipy;
-
nltk3.4.4;
-
pandas;
-
matplotlib;
-
pip install scikit-learn;
-
simplejson;
-
jparser;
-
urlparse(这个需要到/home/wang/.local/share/virtualenvs/Python_back-c4TAEY-Z/lib/python3.7/site-packages/jparser/model.py 下把import urlparse改成from urllib.parse import urlparse);
-
newspaper3k;
-
chardet;
-
execjs(pip install PyExecJS );
-
googletrans(/home/wang/.local/share/virtualenvs/Python_back-c4TAEY-Z/lib/python3.7/site-packages/jparser/model.py下将 12行assert那一行的unicode改为str);
-
flask_cors
-
下图是下载之后这些包存在虚拟环境的路径,记录一下
-
nohup里缺啥模块就install啥,pipenv shell进去环境再pip install
-
后端爬虫,mysql需要建数据库net 然后执行sql语句。
root用户下:mysql use secu; source /sql/net.sql
-
还要把file.py文件里的
改成这种形式 db = pymysql.connect(host=‘’,user=‘’,password=‘’,db=‘’) -
前端先sudo install npm
-
然后npm install
-
https://devpress.csdn.net/linux/62ed0f6419c509286f417e36.html 如何彻底删除npm
-
开始编译,not found什么就npm i @什么
-
运行好之后去前端网页访问,tmmd,爽爆了说是。
-
记得这块不能用localhost,要ifconfig查到自己的ip,然后输进去
问题
-
E: 无法获得锁 /var/lib/dpkg/lock-frontend - open (11: 资源暂时不可用)
强制解锁即可sudo rm 上面无法获得锁的目录
-
No module named ‘distutils.cmd’
sudo apt-get install python3.6-distutils
-
安装mysql运行时报错
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)
点击链接 -
pipenv找不到命令:
-
先下载pip3
sudo apt install python3-pip
sudo -H pip install -U pipenv -
node报错:node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28’ not found (required by node)
解决:wget http://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.xz tar -xvf glibc-2.35.tar.xz cd glibc-2.35 mkdir build cd build ../configure --prefix=/usr/glibc2.25 make -j16 sudo make install
-
configure: error:
*** These critical programs are missing or too old: bison
*** Check the INSTALL file for required versions.sudo apt install gawk sudo apt install bison
-
Command ‘nodejs’ not found, but can be installed with:
· -
卸载包:
sudo apt-get remove xxx -
下列软件包有未满足的依赖关系: nodejs : 依赖: libc6 (>= 2.28) 但是 2.27-3ubuntu1.6 正要被安装
这么整
大概就是换镜像源 然后源链接要对应ubuntu版本 -
mysql建表报错:
把net.sql里所有的utf8mb4_0900_ai_ci都换成utf8_general_ci utf8mb4全换成utf8,然后在secu里跑net.sql即可 -
输密码没报错但是登不上,把前端项目config/index.html文件里的localhost全部替换成ifconfig后获得的ip
-
爬虫需要科学up网
-
xray
wget https://github.com/XTLS/Xray-install/raw/main/install-release.sh sudo chmod u+x install-release.sh sudo ./install-release.sh