linux常用的小命令

查看linux版本

uname -a

图上可知,linux内核版本为2.6.32

查看cpu核数

cat /proc/cpuinfo |grep "cores"| uniq

系统中查找文件

root@ubuntu:~# find / -name 'nginx'

使用locate可以查看相关文件名

[shichaogeng@study vitest]$ locate jdk

 日志处理:日志处理--高效Linux命令整理

ssh命令

只需要用户名和主机ip就能连接了

# 命令

ssh user@ip

# 例子

[root@localhost ~]# ssh root@192.168.25.139
root@192.168.25.139's password:
Last login: Mon Sep 18 05:50:11 2017 from 192.168.25.143

还可以指定端口(默认端口22)

ssh -p 33033 user@ip

直接在远程服务器执行命令

[root@localhost ~]# ssh root@192.168.25.139 echo $PATH
root@192.168.25.139's password: 
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

这个功能不错

我也是在网上找的,更具体的参见https://linux.cn/article-3858-1.html

scp在linux服务器之间拷贝数据

 scp是有Security的文件copy,基于ssh登录。操作起来比较方便,比如要把当前一个文件copy到远程另外一台主机上,可以如下命令。

# 拷贝到远程目录下
scp local_file remote_username@remote_ip:remote_folder

实验下吧,先建立个文件

[root@localhost ~]# vim test.file

然后执行scp

[root@localhost ~]# scp test.file root@192.168.25.139:/root
root@192.168.25.139's password: 
test.file                            

目标服务器看下

[root@localhost ~]# ssh root@192.168.25.139 ls -a test*
root@192.168.25.139's password: 
test.file

有了

如果想从远程scp到本地,只需要对调下参数

scp remote_username@remote_ip:remote_folder local_file

如果是文件夹,可以加 -r参数

原文地址:https://www.cnblogs.com/gengsc/p/6826553.html