Linux 基础入门 01

1. 虚拟化

1999年 VMWare推出 x86架构

2006年 KVM

2008年 Hyper-V

2011年 成立开放虚拟化联盟,加速KVM

虚拟机分类:裸金属型、宿主型

内存虚拟化

2. Linux 操作系统
2.1 主流操作系统
  • 商用:红帽 RedHat RHEL8 Centos Ubuntu Kali(安全渗透) Debian(开发)
  • 民用:fedora
2.2 Windows和Linux的区别
2.2.1 Windows操作系统
  • Windows 是民用居多 Linux 是商用居多
  • Windows 系统是闭源的 Linux系统是开源的
  • Windows 操作系统 操作简单、有图形化界面
  • Windows 系统空间占用极大
  • Windows 操作系统的底层源码是保密的
  • Windows 操作系统是被留后门的,系统不安全
2.2.2 Linux 操作系统
  • Linux操作系统是属于开源软件基金会
  • 开源软件必须是源码完全开源的
  • 基于开源软件创造的一切知识产权也必须是开源的
  • 所有人都可以对开源软件提出源码意见
  • Windows 操作系统实在系统稳定性、兼容性、开放性是远远比不过Linux 都是内核息息相关的

Linux操作系统开源网站:Kernel

操作系统的系统内核,掌管了整个系统的调度算法、指令集、资源控制、所有的系统功能

2.2.3 others

红帽 RHEL redhat enterprise linux 免费 卖lisence

额外的研发 附加专利 代码也是完全公开的。

centos 跟红帽系统完全一样,源码也一样,完全免费,发布社区

2014年 redhat 收购 centos

2021年12月31日 红帽彻底暂停 centos 技术支持 centos 7将提供技术支持到2024年

3. 红帽认证

考RHCE 技术难度远低于授课难度的

RHCE 考试 高级认证 含金量是远超 华为HCIP

RHCE考试 是全实操 考试时间 8小时

上午考RHCSA 红帽系统管理员 入门级 3.5h 基本操作,简单服务部署,shell编程,逻辑卷管理

下午考RHCE 红帽认证系统工程师 4.5 ansible 自动化运维,全脚本实现

4. 快照技术

快照技术是虚拟化特有的技术之一,可以将虚拟机当前的状态备份,无论虚拟机发生什么问题,都可以回到当前这个时间点虚拟机的状态。
快照一定要关机打,因为开着机打快照,会导致当前内存迅速锁死,下次回复快照,会占用大量内存 使得恢复进度非常缓慢。

5. Linux 入门
  • 用户 在进入系统的时候系统上会显示一个其他用户,并非超级管理员用户,选择 not listed 输入root 密码进入

  • 超级管理员 root 拥有系统的一切的权限,所有这个用户可以对系统进行不可回复的破坏

  • 删库 跑路

    rm -rf /*
    
  • Linux 文件结构

    • 起源是 / 根 Linux 万物皆文件
    • / 根目录 是整个linux文件系统的开始 就像windows是以盘符C:\开头的样。只是 linux没有盘符的概念。
    • / bin 存放构建最小系统所需要的工具
    • /root 这就是root的家目录root这个用户的文件
    • /dev 这个目录下存放了系统中所有的硬件文件
    • /home 这个是除 root外其他用户的默认家目录,比如redhat的目录就在
    • /home
    • /boot 用来实现系统引导,存放了linux的内核虚拟文件
    • /lib 库文件
    • /mnt 挂载文件
    • /sbin 用来存放内核所需要的工具
    • /proc 内存映射,该目录不占用磁盘空间
    • /tmp 缓存目录,是所有用户生成文件都会放在该目录下,随时可以删除
6. 登录企业服务器的几种方法
  1. 远程登录 ssh 远程连接
  2. web登录 是可以通过可视化来操作,一般留给监控、运维人员使用,做简单配置
6.1 如何远程登录Linux 服务器
  1. 服务器要有网络,服务器IP地址
  2. 网络可达(连接端和被连接端能ping通)
  3. 服务器必须开启openssh 功能,允许被人远程访问,红帽系的服务默认开启。Ubuntu操作系统需要单独手动开启
  4. 必须知道该服务器的用户名和密码(不一定要root)
6.2 如何查看IP地址

命令 :ip addr 服务器的网卡一般都是以ens 开头

假设服务器IP地址为192.168.200.128 还需要远程连接工具才可以连接上去

7.Linux常用命令
  • 查看服务器名称:hostname

  • 设置服务器名称:hostnamectl set-hostname wentan

  • 查看历史命令:history

  • 查看日历时间:date cal

  • 现在位置:pwd

  • 创建目录mkdir

  • 创建文件touch 123.txt

  • 复制cp 123.txt /root/

  • 移动mv 123.txt /root/

  • 删除文件rm 123.txtrm -f

  • 删除目录 rm -rrm -rf

  • 重命名mv 123.txt 1234.tx

  • ls -a, --all do not ignore entries starting with .
    -A, --almost-all do not list implied . and …
    –author with -l, print the author of each file
    -b, --escape print C-style escapes for nongraphic characters
    –block-size=SIZE with -l, scale sizes by SIZE when printing them;
    e.g., ‘–block-size=M’; see SIZE format below
    -B, --ignore-backups do not list implied entries ending with ~
    -c with -lt: sort by, and show, ctime (time of last
    modification of file status information);
    with -l: show ctime and sort by name;
    otherwise: sort by ctime, newest first
    -C list entries by columns
    –color[=WHEN] colorize the output; WHEN can be ‘always’ (default
    if omitted), ‘auto’, or ‘never’; more info below
    -d, --directory list directories themselves, not their contents
    -D, --dired generate output designed for Emacs’ dired mode
    -f do not sort, enable -aU, disable -ls --color
    -F, --classify append indicator (one of /=>@|) to entries
    –file-type likewise, except do not append '

    –format=WORD across -x, commas -m, horizontal -x, long -l,
    single-column -1, verbose -l, vertical -C
    –full-time like -l --time-style=full-iso
    -g like -l, but do not list owner
    –group-directories-first
    group directories before files;
    can be augmented with a --sort option, but any
    use of --sort=none (-U) disables grouping
    -G, --no-group in a long listing, don’t print group names
    -h, --human-readable with -l and -s, print sizes like 1K 234M 2G etc.
    –si likewise, but use powers of 1000 not 1024
    -H, --dereference-command-line
    follow symbolic links listed on the command line
    –dereference-command-line-symlink-to-dir
    follow each command line symbolic link
    that points to a directory
    –hide=PATTERN do not list implied entries matching shell PATTERN
    (overridden by -a or -A)
    –hyperlink[=WHEN] hyperlink file names; WHEN can be ‘always’
    (default if omitted), ‘auto’, or ‘never’
    –indicator-style=WORD append indicator with style WORD to entry names:
    none (default), slash (-p),
    file-type (–file-type), classify (-F)
    -i, --inode print the index number of each file
    -I, --ignore=PATTERN do not list implied entries matching shell PATTERN
    -k, --kibibytes default to 1024-byte blocks for disk usage;
    used only with -s and per directory totals
    -l use a long listing format
    -L, --dereference when showing file information for a symbolic
    link, show information for the file the link
    references rather than for the link itself
    -m fill width with a comma separated list of entries
    -n, --numeric-uid-gid like -l, but list numeric user and group IDs
    -N, --literal print entry names without quoting
    -o like -l, but do not list group information
    -p, --indicator-style=slash
    append / indicator to directories
    -q, --hide-control-chars print ? instead of nongraphic characters
    –show-control-chars show nongraphic characters as-is (the default,
    unless program is ‘ls’ and output is a terminal)
    -Q, --quote-name enclose entry names in double quotes
    –quoting-style=WORD use quoting style WORD for entry names:
    literal, locale, shell, shell-always,
    shell-escape, shell-escape-always, c, escape
    (overrides QUOTING_STYLE environment variable)
    -r, --reverse reverse order while sorting
    -R, --recursive list subdirectories recursively
    -s, --size print the allocated size of each file, in blocks
    -S sort by file size, largest first
    –sort=WORD sort by WORD instead of name: none (-U), size (-S),
    time (-t), version (-v), extension (-X)
    –time=WORD with -l, show time as WORD instead of default
    modification time: atime or access or use (-u);
    ctime or status (-c); also use specified time
    as sort key if --sort=time (newest first)
    –time-style=TIME_STYLE time/date format with -l; see TIME_STYLE below
    -t sort by modification time, newest first
    -T, --tabsize=COLS assume tab stops at each COLS instead of 8
    -u with -lt: sort by, and show, access time;
    with -l: show access time and sort by name;
    otherwise: sort by access time, newest first
    -U do not sort; list entries in directory order
    -v natural sort of (version) numbers within text
    -w, --width=COLS set output width to COLS. 0 means no limit
    -x list entries by lines instead of by columns
    -X sort alphabetically by entry extension
    -Z, --context print any security context of each file
    -1 list one file per line. Avoid ‘\n’ with -q or -b
    –help display this help and exit
    –version output version information and exit

  • 获取帮助手册 man + 命令

  • 关机 shutdown shutdown 0 立刻关机

  • 重启 reboot

  • 测试联通性 ping

  • 切换用户 su - wentan su - root

  • 编辑 保存 退出 vi/vim 1234.txt :wq

  • :w //保存文件
    :w vpser.net //保存至vpser.net文件
    :q //退出编辑器,如果文件已修改请使用下面的命令
    :q! //退出编辑器,且不保存
    :wq //退出编辑器,且保存文件

    8. 用户和组

    超级管理员用户 root

    其他用户 权限没有root高

    用户:任何一个用户都会被分配一个ID

    UID = 0 标识了超级管理员用户 root

    一般的其他用户,UID 是从1000开始的

    0-1000是系统默认存在的用户,系统已经占用

    /etc/passsd 存储了所有用户的信息,是不可以随便编辑的

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-xrPozZfD-1641784060970)(C:\Users\tan-1210\AppData\Roaming\Typora\typora-user-images\image-20220108160907388.png)]

root:x:0:0:root:/root:/bin/bash

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-X4WQ6CiS-1641784060972)(C:\Users\tan-1210\AppData\Roaming\Typora\typora-user-images\image-20220108161204721.png)]

用户必须属于一个组 我们在创建用户的时候默认创建一个组,组名和用户名相同

每个组也都被分了一个组ID
/etc/group 存放了组信息
可以将用户添加到某个组
同一个组的所有用户,是可以共享这个组的文件的

redhat :X:1000:
字段1:组名称
字段2:密码占位符
字段3:组的id

有个组叫wheel 如果某个普通用户 想执行某些只能root执行的命令,可以通过提权来完成这些命令 ,就要把这个用户 加入到 wheel这个组里面
wheel组 是系统管理员组
什么是提权 sudo + 某些命令 就可以以root用户来执行这些命令
在第一次sudo的时候 需要提供用户密码确认

su - root

sudo 和 su - 区别是什么?
sudo的全称叫做: substitute user do 代替用户做 此时的用户还是非root
su - 是直接切换到用户 root的命令

用户和组的创建和修改:
useradd
-u: uid
-g: 用户组的名称
-d: 家目录
-G: 附加组 (wheel)
-s: 指定shell文件

useradd admin -u 1001 -g redhat -s /bin/bash -G wheel
passwd admin 给密码 需要重复确认

groupadd 增加组
-g 组id
groupadd -g 1002 admins
user do` 代替用户做 此时的用户还是非root
su - 是直接切换到用户 root的命令

用户和组的创建和修改:
useradd
-u: uid
-g: 用户组的名称
-d: 家目录
-G: 附加组 (wheel)
-s: 指定shell文件

useradd admin -u 1001 -g redhat -s /bin/bash -G wheel
passwd admin 给密码 需要重复确认

groupadd 增加组
-g 组id
groupadd -g 1002 admins


欢迎关注微信公众号:问渠清源

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

tan-1210

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值