Linux学习(一)基础

202 阅读1分钟

一、基础命令

  1. 上传文件

scp ./test.txt root@111.111.111.111:/root

把本地当前目录下的 test.txt 文件上传到 root 用户的根目录 root 文件夹下。

  1. 下载软件

yum install nano

  1. 查看服务状态

systemctl status nginx

  1. 停止服务

systemctl stop nginx

  1. 开启服务

systemctl start nginx

  1. 重启服务

systemctl restart nginx

  1. 创建文件 test.txt 并将 hello world! 写入

echo “hello world!” > test.txt

  1. 网卡位置

/etc/sysconfig/network-scripts 下面的 ifcfg-eth0 文件

  1. 查看网络地址

ip route

  1. 端口相关
  • 查看打开了多少

netstat

ss

ss -an

  • 查看其中某个端口

ss -an | grep 80

  • 查看其中占用端口的进程

ss -anp | grep 80

  • 干掉进程(一般来说,pid 数字较小的是主进程)

kill - [pid]

pkill [nginx]

  1. 下载
  • 服务器的时间戳

wget www.baidu.com

  • 本地的时间戳

curl www.baidu.com -o test.html

  1. 手册

man [命令]

  1. 任务管理器

top

  1. 跑了哪些进程

ps aux

ps aux | grep ngnix

  1. 哪些用户登陆了服务器

w

  1. 登陆服务器历史

last

  • 只显示 10 条

last -n 10

  • 登录失败的记录

lastb

二、control 相关

  • 不小心 control + s 了怎么办?

control + s 是锁定终端的意思,这时候需要用 control + q 解锁

  • 清屏

control +l

  • 结束输入或退出 shell

control + d

  • 光标快速移动到开头/结尾

control + a / control + e

三、安装 Node.js

添加官⽅的yum源

curl -sL rpm.nodesource.com/setup_11.x | bash -

yum命令安装

yum install -y nodejs

PS : mac 是 BSD 内核