学习笔记,防止自己忘掉。

练习VIM

使用yum install vim安装,然后按照菜鸟教程进行练习

https://www.runoob.com/linux/linux-vim.html

随便练习下:
练习VIM

SCP

scp是自带的,不用安装,菜鸟教程上也有:

https://www.runoob.com/linux/linux-comm-scp.html

[root@oseasy ~]# yum install scp

已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirror.sjtu.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
没有可用软件包 scp。
错误:无须任何处理

开两台虚拟机,可以通信。

[root@oseasy ~]# ping 192.168.6.131
PING 192.168.6.131 (192.168.6.131) 56(84) bytes of data.
64 bytes from 192.168.6.131: icmp_seq=1 ttl=64 time=0.645 ms
64 bytes from 192.168.6.131: icmp_seq=2 ttl=64 time=0.389 ms
^C
--- 192.168.6.131 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.389/0.517/0.645/0.128 ms

使用scp传输一个文件看看:

[root@oseasy ~]# scp -r test root@192.168.6.131:/root/ceshi
The authenticity of host '192.168.6.131 (192.168.6.131)' can't be established.
ECDSA key fingerprint is SHA256:wBy6gx7dz21POJvSsj6vLR6xKzJ6xeZT9XaTF2Z+NJQ.
ECDSA key fingerprint is MD5:08:29:f1:db:65:32:3d:a6:69:e2:bc:12:22:f2:15:e6.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.6.131' (ECDSA) to the list of known hosts.
root@192.168.6.131's password: 
test                                                               100%    6     6.1KB/s   00:00    
[root@oseasy ~]# 

在第二台机器上看看

[root@oseasy ~]# ls
anaconda-ks.cfg  ceshi
[root@oseasy ~]# ls ceshi
test
[root@oseasy ~]# 

传输成功。

rsync

建议查看官方文档:

https://www.samba.org/ftp/rsync/rsync.html

需要使用:yum install rsync安装rsync
先删掉192.168.6.131机器上的文件,然后使用,对了,密码应该是你用户密码,比如root:

[root@oseasy ~]# rsync -r test 192.168.6.131:/root/test
root@192.168.6.131's password: 
Permission denied, please try again.
root@192.168.6.131's password: 
Permission denied, please try again.
root@192.168.6.131's password: 
[root@oseasy ~]#

第二台机器就获得了文件:

[root@oseasy ~]# ls
anaconda-ks.cfg  ceshi
[root@oseasy ~]# rm -rf ceshi
[root@oseasy ~]# ls
anaconda-ks.cfg
[root@oseasy ~]# ls
anaconda-ks.cfg  test
[root@oseasy ~]#

我这是最简单的应用,复杂的应用需要百度看文档来配置

linux挂载Windows文件夹

我以前都是用的rclone,没想到mount也可以用来挂载smb
先在Windows下创建一个smb共享文件夹,验证可以访问后,可以在linux下执行,只不过这里是需要用ip访问(smb与CIFS互相兼容)。

mkdir /home/smb
sudo mount -t cifs -o vers=2.0,_netdev,username=cold,password=cold,uid=1000,gid=1000 //192.168.6.130/Users/cold/linux /home/smb

如果用老师的方法可能会提示:mount: 将 //192.168.6.130/Users/cold/linux 挂载到 /home/smb 失败: 主机关闭,而用tcping查看却发现445端口是开的,192.168.6.130 port 445 open.这是因为微软的Windows10默认不再支持smb1.0,而mount默认是从smb1.0访问的,这就导致了错误,因此需要手动指定版本。老师可能是接的群晖的smb

如果有中文目录,还得iocharset=utf8参数,例如 -o iocharset=utf8,username=Windows共享用户名,password=密码
又是百度搜不到的内容
linux挂载smb

打包

/etc/sysconfig/network-scripts目录下所有文件打包 /root/netbak.tar

cd /etc/sysconfig/
tar -cf /root/netbak.tar network-scripts

如下所示:

[root@oseasy sysconfig]# ls -a /root
.   anaconda-ks.cfg  .bash_logout   .bashrc  .pki  .tcshrc  .viminfo
..  .bash_history    .bash_profile  .cshrc   .ssh  test
[root@oseasy sysconfig]# cd /etc/sysconfig/
[root@oseasy sysconfig]# tar -cf /root/netbak.tar network-scripts
[root@oseasy sysconfig]# ls -a /root
.   anaconda-ks.cfg  .bash_logout   .bashrc  netbak.tar  .ssh     test
..  .bash_history    .bash_profile  .cshrc   .pki        .tcshrc  .viminfo
[root@oseasy sysconfig]# 

如果使用:

[root@oseasy ~]# tar -cf /root/netbak.tar /etc/sysconfig/network-scripts/
tar: 从成员名中删除开头的“/”

提示报错是因为这样操作会造成压缩文件在解压缩时很可能将原文件进行覆盖,就算不会覆盖,也可能造成系统错乱,尤其是“/etc”等这些非常敏感的目录。

磁盘性能检测

dd磁盘检测用这个教程就行了:https://it.ismy.fun/2018/09/16/linux-hard-drive-test-with-dd/

注意,以下命令可能不存在设备,自行修改即可

例如:

    [root@oseasy ~]# time dd if=/dev/zero of=testw.dbf bs=4k count=100000
    记录了100000+0 的读入
    记录了100000+0 的写出
    409600000字节(410 MB)已复制,11.6163 秒,35.3 MB/秒

real    0m11.625s
user    0m0.015s
sys    0m1.170s

简单对比就行了,其实我更喜欢用dd来dd系统。

nmon

centos不自带nmon,所以用:

yum install nmon

照着提示来就行了。

nmon

搞定。


参考:
Linux vi/vim
Linux scp命令
rsync
rsync:基本命令和用法
Linux中通过mount或smbmount直接挂接Windws中文共享目录
挂载CIFS主机已关闭
tar时报错:从成员名中删除开头的"/"
Linux 下 DD 命令硬盘测速

最后修改:2021 年 01 月 13 日
如果觉得我的文章对你有用,请随意赞赏