远程控制与数据库安全

远程控制与数据库安全

实验准备

软件:VMware Workstation Pro
虚拟机:Red Hat Enterprise Linux 7 服务器,Red Hat Enterprise Linux 7 客户端
网络模式:NAT模式

1、配置服务器及客户端网络
在这里插入图片描述
服务器ip

[root@localhost 桌面]# ifconfig 
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.13.131  netmask 255.255.255.0  broadcast 192.168.13.255
        inet6 fe80::20c:29ff:feb8:5c2f  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:b8:5c:2f  txqueuelen 1000  (Ethernet)
        RX packets 171  bytes 13044 (12.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 97  bytes 10353 (10.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 262  bytes 22320 (21.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 262  bytes 22320 (21.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

客户端ip

[root@localhost 桌面]# ifconfig 
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
       inet 192.168.13.132  netmask 255.255.255.0  broadcast 192.168.13.255
       inet6 fe80::20c:29ff:fedd:7c41  prefixlen 64  scopeid 0x20<link>
       ether 00:0c:29:dd:7c:41  txqueuelen 1000  (Ethernet)
       RX packets 35  bytes 3366 (3.2 KiB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 30  bytes 3693 (3.6 KiB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
       inet 127.0.0.1  netmask 255.0.0.0
       inet6 ::1  prefixlen 128  scopeid 0x10<host>
       loop  txqueuelen 0  (Local Loopback)
       RX packets 262  bytes 22320 (21.7 KiB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 262  bytes 22320 (21.7 KiB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
1、设置镜像,配置yum源
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/5c1782d0122140c0be8c70114c9cec2f.png)
连接cd小光标
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/671ee0fc634940bdb8d2e80736df8b51.png)
```java
[root@localhost 桌面]# mkdir /mnt/cdrom
[root@localhost 桌面]# mount /dev/sr0 /mnt/cdrom/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost 桌面]# vim /etc/yum.repos.d/a.repo
[root@localhost 桌面]# cat /etc/yum.repos.d/a.repo 
[a]
name=a
baseurl=file:///mnt/cdrom
enable=1
gpgcheck=0
[root@localhost 桌面]# yum repolist 
已加载插件:langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
a                                                                                                                                                                     | 4.1 kB  00:00:00     
(1/2): a/group_gz                                                                                                                                                     | 134 kB  00:00:00     
(2/2): a/primary_db                                                                                                                                                   | 3.4 MB  00:00:00     
源标识                                                                                        源名称                                                                                    状态
a                                                                                             a                                                                                         4,305
repolist: 4,305
[root@localhost 桌面]# yum install mariadb mariadb-server -y
[root@localhost 桌面]# systemctl start  mariadb
[root@localhost 桌面]# systemctl status mariadb.service 
mariadb.service - MariaDB database server
  Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled)
  Active: active (running) since 四 2024-05-09 11:06:54 CST; 2min 26s ago
 Process: 13706 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
 Process: 13627 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Main PID: 13705 (mysqld_safe)
  CGroup: /system.slice/mariadb.service
          ├─13705 /bin/sh /usr/bin/mysqld_safe --basedir=/usr

在完成MariaDB数据库软件程序的安装并确保其成功启动后,我们建议先不要急于使用它。为了保障数据库的安全性和稳定运行,首要任务是进行初始化操作。该初始化流程包含以下五个关键步骤:
设置root管理员在数据库中的密码值(该密码并非root管理员在系统中的密码,密码值默认为空,直接回车即可)。

设置root管理员在数据库中的专有密码。

删除匿名用户,并使用root管理员从远程登录数据库,以确保数据库上运行的业务的安全性。

删除默认的测试数据库,取消测试数据库的一系列访问权限。

刷新授权列表,让初始化的设定立即生效。

[root@localhost 桌面]# mysql_secure_installation 
/usr/bin/mysql_secure_installation:379: find_mysql_client: 未找到命令

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 输入管理员原始密码,默认为空值,直接回车即可
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y(设置管理员密码)
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y(删除匿名账户)
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y(禁止管理员从远程登录)
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y(删除测试数据库及其访问权限)
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y (刷新授权表,让初始化后的设定立即生效)
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
 在众多生产环境的实践中,站库分离技术(即将网站与数据库部署于不同的服务器)被广泛应用以确保系统的高可用性和安全性。当需要为root管理员提供远程访问数据库的权限时,我们需要在初始化过程中制定相应的策略,以允许root管理员从远程地址进行连接。此外,为了保障数据库服务的安全,还需配置防火墙规则,确保其对数据库服务程序(如MySQL,默认占用3306端口)的访问请求进行放行。在防火墙策略中,这类服务通常被统一标识为“mysql”。

[root@localhost 桌面]# firewall-config
在这里插入图片描述
首次登录MariaDB数据库。为了管理数据库,我们将使用mysql命令。在这个命令中,-u参数用于指定以root管理员的身份进行登录,-p用来验证该用户在数据库中的密码值,以确保登录的安全性。

[root@localhost 桌面]# mysql -u root -p
Enter password: 输入刚刚设置的密码
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.35-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SHOW databases;                 //查看数据库管理系统中当前都有哪些数据库
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
MariaDB [(none)]> SET password = PASSWORD('hnswjj');    //使用数据库命令将root管理员在数据库管理系统中的密码值修改为hnswjj
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye
使用原密码redhat尝试登陆,登陆失败。
[root@localhost 桌面]# mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
使用新密码hnswjj尝试登陆,登陆成功,创建用户student,admin,jack;
[root@localhost 桌面]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 5.5.35-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>  CREATE USER student@localhost IDENTIFIED BY 'redhat';
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]>  CREATE USER admin@localhost IDENTIFIED BY 'redhat';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]>  CREATE USER jack@localhost IDENTIFIED BY 'redhat';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> SELECT HOST,USER,PASSWORD FROM user WHERE USER="student"MariaDB [mysql]> SELECT HOST,USER,PASSWORD FROM user WHERE USER="student";
+-----------+---------+-------------------------------------------+
| HOST      | USER    | PASSWORD                                  |
+-----------+---------+-------------------------------------------+
| localhost | student | *55D9962586BE75F4B7D421E6655973DB07D6869F |
+-----------+---------+-------------------------------------------+
1 row in set (0.00 sec)

MariaDB [mysql]> SELECT HOST,USER,PASSWORD FROM user WHERE USER="admin";
+-----------+-------+-------------------------------------------+
| HOST      | USER  | PASSWORD                                  |
+-----------+-------+-------------------------------------------+
| localhost | admin | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
+-----------+-------+-------------------------------------------+
1 row in set (0.00 sec)

MariaDB [mysql]> SELECT HOST,USER,PASSWORD FROM user WHERE USER="jack";
+-----------+------+-------------------------------------------+
| HOST      | USER | PASSWORD                                  |
+-----------+------+-------------------------------------------+
| localhost | jack | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
+-----------+------+-------------------------------------------+
1 row in set (0.00 sec)
MariaDB [mysql]>  SHOW GRANTS FOR student@localhost;
+----------------------------------------------------------------------------------------------------------------+
| Grants for student@localhost                                                                                   |
+----------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'student'@'localhost' IDENTIFIED BY PASSWORD '*55D9962586BE75F4B7D421E6655973DB07D6869F' |
+----------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

查看student用户权限,并针对mysql数据库中的user表单向用户luke授予查询、更新、删除以及插入等权限;

MariaDB [mysql]> GRANT SELECT,UPDATE,DELETE,INSERT ON mysql.user TO student@localhost;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]>  SHOW GRANTS FOR student@localhost;
+----------------------------------------------------------------------------------------------------------------+
| Grants for student@localhost                                                                                   |
+----------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'student'@'localhost' IDENTIFIED BY PASSWORD '*55D9962586BE75F4B7D421E6655973DB07D6869F' |
| GRANT SELECT, INSERT, UPDATE, DELETE ON `mysql`.`user` TO 'student'@'localhost'                                |
+----------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

MariaDB [mysql]> exit;

登录数据库,创建hnswjjxy数据库并创建表单mybook

MariaDB [(none)]>  CREATE DATABASE hnswjjxy;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]>  SHOW databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| hnswjjxy        |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.001 sec)
MariaDB [(none)]> use hnswjjxy;
Database changed
MariaDB [hnswjjxy]> CREATE TABLE mybook (name char(15),price int,pages int);
Query OK, 0 rows affected (0.009 sec)
MariaDB [hnswjjxy]> DESCRIBE mybook;
+-------+----------+------+-----+---------+-------+
| Field | Type     | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| name  | char(15) | YES  |     | NULL    |       |
| price | int(11)  | YES  |     | NULL    |       |
| pages | int(11)  | YES  |     | NULL    |       |
+-------+----------+------+-----+---------+-------+
3 rows in set (0.002 sec)

mysqldump命令用于备份数据库数据,格式为“mysqldump [参数] [数据库名称]”。其中参数与mysql命令大致相同,-u参数用于定义登录数据库的用户名称,-p参数表示密码提示符。下面将hnswjjxy数据库中的内容导出为一个文件,并保存到root管理员的家目录中:

[root@localhost 桌面]# mysqldump -u root -p hnswjjxy > /root/hnswjjxy.dump
Enter password: 
[root@localhost 桌面]# cd /root/
[root@localhost ~]# ls
anaconda-ks.cfg  hnswjjxy.dump  initial-setup-ks.cfg  公共  模板  视频  图片  文档  下载  音乐  桌面

然后进入MariaDB数据库管理系统,彻底删除hnswjjxy数据库,这样mybook数据表单也将被彻底删除。

[root@localhost ~]#  mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 5.5.35-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> DROP DATABASE hnswjjxy;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> SHOW databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

然后重新建立linuxprobe数据库,可以看到没有表单:

MariaDB [(none)]>  CREATE DATABASE hnswjjxy;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> use hnswjjxy;
Database changed
MariaDB [hnswjjxy]> DESCRIBE mybook;
ERROR 1146 (42S02): Table 'hnswjjxy.mybook' doesn't exist
MariaDB [hnswjjxy]> exit;

使用输入重定向符把刚刚备份的数据库文件导入到mysql命令中,然后执行该命令。接下来登录MariaDB数据库,就又能看到linuxprobe数据库以及mybook数据表单了。数据库恢复成功!

[root@localhost ~]# mysql -u root -p hnswjjxy < /root/hnswjjxy.dump 
Enter password: 
[root@localhost ~]#  mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 19
Server version: 5.5.35-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SHOW databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| hnswjjxy           |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> use hnswjjxy;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

MariaDB [hnswjjxy]> DESCRIBE mybook;
+-------+----------+------+-----+---------+-------+
| Field | Type     | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| name  | char(15) | YES  |     | NULL    |       |
| price | int(11)  | YES  |     | NULL    |       |
| pages | int(11)  | YES  |     | NULL    |       |
+-------+----------+------+-----+---------+-------+
3 rows in set (0.00 sec)

MariaDB [hnswjjxy]> 

远程控制服务ssh配置

服务器

[root@localhost ~]# systemctl status sshd
sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled)
   Active: active (running) since 四 2024-05-09 14:10:55 CST; 49min ago
 Main PID: 1742 (sshd)
   CGroup: /system.slice/sshd.service
           └─1742 /usr/sbin/sshd -D

509 14:10:55 localhost.localdomain systemd[1]: Started OpenSSH server daemon.
509 14:10:55 localhost.localdomain sshd[1742]: Server listening on 0.0.0.0 port 22.
509 14:10:55 localhost.localdomain sshd[1742]: Server listening on :: port 22.
[root@localhost ~]# systemctl enable sshd
[root@localhost ~]# systemctl list-unit-files | grep ssh
anaconda-sshd.service                       static  
sshd-keygen.service                         static  
sshd.service                                enabled 
sshd@.service                               static  
sshd.socket                                 disabled
[root@localhost ~]# ifconfig 
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.13.131  netmask 255.255.255.0  broadcast 192.168.13.255
        inet6 fe80::20c:29ff:feb8:5c2f  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:b8:5c:2f  txqueuelen 1000  (Ethernet)
        RX packets 632  bytes 46003 (44.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 163  bytes 16158 (15.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 6  bytes 560 (560.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6  bytes 560 (560.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

客户端

[root@localhost 桌面]# ifconfig 
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.13.132  netmask 255.255.255.0  broadcast 192.168.13.255
        inet6 fe80::20c:29ff:fedd:7c41  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:dd:7c:41  txqueuelen 1000  (Ethernet)
        RX packets 695  bytes 48300 (47.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 184  bytes 17871 (17.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 6  bytes 560 (560.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6  bytes 560 (560.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost 桌面]# ssh 192.168.13.131
The authenticity of host '192.168.13.131 (192.168.13.131)' can't be established.
ECDSA key fingerprint is 01:e1:e1:a1:fe:89:18:b6:3d:ba:d4:a3:19:f3:1a:f9.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.13.131' (ECDSA) to the list of known hosts.
root@192.168.13.131's password: 
Last login: Thu May  9 14:11:07 2024
[root@localhost ~]# ifconfig           //注:此时已远程登陆至服务器,故ifconfig命令看到的是服务器ip.
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.13.131  netmask 255.255.255.0  broadcast 192.168.13.255
        inet6 fe80::20c:29ff:feb8:5c2f  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:b8:5c:2f  txqueuelen 1000  (Ethernet)
        RX packets 734  bytes 55822 (54.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 195  bytes 20942 (20.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 6  bytes 560 (560.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6  bytes 560 (560.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@localhost ~]# exit
登出
Connection to 192.168.13.131 closed.

打开服务器sshd服务配置文件,将第48行的参数设置为禁止root管理员远程登录;

[root@localhost ~]# vim /etc/ssh/sshd_config 
……
45 # Authentication:
 46 
 47 #LoginGraceTime 2m
 48 PermitRootLogin no
 49 #StrictModes yes
 50 #MaxAuthTries 6
 51 #MaxSessions 10
 52 
……
[root@localhost ~]# systemctl restart sshd.service

使用客户端远程登陆,提示权限拒绝;
[root@localhost 桌面]# ssh 192.168.13.131
root@192.168.13.131’s password:
Permission denied, please try again.

重新开启root管理员远程登录权限;

[root@localhost ~]# vim /etc/ssh/sshd_config 
……
45 # Authentication:
 46 
 47 #LoginGraceTime 2m
 48 PermitRootLogin yes
 49 #StrictModes yes
 50 #MaxAuthTries 6
 51 #MaxSessions 10
 52 
……
[root@localhost ~]# systemctl restart sshd.service

使用客户端远程登陆,提示登陆成功;
[root@localhost 桌面]# ssh 192.168.13.131
root@192.168.13.131’s password:
Last failed login: Thu May 9 15:17:36 CST 2024 from 192.168.13.132 on ssh:notty
There were 2 failed login attempts since the last successful login.
Last login: Thu May 9 15:16:30 2024 from 192.168.13.132
[root@localhost ~]# exit
登出
Connection to 192.168.13.131 closed.
使用客户端远程传输文件至服务器的/home目录
[root@localhost 桌面]# cd /opt
[root@localhost opt]# scp /opt/hnsw.txt 192.168.13.131:/home
root@192.168.13.131’s password:
hnsw.txt 100% 28 0.0KB/s 00:00
在服务器中查看传输文件内容:
[root@localhost ~]# cd /home/
[root@localhost home]# ls
hnsw.txt student
[root@localhost home]# cat hnsw.txt
welcome to redhat classroom
[root@localhost home]# cd /
[root@localhost /]# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
[root@localhost /]# mv home .home
[root@localhost /]# ls
bin boot dev etc lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
[root@localhost /]# ls -a
. … bin boot dev etc .home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var

使用客户端远程登录服务器,删除文件hnsw.txt,创建文件abc.txt
[root@localhost opt]# ssh 192.168.13.131
root@192.168.13.131’s password:
Last login: Thu May 9 15:20:03 2024 from 192.168.13.132
[root@localhost ~]# cd /.home/
[root@localhost .home]# ls
hnsw.txt student
[root@localhost .home]# cat hnsw.txt
welcome to redhat classroom
[root@localhost .home]# rm hnsw.txt
rm:是否删除普通文件 “hnsw.txt”?y
[root@localhost .home]# touch adc.txt
[root@localhost .home]# ls
adc.txt student
[root@localhost .home]#

  • 25
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值