day03-Linux基础命令详解(1)

01.Linux命令提示符

eg:

[root@oldboy ~]# # 提示我们可以正常输入命令 (bash解释器)

  • root: 系统管理员

  • oldboy: 主机名称(表示本机)

  • ~: 表示的是家目录

    • 家目录: 默认登录操作系统所在的位置Linux默认的家目录

    • /root /目录下的 root目录下

  • #: 表示用户提示符

    #:表示当前是管理员

    $:表示普通用户登录的系统

02.Linux系统关机重启命令

命令语法结构:

  • 命令 直接回车
  • 命令 空格 文件或者目录
  • 命令 空格 [参数选项] 空格 文件或者目录

[] 在Linux操作系统中中括号为可选项 每个参数表示不同的功能

案例: pwd 直接回车

案例2:  rm  oldboy.txt

案例3: rm  -f   oldboy.txt

关机命令:

1. shutdown 直接回车 默认1分钟后关机
参数: 
     -c  取消关机  了解
     -h  时长  例如 shutdown -h 5 表示5分钟后关机
     -h  now   立刻关机
     -r  重启
[root@oldboy ~]# shutdown 
Shutdown scheduled for Mon 2023-07-03 10:27:07 CST, use 'shutdown -c' to cancel.

Broadcast message from root@oldboy (Mon 2023-07-03 10:26:07 CST):
广播消息来自root
The system is going down for power-off at Mon 2023-07-03 10:27:07 CST!
这个系统将要在xxx时间进行关机


# 取消关机
[root@oldboy ~]# shutdown -c

Broadcast message from root@oldboy (Mon 2023-07-03 10:26:18 CST):

The system shutdown has been cancelled at Mon 2023-07-03 10:27:18 CST!

# 立刻关机 必须掌握
[root@oldboy ~]# shutdown -h now


# 1分钟后重启
[root@oldboy ~]# shutdown -r



其他关机命令:
halt     回车
poweroff 回车
init 0   回车

2.重启命令
shutdonw -r now
reboot   回车
init 6   回车

系统开机:

硬件: 托管到IDC机房

​ 打电话通知IDC机房管理人员

​ 远程控制卡(支持远程开机 关机 安装操作系统) 需要配置IP地址

云服务: 浏览器登录后台 点击选项

03.Linux man帮助

语法格式: manual

man 命令

help 命令

内置命令

外置命令

在这里插入图片描述
百度一下你就知道

Linux

04.Linux系统中常用快捷键

[root@oldboy ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0

ctrl+c  强制结束当前运行的命令    常用
ctrl+l  清屏					  常用
ctrl+d  退出shell
ctrl+a  移动光标到行首  Home
ctrl+e  移动光标到行尾  End
ctrl+u  剪切
ctrl+y  粘贴剪切板的内容
05.Linux系统目录结构

Linux目录: 一切从/开始 /是最顶级的目录 类似windows只有一个C盘

/ 顶点目录

/boot/

/root/

/etc/

/etc/hosts

/oldboy.txt

使用什么方式区分目录还是普通文件?

结尾是/尾目录 没有/的为普通文件

目录是蓝色的

文件是白色的

Linux的后缀是给我们自己看的,Linux一切皆文件

windows目录结构:

C:\test\

D:\考研资料\大片\

E:\学习资料\Linux\

Linxu目录结构概念:

相对路径: 从当前目录可以查找到的文件

​ ll 1.txt # 1.txt表示在当前的位置

​ 找到教室6 出门左拐

绝对路径: 一切文件从/开始查找的文件 带/的文件 称为绝对路径

​ ll /root/1.txt # 从/开始查找文件的位置

​ 地球–>亚洲–>中国–>北京–>昌平沙河–>富雷科技产业园–>老男孩教育教室6

注意: 文件或者目录的路径不能有空格

知识点小结:

1.Linux命令提示符

[root@oldboy ~]#

管理员root的家 /root目录

2.Linux关机重启命令

shutdown -h now

init 0

halt

poweroff

重启命令

reboot

init 6

3.man帮助

man 命令

help 命令

4.Linux快捷键

ctrl+c

ctrl+l

ctrl+a

ctrl+u

ctrl+y

ctrl+e

5.Linux目录结构

文件表示方法:

相对路径

绝对路径

今日重点:

一个关机和一个重启命令

man帮助和百度搜索必会

Linux快捷键 ctrl+l ctrl+c ctrl+u ctrl+a

目录结构 学习过程中由浅入深

下午内容:

一级目录作用功能

Linux基础命令

pwd

ls

cat

cd

touch

mkdir

06.一级目录作用

bin: 二进制命令所在的目录

dev : 硬件设备所在的目录 磁盘 光驱

home: 普通用户的家目录 贫民窟 /home/oldboy /root/ /home/test

mnt: 临时挂载点 硬件的入口 入口目录可以自己创建 默认空的

proc: 内存的映射

tmp: 临时存放文件的位置 类似windows的回收站

var: 存放经常变化的文件 日志文件 服务安装默认日志存放位置nginx /var/log/nginx/access.log
boot: 内核 引导程序

etc: 系统的配置文件 服务默认的配置文件

​ /etc/sysconfig/network-scripts/ifcfg-eth0

​ /etc/nginx/

opt: 第三方软件默认安装所在的位置 默认空

root:管理员家目录 类似皇宫

sbin: 管理员可执行的命令的位置

usr: 存放用户的程序 文件
在这里插入图片描述

07.Linux常用基础命令
1. pwd 显示当前所在的路径 print working directory
语法结构:
[root@oldboy ~]# pwd   # 回车
/root

2. cd 切换目录 change directory
语法结构:
相对路径进入目录:
[root@oldboy ~]# cd /
[root@oldboy /]# cd etc
[root@oldboy etc]# cd sysconfig/
[root@oldboy sysconfig]# cd network-scripts/
[root@oldboy network-scripts]# pwd
/etc/sysconfig/network-scripts
[root@oldboy network-scripts]#

使用绝对路径进入目录:
[root@oldboy network-scripts]# cd  # cd直接回到皇宫
[root@oldboy ~]#
[root@oldboy ~]# cd /etc/sysconfig/network-scripts/
[root@oldboy network-scripts]# pwd
/etc/sysconfig/network-scripts
[root@oldboy ~]# cd -     # 回到上一次所在的路径
/etc/sysconfig/network-scripts
[root@oldboy network-scripts]# pwd
/etc/sysconfig/network-scripts

# cd ~ 回到家目录
[root@oldboy network-scripts]# cd ~
[root@oldboy ~]#

# cd /root 回到家目录
[root@oldboy network-scripts]# cd /root/
[root@oldboy ~]# pwd
/root
# 回到上一级目录
[root@oldboy network-scripts]# cd ..
[root@oldboy sysconfig]# pwd
/etc/sysconfig
# 回到上二级目录
[root@oldboy sysconfig]# cd ../..
[root@oldboy /]# pwd
/

# 点表示当前所在的目录
[root@oldboy ~]# cd .
[root@oldboy ~]# 


cd命令小结:
cd   回到家目录
cd ~ 回到家目录
cd /root 回到家目录
cd - 返回到上一次所在的路径
cd .. 回到上一级目录
cd .  表示当前的目录

3.ls  查看文件或目录
参数选项:
		 -l 显示文件或目录的详细信息
		 -d 只查看目录本身的详细信息
语法结构:
查看1.txt是否存在
[root@oldboy ~]# ls 1.txt
1.txt
[root@oldboy ~]# ls 2.txt
ls: cannot access 2.txt: No such file or directory

显示当前目录的所有的文件
[root@oldboy ~]# ls
1.txt  hosts  oldboy

指定查看/tmp目录下有哪些文件
[root@oldboy ~]# ls /tmp/
ks-script-zVRXqX            vmware-root_848-2697663887
vmware-root_800-2999657415  yum.log
vmware-root_846-2697139606  yum_save_tx.2023-07-03.11-33.bUrQzp.yumtx

查看/目录和/tmp目录下有哪些文件
[root@oldboy ~]# ls / /tmp/
/:
bin   dev  home  lib64  mnt  proc  run   srv  tmp  var
boot  etc  lib   media  opt  root  sbin  sys  usr

/tmp/:
ks-script-zVRXqX            vmware-root_848-2697663887
vmware-root_800-2999657415  yum.log
vmware-root_846-2697139606  yum_save_tx.2023-07-03.11-33.bUrQzp.yumtx

# ls -l 查看详细信息
[root@oldboy ~]# ls -l
total 4
-rw-r--r--. 1 root root   0 Jul  3 11:50 1.txt
-rw-r--r--. 1 root root 158 Jul  3 16:33 hosts
drwxr-xr-x. 2 root root   6 Jul  3 16:41 oldboy

#执行ll命令相当于执行 ls -l命令
#系统给ls -l命令起了个外号叫 ll
外号: 老男孩老师-->冉宏元
      铁蛋--->
      鸭蛋
      狗蛋
      狗剩
      二牛
      大牛
      铁牛
      ...
[root@oldboy ~]# ll
total 4
-rw-r--r--. 1 root root   0 Jul  3 11:50 1.txt
-rw-r--r--. 1 root root 158 Jul  3 16:33 hosts
drwxr-xr-x. 2 root root   6 Jul  3 16:41 oldboy
[root@oldboy ~]# ll /tmp/
total 8
-rwx------. 1 root root 836 Jun 29 17:51 ks-script-zVRXqX
drwx------. 2 root root   6 Jul  3 10:45 vmware-root_800-2999657415
drwx------. 2 root root   6 Jul  3 10:44 vmware-root_846-2697139606
drwx------. 2 root root   6 Jun 30 09:12 vmware-root_848-2697663887
-rw-------. 1 root root   0 Jun 29 17:44 yum.log
-rw-------. 1 root root 239 Jul  3 11:33 yum_save_tx.2023-07-03.11-33.bUrQzp.yumtx
[root@oldboy ~]# ll 1.txt
-rw-r--r--. 1 root root 0 Jul  3 11:50 1.txt
[root@oldboy ~]# ll 1.txt hosts
-rw-r--r--. 1 root root   0 Jul  3 11:50 1.txt
-rw-r--r--. 1 root root 158 Jul  3 16:33 hosts

4.touch 创建普通文件 摸(如果文件存在则修改文件的时间)
时间和时间戳的区别
语法结构:
	        相对路径
			touch  file1
			touch  file1 file2
			绝对路径
			touch /tmp/file1
			touch /tmp/file2 /tmp/file3
[root@oldboy ~]# ll
total 0
案例1:创建一个文件
[root@oldboy ~]# touch 1.txt
[root@oldboy ~]# ll
total 0
-rw-r--r--. 1 root root 0 Jul  3 17:06 1.txt
案例2: 创建多个文件
[root@oldboy ~]# touch 2.txt 3.txt
[root@oldboy ~]# ll
total 0
-rw-r--r--. 1 root root 0 Jul  3 17:06 1.txt
-rw-r--r--. 1 root root 0 Jul  3 17:06 2.txt
-rw-r--r--. 1 root root 0 Jul  3 17:06 3.txt
案例3: 在/opt目录下创建test.txt
相对路径:
[root@oldboy ~]# cd /opt/
[root@oldboy opt]# ll
total 0
[root@oldboy opt]# touch test.txt
[root@oldboy opt]# ll
total 0
-rw-r--r--. 1 root root 0 Jul  3 17:08 test.txt

绝对路径:
[root@oldboy ~]# touch /opt/1.txt
[root@oldboy ~]# ll /opt/
total 0
-rw-r--r--. 1 root root 0 Jul  3 17:09 1.txt
-rw-r--r--. 1 root root 0 Jul  3 17:08 test.txt

案例4:在/opt目录下创建a.txt和b.txt
相对路径:
[root@oldboy ~]# cd /opt/
[root@oldboy opt]# ll
total 0
-rw-r--r--. 1 root root 0 Jul  3 17:09 1.txt
-rw-r--r--. 1 root root 0 Jul  3 17:08 test.txt
[root@oldboy opt]# touch a.txt b.txt
[root@oldboy opt]# ll
total 0
-rw-r--r--. 1 root root 0 Jul  3 17:09 1.txt
-rw-r--r--. 1 root root 0 Jul  3 17:10 a.txt
-rw-r--r--. 1 root root 0 Jul  3 17:10 b.txt

绝对路径:
错误的创建方式:----------------------------------------
[root@oldboy ~]# ll /opt/
total 0
[root@oldboy ~]# touch /opt/a.txt b.txt
[root@oldboy ~]# ll
total 0
-rw-r--r--. 1 root root 0 Jul  3 17:06 1.txt
-rw-r--r--. 1 root root 0 Jul  3 17:06 2.txt
-rw-r--r--. 1 root root 0 Jul  3 17:06 3.txt
-rw-r--r--. 1 root root 0 Jul  3 17:11 b.txt
[root@oldboy ~]# ll /opt/
total 0
-rw-r--r--. 1 root root 0 Jul  3 17:11 a.txt
--------------------------------------------------------

正确的创建方式:
[root@oldboy ~]# touch /opt/a.txt /opt/b.txt
[root@oldboy ~]# ll /opt/
total 0
-rw-r--r--. 1 root root 0 Jul  3 17:12 a.txt
-rw-r--r--. 1 root root 0 Jul  3 17:12 b.txt

扩展: 序列 /opt下创建1.txt 2.txt 3.txt
[root@oldboy ~]# touch /opt/{1..3}.txt
[root@oldboy ~]# ll /opt/
total 0
-rw-r--r--. 1 root root 0 Jul  3 17:13 1.txt
-rw-r--r--. 1 root root 0 Jul  3 17:13 2.txt
-rw-r--r--. 1 root root 0 Jul  3 17:13 3.txt



案例5: 在/opt下和/tmp下同时创建oldboy.txt
[root@oldboy ~]# touch /opt/oldboy.txt /tmp/oldboy.txt
[root@oldboy ~]# ll /opt/
total 0
-rw-r--r--. 1 root root 0 Jul  3 17:15 oldboy.txt
[root@oldboy ~]# ll /tmp/
total 0
-rw-r--r--. 1 root root 0 Jul  3 17:15 oldboy.txt

案例6: 在上一级创建一个test.txt
[root@oldboy tmp]# pwd
/tmp
[root@oldboy tmp]# touch /test.txt
[root@oldboy tmp]# cd /
[root@oldboy /]# touch test.txt
使用..上一级方式
[root@oldboy tmp]# touch ../test.txt


知识点小结: 需要掌握的

01.Linux命令提示符

[root@oldboy ~]# 含义

02.Linux关机重启命令 必会

shutdown

halt

init 0

poweroff

重启

shutdonw -r now

reboot

init 6

03.man help 了解

man touch

help cd

04.快捷键

ctrl+c 强制结束

ctrl+l 清屏

ctrl+u 剪切

ctrl+a 快速到行首 Home

ctrl+e End 到行尾

05.目录结构 1级目录的作用背过

06.Linux基础命令 必会

pwd 查看路径
cd  切换目录
cd ~
cd -
cd ..
cd /root
ls -l ==== ll 查看文件的详细信息
     -l  显示详细信息
     -d  显示目录本身的信息
touch 创建普通文件

作业:

所学内容做成笔记 9点半-10点同桌互相提问

1级目录作用

命令单独的一个文档

下次内容:

mkdir
cat
cp
mv
rm
vim

d /
[root@oldboy /]# touch test.txt
使用…上一级方式
[root@oldboy tmp]# touch …/test.txt




知识点小结: 需要掌握的

01.Linux命令提示符

[root@oldboy ~]#  含义

02.Linux关机重启命令 必会

shutdown

halt

init 0

poweroff

重启

shutdonw -r now

reboot

init 6

03.man help 了解

man touch

help cd

04.快捷键

ctrl+c  强制结束

ctrl+l  清屏

ctrl+u 剪切

ctrl+a  快速到行首 Home

ctrl+e  End 到行尾

05.目录结构 1级目录的作用背过

06.Linux基础命令 必会

```bash
pwd 查看路径
cd  切换目录
cd ~
cd -
cd ..
cd /root
ls -l ==== ll 查看文件的详细信息
     -l  显示详细信息
     -d  显示目录本身的信息
touch 创建普通文件

作业:

所学内容做成笔记 9点半-10点同桌互相提问

1级目录作用

命令单独的一个文档

下次内容:

mkdir
cat
cp
mv
rm
vim
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值