虚拟软件使用方法/远程连接排错/linux系统命令

01-day05-虚拟软件使用方法/远程连接排错/linux系统命令

=====================================================

00.课程介绍部分

1)系统的操作
	命令操作
	快捷方式操作
	符号介绍

01.课程知识回顾

  • 1)远程连接排错
    1.链路是否通畅 ping
    2.链路是否有阻塞 防火墙/安全策略
    3.服务是否开启 telnet systemctl status sshd

    2)系统预备知识
    系统命令提示符:组成:用户名@主机名 目录
    系统目录结构:从根开始
    绝对路径:从根开始
    相对路径:从当期路径开始
    语法命令规范: 命令(区分大小写) cd mkdir 参数 对象: 目录或文件名

    3)系统基础命令
    1.系统运行命令: shutdown
    2.目录操作命令; ls mkdir cd (…/…/ ~ ~ ) pwd:查看当前绝对路径的信息

02.文件目录相关命令

1)查看文件信息命令 ls

[root@RedHat7 ~]# ls /etc/hostname 
/etc/hostname
[root@RedHat7 ~]# ls /etc/hostname -l		---显示文件详细信息
-rw-r--r--. 1 root root 8 Feb 14 01:37 /etc/hostname	

2)如何创建一个空文件

touch Test/test0.txt 
[root@RedHat7 ~]# touch Test/test0.txt
[root@RedHat7 ~]# ls Test/test0.txt 
Test/test0.txt
[root@RedHat7 ~]# ls Test/test0.txt  -l 
-rw-r--r--. 1 root root 0 Feb 14 01:59 Test/test0.txt

3)如何对空文件进行编辑

1.将文件打开直接进行编辑
			vi/vim   ---用于编辑文件命令
			vim Test/test0.txt 
			步骤一:进入到编辑模式(插入模式)
				按键盘上 i
			步骤二:编辑文件内容
			步骤三:保存并退出
				按esc(推出编辑模式)---:wq (write 写/保存   quit 退出)
				 :q  不保存直接退出
				 :w  保存但不退出
		2.将文件不用打开进行编辑
			将屏幕显示信息保存到文件
			步骤一:屏幕上有显示信息
				[root@RedHat7 ~]# echo "hello world"
				hello world
			步骤二:将屏幕信息写入文件
				[root@RedHat7 ~]# echo "hello world" >  Test/test0.txt 
				[root@RedHat7 ~]# cat Test/test0.txt 
				hello world
			
			说明:
			>   覆盖写入  
			>>	追加写入
			

4)查看文件内容的命令
cat — 查看文件

[root@RedHat7 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

5)如何复制保存数据
copy----cp
用法: cp 目标数据(文件/目录 ) 目的地(目录)

文件备份方法:

[root@RedHat7 ~]# cp  Test/test0.txt   /tmp/
[root@RedHat7 ~]# ls -l /tmp/test0.txt 
-rw-r--r--. 1 root root 12 Feb 14 02:25 /tmp/test0.txt
[root@RedHat7 ~]# ls -l  Test/test0.txt 
-rw-r--r--. 1 root root 12 Feb 14 02:17 Test/test0.txt	

目录备份方法:

[root@RedHat7 ~]# cp  -r    01/   /tmp/
[root@RedHat7 ~]# ls -d  /tmp/01/
/tmp/01/
[root@RedHat7 ~]# ls -d  /tmp/01/02
/tmp/01/02
[root@RedHat7 ~]# ls -d  /tmp/01/02/03
/tmp/01/02/03			

补充:目录复制备份有时需要进行多次确认

[root@RedHat7 ~]# cp  -r    01/   /tmp/
cp: overwrite ‘/tmp/01/01.txt’? y
cp: overwrite ‘/tmp/01/02.txt’? y
cp: overwrite ‘/tmp/01/03.txt’? y
cp: overwrite ‘/tmp/01/04.txt’? y
cp: overwrite ‘/tmp/01/05.txt’? y
	
[root@RedHat7 ~]# \cp  -r    01/   /tmp/     \进行目录中数据强行覆盖		
	

6)删除数据命令(慎用)
delete ==== remove ----- rm

删除文件

[root@RedHat7 etc]# rm /tmp/01/01.txt 
rm: remove regular empty file ‘/tmp/01/01.txt’? ^C
[root@RedHat7 etc]# \rm /tmp/01/01.txt
[root@RedHat7 etc]# ls -l /tmp/01/01.txt
ls: cannot access /tmp/01/01.txt: No such file or directory
[root@RedHat7 etc]# rm -f /tmp/01/02.txt 
[root@RedHat7 etc]# ls -l /tmp/01/02.txt
ls: cannot access /tmp/01/02.txt: No such file or directory		

删除目录

[root@RedHat7 ~]# rm /tmp/01
rm: cannot remove ‘/tmp/01’: Is a directory
[root@RedHat7 ~]# rm  -f  /tmp/01
rm: cannot remove ‘/tmp/01’: Is a directory
[root@RedHat7 ~]# rm  -r  /tmp/01
rm: descend into directory ‘/tmp/01’? ^C
[root@RedHat7 ~]# rm  -rf  /tmp/01
[root@RedHat7 ~]# ls -d  /tmp/01
ls: cannot access /tmp/01: No such file or directory

PS:运维人员两大经典错误
01.删根跑路
02.删库跑路

7)移动数据信息(剪切数据信息)
move ---- mv
移动剪切文件数据

[root@RedHat7 ~]# mv 01/01.txt    /tmp/
[root@RedHat7 ~]# ls -l /tmp/01.txt 
-rw-r--r--. 1 root root 0 Feb 14 02:36 /tmp/01.txt
[root@RedHat7 ~]# ls -l 01/01.txt
ls: cannot access 01/01.txt: No such file or directory		

移动剪切目录数据

[root@RedHat7 ~]# mv  01/02/   /tmp/
[root@RedHat7 ~]# ls -d /tmp/02
/tmp/02
[root@RedHat7 ~]# ls -dl /tmp/02
drwxr-xr-x. 3 root root 15 Feb 14 02:36 /tmp/02
[root@RedHat7 ~]# ls -d 01/02/
ls: cannot access 01/02/: No such file or directory			

重命名文件

[root@RedHat7 ~]# cd 01
[root@RedHat7 01]# touch  001.txt
[root@RedHat7 01]# ls
001.txt  02.txt  03.txt  04.txt  05.txt
[root@RedHat7 01]# echo  001001001 >  001.txt 
[root@RedHat7 01]# mv 001.txt 002.txt
[root@RedHat7 01]# ls
002.txt  02.txt  03.txt  04.txt  05.txt
[root@RedHat7 01]# cat 002.txt 
001001001			

移动数据时出现重复信息也会提示需要覆盖

[root@RedHat7 01]# ls -l /tmp/01.txt 
-rw-r--r--. 1 root root 0 Feb 14 02:36 /tmp/01.txt
[root@RedHat7 01]# ls
002.txt  02.txt  03.txt  04.txt  05.txt
[root@RedHat7 01]# touch   01.txt
[root@RedHat7 01]# mv 01.txt   /tmp/
mv: overwrite ‘/tmp/01.txt’? 		

03.课程知识回顾
1)系统基础命令
系统运行命令: 目录相关 文件相关

2)vi命令基础使用方法
3)快捷方式使用

	01. ctrl+c 				中断命令执行过程
	02. ctrl+l				清屏操作
	03. ctrl+d  			注销功能
	04. tab					 补全命令
	05. 方向键上下			调取历史命令
	06. ctrl+a				快速将光标移动到行首
	07. ctrl+e				快速将光标移动到行尾
	08.	ctrl+左右方向键		按照一个英文单词进行移动光标

4)特殊系统符号
		~				家目录
		..				上一级目录
		>				标准输出重定向符         覆盖写入
		>>				标准输出追加重定向符	  追加写入
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值