linux 常用命令

1. 软件安装与卸载

  (1) 二进制安装:直接解压使用

  (2) rpm安装
  安装:rpm -ivh xxx.rpm
  卸载:rpm -evh xxx

  (3) yum安装
  安装:yum install xxx
  卸载:yum remove xxx

  (4) dpkg安装
  安装:dpkg -i xxx.deb
  卸载:dpkg -r xxx.deb

  (5) apt-get安装
  安装:apt-get install xxx
  卸载:apt-get remove xxx

  (6) 源码编译安装
  ./configure --prefix=./test
  make && make install

2. 压缩与解压

  (1) tar包
  压缩:tar -cvf test.tar ./test
  解压:tar -xvf test.tar

  (2) tar.gz包
  压缩:tar -zcvf test.tar.gz ./test
  解压:tar -zxvf test.tar.gz

  (3) tar.bz2包
  压缩:tar -jcvf test.tar.bz2 ./test
  解压:tar -jxvf test.tar.bz2

  (4) zip包
  压缩:zip -r test.zip ./test
  解压:unzip test.zip

  (5) gzip包
  压缩:gzip fileName
  解压:gzip -d fileName.gz

  (6) bzip2包
  压缩:bzip2 fileName
  解压:bzip2 -d fileName.bz2

3. 配置环境变量

  (1) export PATH=PATH:/usr/local/node/bin(临时有效)

  (2) vim ~/.bashrc
  #在最后一行加上
  export PATH=$PATH:/usr/local/node/bin
  #保存后执行
  source ~/.bashrc(永久有效,仅对当前用户有效)

  (3) vim ~/.bash_profile(永久有效,仅对当前用户有效,部分系统为~/.profile)
  (4) vim /etc/bashrc(永久有效,对所有用户有效)
  (5) vim /etc/profile(永久有效,对所有用户有效,部分系统为/etc/bash_profile)
  (6) vim /etc/environment(永久有效,对所有用户有效)

4. 服务管理

  (1) 启动服务
  systemctl start mysqld
  (2) 查看服务状态
  systemctl status mysqld
  (3) 使某服务开机自启
  systemctl enable mysqld
  (4) 关闭某服务开机自启
  systemctl disable mysqld

5. 服务器远程上传与下载

  (1) 连接远程服务器
  ssh -p 22 远程用户名@远程机器IP

  (2) 上传文件到远程服务器
  scp -P 22 本地路径 远程用户名@远程机器IP:远程路径

  (3) 下载文件到本地
  scp -P 22 远程用户名@远程机器IP:远程路径 本地路径

6. 配置ssh key

  (1) 检查是否存在ssh key
  cd ~/.ssh && ls
  (2) 生成ssh key
  ssh-keygen -t rsa -C "xxx@xxx.com"
  (3) 查看ssh key公钥
  cat id_rsa.pub
  (4) 将ssh key公钥添加到远程主机

参考:https://blog.csdn.net/weixin_45682261/article/details/122895651

          https://www.linuxcool.com/

posted @ 2021-11-13 22:05  叶森白  阅读(34)  评论(0编辑  收藏  举报