Linux Getting Started and Installation Tutorial

Linux

Knowledge points in this chapter

Three Linux introduction and installation

3.1 Company Development Department

IT公司专业术语  
 
PM ( Product Manager ) 产品经理:产品的构想、框架的设计、用户的调研等。   
RD(Research and Development)研发:如:软件RD工程师就是软件研发工程师,诸如PHP程序猿,Java程序猿,偏向于后端的技术实现。
FE(Front-End)前端:前端开发(Front-End Development) FE是web前端研发,偏向表现层。  
UE(User Experience,简称UX或 UE)用户体验: 还有个组合叫法:UED(产品交互设计师,用户体验师)。
UI(User Interface)用户界面:UI设计:界面风格用色、图片、交互、的整体设计。
QA(QUALITY ASSURANCE)测试: 中文意思是“质量保证”
DBA(Database Administrator)数据库管理员:负责管理和维护数据库服务器  
OP:运维(Operations)OP这个词语代表的意思很多,这个简称来自于英文的Operations一词   

MRD:市场需求文档(Market Requirements Document)获得老大的认同后,产品进入实施,需要先出MRD,具体来说要有更细致的市场与竞争对手分析,通过哪些功能来实现商业目的,功能/非功能需求分哪几块,功能的优先级等等。实际工作中,这个阶段PD可能的产出物有Mind Manager的思维图,ExcelFeature List等。

市场需求文档(MRD)重点放在为一个被提议的新产品或者现有产品的改进定义市场需求。与BRD指出商业问题和解决这些问题的解决方案不同,MRD更深入提议解决方案的细节。它包括一些或者所有这些细节:

            a. 解决商业问题所需要的特色

            b. 市场竞争分析

            c. 功能和非功能需求

            d. 特色/需求的优先级

            e. 用例

MRD通常是由拥有产品经理,产品营销经理或者行业分析师头衔的人撰写的。MRD通常是一份连续的5-25Word文档,或者正如之后描述那样在一些机构中甚至更长。


 PRD:产品需求文档(Product Requirements Document) 进步一细化,这部分是PD写得最多的内容,也就是传统意义上的需求分析,我们这里主要指UC(use case)文档。主要内容有,功能使用的具体描述(每个UC一般有用例简述、行为者、前置条件、后置条件、UI描述、流程/子流程/分支流程,等几大块),Visio做的功能点业务流程,界面的说明,demo等。Demo方面,可能用dreamweaver、ps甚至画图板简单画一下,有时候也会有UI/UE支持,出高保真的demo,开发将来可以直接用的那种。

产品需求文档(PRD)重点放在为一个被提议的新产品或者现有产品的改进定义市场需求。与MRD侧重于从市场需要角度看需求的不同,PRD侧重于从产品本身角度看待需求。通常在特点和功能需求上更深入细节,并也可能包括屏幕截图和用户界面流程。在那些MRD不包括具体需求和用例的机构中,PRD就包含这些具体内容。PRD通常是由拥有产品经理,行业分析师或者产品分析师头衔的人撰写的。PRD通常是一份连续的20-50Word文档,或者针对复杂产品甚至更长。

提醒:一些机构将这里描述的MRD和PRD合并成一个文档,并称最后的文档为MRD。在这种情况下,MRD包括本段描述的内容,也包括上一段描述PRD的内容,并且可能超过50页。


 FSD:功能详细说明(Functional Specifications Document)有一点像“概要设计”,这步就开始往开发衔接了,产品UI、业务逻辑的细节都要确定,细化文档并保持更新。相应的,有很多内容,比如表结构设计,要由项目经理来编写了。

功能规格文档(FSD)把焦点集中在实现,定义产品功能需求的全部细节。FSD可能通过一张张的截屏和一条条功能点来定义产品规格。这是一份可以直接让工程师创建产品的文档。

    与MRD和PRD侧重于以市场需要和产品角度看需求不同,FSD把重点放在了以表格形式定义产品细节,再让工程师实现这些细节。FSD也可能包括完整的屏幕截图和UI设计细节。

    FSD通常是由拥有产品分析师,工程领导或者项目经理头衔的人撰写的 – 作者通常属于工程部门。通常一个连续几十页的Word或类似文档。

1) DAU : daily active user,日活跃用户数量
2) MAU : 月活跃用户量
3) ARPU : (Average Revenue Per User)即每用户平均收入,用于衡量电信运营商和互联网公司业务收入的指标。 
4) KPI :关键绩效指标法,是企业绩效考核的方法之一,其特点是考核指标围绕关键成果领域进行选取
5) MOU : 平均每户每月通话时间(minutesof usage)
6) OTT :Over The Top”的缩写,是指通过互联网向用户提供各种应用服务。这种应用和目前运营商所提供的通信业务不同,它仅利用运营商的网络,而服务由运营商之外的第三方提供。目前,典型的OTT业务有互联网电视业务,苹果应用商店等。
7) CPC : 网络中最常见的一种广告形式,它是英文单词Cost Per Click的缩写意思就是每次点击付费广告
8) CPM : Cost Per Mille,或者Cost Per Thousand;Cost PerImpressions,广告投放过程中,听到或者看到某广告的每一人平 均分担到多少广告成本
9) CPA:每行动成本,Cost Per Action,指投放按广告实际效果,即按回应的有效问卷或定单来计费,而不限广告投 放量。CPA的计价方式对于网站而言有一定的风险,但若广告投放成功,其收益也比CPM的计 价方式要大得多。广告主为规避广告费用风险,只有当网络用户点击旗帜广告,链接广告主网页后,才按点击 次数付给广告站点费用。
10) CPR:每回应成本,Cost Per Response,以浏览者的每一个回应计费。这种广告计费充分体现了网络广告“及时反应、直接互动、准 确记录”的特点,但是,这个显然是属于辅助销售的广告模式,对于那些实际只要亮出名字 就已经有一半满足的品牌广告要求,大概所有的网站都会给予拒绝,因为得到广告费的机会 比CPC还要渺茫。
11) CPP:每购买成本,Cost Per Purchase,广告主为规避广告费用风险,只有在网络用户点击旗帜广告并进行在线交易后,才按销售笔 数付给广告站点费用。无论是CPA还是CPP,广告主都要求发生目标消费者的“点击”,甚至进一步形成购买,才予 付费;CPM则只要求发生“目击”(或称“展露”、“印象”),就产生广告付费。
12) PFP:按业绩付费,Pay-For-Performance
13) IP:“Intellectual Property”的缩写,即知识产权
14) ACG:为英文AnimationComicGame的缩写,是动画、漫画、游戏的总称。ACG文化的发源地是日本,以网络及其他方式传播。为华人社会常用的次文化词汇(日本并不使用这个词,在英语为主的国家里也并不普及)。
15) KOL:关键意见领袖(Key Opinion Leader,KOL) 基本上就是在微博上有话语权的那些人。也是我们常说的微博红人之类的,这些人在一些行业可能是专业的,或者非常有经验的,所以他们的话通常都能够让他的粉丝信服。就因为这样KOL的影响力在微博营销的过程中是不可或缺的。那么官微应该和什么样的KOL互动,怎么能影响KOL,让他们和官微互动,甚至是有主动谈论你的冲动。
16) SEO:(Search Engine Optimization)汉译为搜索引擎优化。seo优化是专门利用搜索引擎的搜索规则来提高目前网站在有关搜索引擎内的自然排名的方式。SEO的目的理解是为网站提供生态式的自我营销解决方案,让网站在行业内占据领先地位,从而获得品牌收益。
17) RISC:英文全称是Reduced Instruction Set Computer,中文是精简指令集计算机。特点是所有指令的格式都是一致的,所有指令的指令周期也是相同的,并且采用流水线技术。
18) VR:Virtual Reality即虚拟现实(简称VR),是由美国VPL公司创建人拉尼尔Jaron Lanier,在20世纪80年代初提出的。其具体内涵是:综合利用计算机图形系统和各种现实及控制等接口设备,在计算机上生成的,可交互的三维环境中提供沉浸感觉的技术。其中,计算机生成的,可交互的三维环境成为虚拟环境,即Virtual Environment(简称VE),虚拟现实技术实现的载体是虚拟现实仿真平台,即Virtual Reality Platform(简称VRP)。
19) SOHO :Small Office Home Office,家居办公,大多指那些专门的自由职业者:自由撰稿人、平面设计师、工艺品设计人员、艺术家、音乐创作人、产品销售员、广告制作、服装设计、商务代理、做期货、网站等等。
20) UGC : 互联网术语,全称为User Generated Content,也就是用户生成内容的意思。UGC的概念最早起源于互联网领域,即用户将自己原创的内容通过互联网平台进行展示或者提供给其他用户。UGC是伴随着以提倡个性化为主要特点的Web2.0概念兴起的。
21) UED :(user experience design)用户体验设计。UED的本意是用户体验设计,是英文User Experience Design的缩写。通常的理解,我们做的一切都是为了呈现在您眼前的页面。
22) LBS : 基于位置的服务,它是通过电信移动运营商的无线电通讯网络(如GSM网、CDMA网)或外部定位方式(如GPS)获取移动终端用户的位置信息(地理坐标,或大地坐标),在地理信息系统(外语缩写:GIS、外语全称:Geographic InformationSystem)平台的支持下,为用户提供相应服务的一种增值业务。
23) SNS:Social NetworkingServices,即社会性网络服务,是指个人之间的关系网络,这种基于社会网络关系系统思想的网站就是社会性网络网站(SNS网站)。现在许多WEB2.0网站都属于SNS网站,如网络聊天(IM)、交友、视频分享、博客、播客、网络社区、音乐共享等。社会性网络的理论基础源于六度理论(六度分隔理论,Six Degrees of Separation)和150法则(Rule Of 150)。另外不仅现在一些大公司网站开始了一些SNS应用,一些垂直领域的行业站点也开始了SNS的尝试。目前国外较出名的是facebook、myspac,国内流行的SNS有海内、校内、开心、51等。
24) TMT:数字新媒体,或叫TMT(TechnologyMediaTelecom)产业。TMT是电信、媒体和科技三个英文单词的缩写的第一个字头,整合在一起,实际是未来电信、媒体科技(互联网),包括信息技术这样一个融合趋势所产生的大的背景,这就是TMT产业。
25) SPAM:互联网上到处散布垃圾广告消息的现象。在搜索引擎上的Spam通常也称为作弊。搜索引擎营销中所说的SPAM是专门针对那些欺骗搜索引擎的信息。搜索引擎垃圾技术是利用不道德的技巧去提高自己搜索引擎上的排名。不诚实的网站管理员就是利用这样的手段去欺骗搜索引擎从而获得较高的排名。
26) pv:(pageview),即页面浏览量,或点击量;通常是衡量一个网络新闻频道或网站甚至一条网络新闻的主要指标;
27) uv :(unique visitor),指访问某个站点或点击某条新闻的不同IP地址的人数。 在同一天内,uv只记录第一次进入网站的具有独立IP的访问者,在同一天内再次访问该网站则不计数。
28Adsens :GoogleAdSense 是一种获取收入的快速简便的方法,适合于各种规模的网站发布商。它可以在网站的内容网页上展示相关性较高的 Google广告,并且这些广告不会过分夸张醒目。
29) 马太效应:(Matthew Effect),指强者愈强、弱者愈弱、好的愈好,坏的愈坏,多的愈多,少的愈少的现象,广泛应用于社会心理学、教育、金融以及科学等众多领域。
30) 羊群效应:指人们经常受到多数人影响,从而跟从大众的思想或行为,也被称为“从众效应”。人们会追随大众所同意的,将自己的意见默认否定,且不会主观上思考事件的意义。羊群效应是诉诸群众谬误的基础。
31) 霍桑效应:指那些意识到自己正在被别人观察的个人具有改变自己行为的倾向。
32) 病毒式营销:源于英文词汇viralmarketing。常用于进行网站推广、品牌推广等。利用的是用户口碑传播的原理,在互联网上,这种“口碑传播”更为方便,可以像病毒一样迅速蔓延,因此病毒性营销成为一种高效的信息传播方式,而且,由于这种传播是用户之间自发进行的,因此几乎是不需要费用的网络营销手段。
33) 斯德哥尔摩综合征:指犯罪的被害者对于犯罪者产生情感,甚至反过来帮助犯罪者的一种情结。这个情感造成被害人对加害人产生好感、依赖心、甚至协助加害人。人质会对劫持者产生一种心理上的依赖感。他们的生死操控在劫持者手里,劫持者让他们活下来,他们便不胜感激。他们与劫持者共命运,把劫持者的前途当成自己的前途,把劫持者的安危视为自己的安危。于是,他们采取了“我们反对他们”的态度,把解救者当成了敌人。
34) 长尾理论 : 网络时代兴起的一种新理论,由于成本和效率的因素,当商品储存流通展示的场地和渠道足够宽广,商品生产成本急剧下降以至于个人都可以进行生产,并且商品的销售成本急剧降低时,几乎任何以前看似需求极低的产品,只要有卖,都会有人买。这些需求和销量不高的产品所占据的共同市场份额,可以和主流产品的市场份额相比,甚至更大。

3.2 Why use linux system

我们项目 开发环境 使用的是 自己的电脑:windows操作系统  安装idea 进行代码开发
我们项目 生产环境 使用的是 服务器电脑:linux操作系统
    
为什么 生产环境 使用的是 linux操作系统 ? 能不能用windows?
    
所以我们平时使用的是windows操作系统  Linux很多人没接触过过 我们就要学习一下

3.3 Introduction to Linux

 A 个人桌面领域的应用  此领域是传统linux应用最薄弱的环节,传统linux由于界面简单、操作复杂、应用软件少的缺 点,一直被windows所压制,但近些年来随着ubuntu、fedora [fɪˈdɔ:] 等优秀桌面环境的兴 起,同时各大硬件厂商对其支持的加大,linux在个人桌面领域的占有率在逐渐的提高。
     
 Linux 也是有图形界面的  但是不好看 而且不好用  windows 强项就是图形操作
     
 B 服务器领域  linux在服务器领域的应用是最强的。 linux免费、稳定、高效等特点在这里得到了很好的体现,近些年来linux服务器市场得到了飞 速的提升,尤其在一些高端领域尤为广泛。

 C 嵌入式领域   近些年来linux在嵌入式领域的应用得到了飞速的提高、linux运行稳定、对网络的良好支持性、低成本,且可以根据需要进行软件裁剪,内核最小 可以达到几百KB等特点,使其近些年来在嵌入式领域的应用得到非常大的提高主要应用:机顶盒、数字电视、网络电话、程控交换机、手机、PDA、智能家居、智能硬件 等都是其应用领域。以后再物联网中应用会更加广泛。

3.4 Types of Linux

insert image description here

windows:  win7  win8  win10 win11
安卓系统: 小米米有系统   华为安卓系统  三星安卓系统  锤子安卓系统  魅族安卓系统    主题
Linux 基本内核  很多人根据Linux基础 开发出来的一些列系统 centos   Redhat

3.5 Linux server

我们安装操作系统 需要电脑( 学习的时候  Linux 多个 一台电脑 )
有几种方案:
1 把你电脑 windows干掉 换成Linux    x
2 电脑装双系统                     x
3 购买云系统                       学习不行     企业可以
4 内部服务器集群                    学习可以   大企业可以
    
5 虚拟机技术  
    类似于 模拟器  
 此时只能使用 虚拟机技术。 
    
 VM        虚拟机
 CentOS    Linux一种镜像
 Xshell    远程连接linux的工具
 Xftp      远程文件传输 

3.6 Software installation

1 安装虚拟机
2 安装centos

3.7 Configure the virtual machine

A Automatically obtain ip

A Whether the ping network is smooth

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-WUtxIALH-1665382242182)(.../.../courseware/qy134/framework/linux/assets/wps3.jpg)]

B View network information ip addr

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-XKm4i4x3-1665382242183)(.../.../courseware/qy134/framework/linux/assets/wps4.jpg)]

C Dynamically obtain ip address dhclient

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-ShwOr3Mf-1665382242183)(.../.../courseware/qy134/framework/linux/assets/wps5.jpg)]
insert image description here

B manually set ip

①Virtual network

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-ibMhR7UG-1665382242184)(.../.../courseware/qy134/framework/linux/assets/wps7.jpg)]

Host-only mode: The real environment and the virtual environment are isolated; in this mode, all virtual systems can communicate with each other, but the virtual system and the real network are isolated. (The virtual system and the host machine system can communicate with each other, which is equivalent to the interconnection of the two machines through a twisted pair.) The only difference from nat is that in this way, there is no address translation service, so by default , the virtual machine can only be accessed by the host. -------The host can be pinged, but cannot access the Internet;

Bridge mode: In bridge mode, the operating system virtualized by VMWare is like an independent host in the LAN (the host and the virtual machine are in the same position), and it can access any machine in the network. We often need to configure IP address, subnet mask, etc. for the virtual host (note that the ip address of the virtual host should be in the same network segment as the host ip address). In this way, the virtual machine can communicate with the host independently (of course, as long as it can communicate with the virtual machine in the same LAN), at the same time, after configuring the gateway and DNS addresses, it can be accessed through the gateway or router of the LAN the Internet. . ------It can be pinged with the host host and can access the Internet;

NAT mode: It is to let the virtual system use the NAT (Network Address Translation) function to access the public network through the network where the host machine is located. Using NAT mode can realize accessing the Internet in the virtual system. To put it simply, the host machine builds a local area network, and then there is only one machine in the local area network, which is the virtual machine. The TCP/IP configuration information of the virtual system in NAT mode is provided by the DHCP server of the VMnet8 (NAT) virtual network and cannot be manually modified, so the virtual system cannot communicate with other real hosts in the local area network. The biggest advantage of using the NAT mode is that it is very simple for the virtual system to access the Internet. You only need the host machine to access the Internet. You do not need to configure the IP address, subnet mask, and gateway, but the DNS address still needs to be filled in according to the actual situation. --------The host cannot be pinged, but can access the Internet;

The nat mode can access the Internet but cannot communicate with the host computer. In theory, it is safer. No matter what damage is done to the virtual system, it will not affect the host computer. The bridge mode is equivalent to connecting an independent host to the switch, which is generally used to provide services in the subnet.

Summary: If you want the virtual machine to access the external network, you can use the Nat mode. If you want to communicate with the host, you can use the bridge mode. The premise is to set your own independent ip in the LAN. If the host cannot ping the virtual machine, it is likely to be The virtual machine's firewall is not turned off.

[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-kUkQPEin-1665382242184)(.../.../courseware/qy134/framework/linux/assets/image-20210707111839006.png )]

Gateway 192.168.239.2

输入命令  vi  /etc/sysconfig/network-scripts/ifcfg-ens33   回车
进入网络配置的页面  然后点击 i  此时进入insert编辑模式

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-ajPVuFxg-1665382242185)(.../.../courseware/qy134/framework/linux/assets/image-20201216165917174.png )]

修改完成之后   按esc  找到UUID这一行  双击 d 删除UUID  再按 :wq  回车 保存并退出  
此时重启网络服务   service  network  restart
此时在使用 ip addr 查看网卡信息 发现已经修改成功
通过  ping www.baidu.com  验证是否能联网 ctrl+c 中断ping的输出

3.2.2 Turn off the firewall in linux

 关闭网络防火墙
systemctl  status  firewalld 查看当前防火墙状态
systemctl  stop    firewalld 关闭当前防火墙。
systemctl  disable firewalld 开机防火墙不启动。

查看指定区域所有打开的端口
firewall-cmd --zone=public --list-ports

在指定区域打开端口(记得重启防火墙firewall-cmd  --reload)
firewall-cmd --zone=public --add-port=80/tcp --permanent
 说明:
   –zone 作用域
   –add-port=8080/tcp 添加端口,格式为:端口/通讯协议
   –permanent #永久生效,没有此参数重启后失效

Our linux needs to turn off the firewall, because when we configure the following clusters, if the firewall is not closed, there may be inexplicable problems.

The firewall is not closed in the company. At this time, some ports are inaccessible from the outside, and we need to open these ports.

3.2.3 Set time

cal 查看日期
date查看时间
更新时间 -- 网络时间协议服务 ntpd
安装服务  yum  -y    install  ntp ntpdate
同步服务时间  ntpdate ntp1.aliyun.com
开启自动同步 service  ntpd start
开机自启同步 systemctl enable  ntpd

3.2.4 xshell connection

Four Basic Operations of Linux

4.1 Power on and off

shutdown:关机指令;
shutdown –h 10 ‘This server will shutdown after 10 mins’ 这个命令告诉大家,计算机将在10分钟后关
机,并且会显示在登陆用户的当前屏幕中。
shutdown –h now:立马关机
shutdown –h 20:25:系统会在今天20:25关机
shutdown –h +1010分钟后关机

halt:关闭系统,等同于shutdown –h now 和   
poweroff
init 0:关机

shutdown –r now:系统立马重启
shutdown –r +10:系统10分钟后重启
reboot:就是重启,等同于 shutdown –r now
init 6:重启

4.2 Command format in linux

[root@localhost ~]#

①命令提示符
[]:这是提示符的分隔符号,没有特殊含义。

root:显示的是当前的登录用户,我们现在显示的是root 因为我们使用的是超级管理员账号登录的 注意以后可能我们就没有root账号使用了。

@:分隔符号,没有特殊含义。

localhost:当前系统的简写主机名(完整主机名是 localhost.localdomain)。
           我们可以自己去编写主机名 。
           vi   /etc/hostname      双击d  点击 i 进入编辑模式  自己起名字 例如 redis120  ng130  zk140  haha150
           vi   /etc/hosts    添加hosts

~:代表用户当前所在的目录,此例中用户当前所在的目录是家目录。

#:命令提示符,Linux 用这个符号标识登录的用户权限等级。如果是超级用户,提示符就是 #;如果是普通用户,提示符就是 $。

②命令的基本格式

[root@localhost ~]# 命令       [选项]   [参数]  
                    shutdown   -h      10

命令格式中的 [] 代表可选项,也就是有些命令可以不写选项或参数,也能执行
1、命令: 表示命令的名称,如 ls
2、选项:定义命令的执行特性,可以有长短两种选项: 
    长选项:用 -- 引导,后面跟完整的单词,如 --help
    短选项:用 - 引导, 后面跟单个的字符,如 -a
        
(1)多个短选项可以组合使用,例如: -h -l -a == -hla,但是长选项不能组合使用,如 --help后面就不能再跟另外一个单词了。
(2)option 也可以有自己的参数,注意:选项与选项之间,选项与参数之间,参数与参数之间必须有空格!

3、参数:描述命令作用的对象,如/etc 就是ls 命令作用的对象。



如果有linux命令不知道  就找个男人来帮忙

insert image description here

3.3.3 Linux folder

insert image description here

Here is an explanation of these directories:

*/bin* : bin is the abbreviation of Binaries (binary files), this directory stores the most frequently used commands.

****/boot: **** Here are some core files used when starting Linux, including some connection files and mirror files.

****/dev : ****dev is the abbreviation of Device (device). The external devices of Linux are stored in this directory. The way of accessing devices in Linux is the same as the way of accessing files.

****/etc: ****etc is the abbreviation of Etcetera (etc.), this directory is used to store all configuration files and subdirectories required for system management.

*/home* : The user's home directory. In Linux, each user has his own directory. Generally, the directory name is named after the user's account, such as alice, bob, and eve in the above figure.

*/lib* : lib is the abbreviation of Library (library). This directory stores the most basic dynamic link shared library of the system, and its function is similar to the DLL file in Windows. Almost all applications need to use these shared libraries.

*/lost+found* : This directory is usually empty. When the system is shut down illegally, some files are stored here.

*/media* : Linux system will automatically recognize some devices, such as U disk, CD-ROM, etc. After recognition, Linux will mount the recognized devices to this directory.

*/mnt* : The system provides this directory to allow users to temporarily mount other file systems. We can mount the CD-ROM on /mnt/, and then enter this directory to view the contents of the CD-ROM.

*/opt* : opt is the abbreviation of optional (optional), which is the directory for installing additional software on the host. For example, if you install an ORACLE database, you can put it in this directory. Default is empty.

*/proc* : proc is the abbreviation of Processes (process), /proc is a pseudo file system (that is, a virtual file system), which stores a series of special files of the current kernel running state, this directory is a virtual directory , which is a mapping of system memory, we can get system information by directly accessing this directory. The content of this directory is not on the hard disk but in the memory. We can also directly modify some files in it. For example, the following command can be used to block the ping command of the host so that others cannot ping your machine: echo 1 > /proc /sys/net/ipv4/icmp_echo_ignore_all

*/root* : This directory is the home directory of the system administrator, also known as the user with super authority.

*/sbin* : s is the meaning of Super User, which is the abbreviation of Superuser Binaries (binary files of super users), and the system management program used by system administrators is stored here.

*/selinux* : This directory is unique to Redhat/CentOS. Selinux is a security mechanism, similar to the Windows firewall, but this mechanism is more complicated. This directory is for storing selinux-related files.

*/srv* : This directory stores some data that needs to be extracted after the service is started.

*/sys* : This is a big change in the Linux2.6 kernel. A new file system sysfs in the 2.6 kernel is installed in this directory. The sysfs file system integrates the information of the following three file systems: the proc file system for process information, the devfs file system for devices, and the devpts file system for pseudo-terminals. The file system is a visual reflection of the kernel device tree. When a kernel object is created, corresponding files and directories are also created in the kernel object subsystem.

*/tmp* : tmp is an abbreviation of temporary (temporary). This directory is used to store some temporary files.

*/usr* : usr is the abbreviation of unix shared resources (shared resources), this is a very important directory, many applications and files of users are placed in this directory, similar to the program files directory under windows.

****/usr/bin: ****Applications used by system users.

****/usr/sbin: ****A more advanced management program and system daemon used by super users.

****/usr/src: ****The default directory where the kernel source code is placed.

*/var* : var is the abbreviation of variable (variable). This directory stores things that are constantly expanding. We are used to putting those frequently modified directories in this directory. Includes various log files.

*/run* : It is a temporary file system that stores information since the system was started. When the system restarts, the files in this directory should be deleted or cleared. If you have a /var/run directory on your system, it should point to run. In the Linux system, several directories are more important, and you need to be careful not to accidentally delete or change internal files at will.

*/etc* : As mentioned above, this is the configuration file in the system. If you change a file in this directory, the system may not start.

*/bin, /sbin, /usr/bin, /usr/sbin* : This is the directory where the system presets the execution files. For example, ls is in the /bin/ls directory.

It is worth mentioning that /bin, /usr/bin are commands for system users (common users except root), while /sbin, /usr/sbin are commands for root.

*/var* : This is a very important directory. There are many programs running on the system, so each program will have a corresponding log, and these logs will be recorded in this directory, specifically in the /var/log directory , and the default placement of mail is also here.

3.3.4 Linux file directory operation

 pwd :Print the name of the current working directory.本命令用于显示当前的工作目录
 cd:  Change the shell working directory. 本命令用于改变当前的工作目录   相对和绝对   cd .. 回退上一级
 ll  ls :命令列出指定目录下的文件,缺省目录为当前目录
 
 
 touch:将指定文件的访问时间和修改时间改变,若指定文件不存在则创建之,若无指定时间,则使用当前时间,返回值是未成功改变时间的文件个数,包括不存在而又未能创建的文件。 
 mkdir:本命令用于建立目录
 rmdir:本命令用于删除目录
 
 cp:将文件1(文件2 ...)拷贝到目标上,目标不能与文件同名, 若目标是文件名,则拷贝的文件只能有一个,若目标是目录, 则拷贝的文件可以有多个,若目标文件不存在,则建立这个文件,若存在,则覆盖其以前的内容,若目标是目录,则将文件拷贝到这个目录下。
 mv:将文件移动至目标,若目标是文件名,则相当于文件改名
 rm:用来删除文件或目录    rm -rf aaa  递归删除并且不询问是否删除
 
 cat 显示和连接一个或多个文件至标准输出 
 head 将文件的头n 行显示输出,缺省值为 10 行,显示多个文件时,在每个文件的前面加上 ==> 文件名 <== 
 
 head -n 10  login.vue
 tail -n 10  login.vue  面试题 查看日志命令 
 
 xftp共享文件到linux
 
 more 将文件显示在终端上,每次一屏,在左下部显示 --more--,若是从文件读出而非从管道,则在后面显示百分比,表示已显示的部分,按回车键则上滚一行,按空格键则上滚一屏,未显示完时可以使用more 命令中的子命令。
 less 和more一样 但是快   
 
 wc   统计文件的行、字、字符数,若无指定文件,则统计标准输入
 find 命令递归地遍历指定路径下的每个文件和子目录
 grep 在指定的文件中搜索模式  grep 'html' student.html
 diff 本命令比较两个文本文件,将不同的行列出来
 cmp 比较两个文件,若文件1 为 "-" ,则使用标准输入, 两个文件相同则无提示,不同则显示出现第一个不同时的字符数和行号。

3.3.5 yum source in linux

2.7.1 什么是yum
Yum(全称为 Yellow dog Updater, Modified)是一个在FedoraRedHat以及CentOS中的Shell前端软件包管理器。基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装
    
2.7.2 yum的常用命令
安装软件(以foo-x.x.x.rpm为例):yum install foo-x.x.x.rpm
删除软件:yum remove foo-x.x.x.rpm或者yum erase foo-x.x.x.rpm
升级软件:yum upgrade foo或者yum update foo
查询信息:yum info foo
搜索软件(以包含foo字段为例):yum search foo
显示软件包依赖关系:yum deplist foo
-q 静默执行
-t 忽略错误
-R[分钟] 设置等待时间
-y 自动应答yes
--skip-broken 忽略依赖问题
--nogpgcheck 忽略GPG验证
2.7.3 使用清华镜像仓库
https://mirrors.cnnic.cn/help/centos/

以上步骤可以被下方的命令一步完成

sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
         -e 's|^#baseurl=http://mirror.centos.org|baseurl=https://mirrors.tuna.tsinghua.edu.cn|g' \
         -i.bak \
         /etc/yum.repos.d/CentOS-*.repo

注意其中的*通配符,如果只需要替换一些文件中的源,请自行增删。

注意,如果需要启用其中一些 repo,需要将其中的 enabled=0 改为 enabled=1

最后,更新软件包缓存
     
sudo yum makecache

2.7.4 wegt
wget是Linux中的一个下载文件的工具,wget是在Linux下开发的开放源代码的软件,作者是Hrvoje Niksic,后来被移植到包括Windows在内的各个平台上。它用在命令行下。对于Linux用户是必不可少的工具,尤其对于网络管理员,经常要下载一些软件或从远程服务器恢复备份到本地服务器。如果我们使用虚拟主机,处理这样的事务我们只能先从远程服务器下载到我们电脑磁盘,然后再用ftp工具上传到服务器。这样既浪费时间又浪费精力,那不没办法的事。而到了Linux VPS,它则可以直接下载到服务器而不用经过上传这一步。wget工具体积小但功能完善,它支持断点下载功能,同时支持FTP和HTTP下载方式,支持代理服务器和设置起来方便简单
相当于用浏览器下载
安装wegt: yum install   -y     wget   
wget https://download.redis.io/releases/redis-6.0.9.tar.gz

2.7.5  yum  wget  rpm的区别

wget 是一个Linux shell命令行下的一个下载工具,通常我们可以去拿这个命令去下载一些安装包,可以是编译tar包, 也可以是rpm包,也可以是其他格式的文件,最后通过其他方式进行本地手动安装。类似于windows系统里的网页下载

rpm 是一个RedhatCentOS下的一个包管理工具,他用来安装我们从远程下载下来的.rpm格式的安装包, 缺点是如果你安装的tools如果有版本依赖,你需要逐个去下载并手动安装,比较耗费时间。类似于windows系统里.exe的安装

yum 是一个在rpm基础上支持在线查找包依赖一个包管理工具,他的本质其实也是用来安装.rpm文件,优点在于他可以从你事先配置好的仓库中抓取所有你需要安装的工具的所有依赖,一并安装,这样子其实就是方便快速安装你需要的软件,避免长时间耗费在查找依赖上
     

3.3.6 Compression and decompression

① gzip 和 gzip  -d   gzip只能压缩文件 , 不能压缩目录 ,后缀名为.gz , 而且不保留原文件
  gzip  文件名   gzip -d  文件名


② bzip2   yum -y install  bzip2.x86_64 效率比gzip高 -k可以保留源文件,使用方式和gzip差不多


③ tar 语法:tar [-zcf] 压缩后文件名  文件或目录
-c    建立一个压缩文件的参数指令(create),后缀是.tar
-x    解开一个压缩文件的参数指令(extract)
-z    以gzip命令压缩/解压缩  
-j    以bzip2命令压缩/解压缩
-v    压缩的过程中显示文件(verbose)
-f     file 指定文件名,必选项
tar -zxvf 文件名     解压的
tar -zxvf  压缩包名字

tar -zcvf 文件名     压缩的
tar -zcvf  压缩后名字    要压缩的文件们.......

注意: 在tar命令中  f必须是最后一个

yum -y  install  vim*

Five vim editors

5.1 Introduction to vim

Vim is a well-known powerful and highly customizable text editor similar to Vi. It has improved and added many features on the basis of Vi. VIM is free software. Vim is generally hailed as the best of the Vi-like editors, in fact the real rivals come from different variants of Emacs. In 1999, Emacs was selected as the winner of the Linuxworld text editing category, and Vim came in second. But in February 2000, Vim won the Slashdot Beanie's Best Open Source Text Editor Award, and pushed Emacs to the second line. In general, Vim and Emacs are very good in text editing. In the past, our linux came with it, and it needs to be installed after c7.

3.4.2 vim installation

yum -y  install  vim*

3.4.3 Comparison between vi and vim

[root@localhost test]# vi student.html 
[root@localhost test]# vim  student.html 

3.4.4 vim three modes

insert image description here

Basically vi/vim is divided into three modes,

They are Command mode, Insert mode and Last line mode.

The functions of these three modes are:

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-YJC5ezYu-1665395778264)(.../.../courseware/qy134/framework/linux/assets/wps1-1608270567645.jpg )]

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-Ch7Tj7pt-1665395778265)(.../.../courseware/qy134/framework/linux/assets/image-20210708114734732.png )]

3.4.4 Vim common commands

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-x82zrNKu-1665395778265)(.../.../courseware/qy134/framework/linux/assets/wps2-1608272239250.jpg )]

三种状态进行切换
插入模式:
【i】:在当前光标所在字符的前面,转为输入模式
【a】:在当前光标所在字符的后面,转换为输入模式
【o】:在当前光标所在行的下方,新建一行,并转换为输入模式:
【I】:在当前光标所在行的行首,转换为输入模式
【A】:在当前光标所在行的行尾,转换为输入模式
【O】:在当前光标所在行的上方,新建一行,并转换为输入模式;

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-PgbZhjy8-1665395778265)(.../.../courseware/qy134/framework/linux/assets/image-20201218142354825.png )]

退出命令
【:q】退出
【:x】保存退出
【:wq】保存并退出
【:q!】强制退出并hu略所有更改
快捷键滚动
【Ctrl + e】向下滚动一行
【Ctrl + y】向上滚动一行
【Ctrl + d】向下滚动半屏
【Ctrl + u】向上滚动半屏
【Ctrl + f】向下滚动一屏
【Ctrl + b】向上滚动一屏  
复制命令(y,yank)
 【y】复制,可以结合光标跳转字符,实现范围复制(行为与d有类似之处)
 【y$】复制到行尾
 【y^】复制到非空行首
 【y0】复制到行首
 【yy】复制当前行
 【#yy】复制多行
 【Y】整行复制     
 
粘贴命令(p,paste)
 【p】缓冲区存的如果为整行,则粘贴当前光标所在行的下方,否则粘贴至当前光标所在处的后面
 【P】缓冲区存的如果为整行,则粘贴当前光标所在行的上方,否则粘贴至当前光标所在处的前面
部分粘贴
 【v】+方向键 +【y】+【p】
撤销更改
【u】撤销最近的更改
【#u】撤销之前多次更改
【U】撤销光标落在这行后所有此行的更改
【按Ctrl + r】重做最后的“撤销”更改(相当于取消撤销)
替换操作
【r】替换光标所在字符
【R】切换成REPLACE模式
删除操作
【x】删除光标处的字符
【#x】删除从光标处开始向后#个字符
【xp】光标所在处的字符和光标后面的字符对调位置
【J】删除当前行后的换行符
【dd】删除光标所在行
【#dd】多行删除
【d$】删除到行尾
【d^】删除到非空行首
【d0】删除到行首
【dG】删除到末尾
【D】从当前光标位置一直删除到行尾,留空行 
查找
【:/PATTERN】从当前光标所在处向文件尾部查找匹配“PATTERN”相同的内容。
【:?PATTERN】从当前光标所在处向文件首部查找匹配“PATTERN”相同内容
【n】与命令同方向【N】与命令反方向

 替换
格式:【s/要查找的内容/替换为的内容/修饰符】【s】【%s】全局替换
修饰符: 【i】忽略大小写【g】管局替换;默认情况下,每行只替换第一次出现【gc】全局替换,每次替换前询问
命令模式    dd     i
底行模式    :wq   :q!      :%s/要替换的/替换成啥/ig

.5 Linux rights management operations

There are strict permission levels on the Linux server. If the permissions are too high, misoperation will increase the risk of the server. Therefore, it is very important to understand the various permissions in the linux system and to assign reasonable permissions to users and services.

Linux systems generally make files read/write accessible

Identity is divided into 3 categories: owner, group, others,

And the three identities have read, write, execute and other permissions respectively.

File A owner (wre) group member (wre) other group (wre)

3.5.1 Permission Introduction--What is Permission?

​ In the management of multi-user computer systems, authority means that a specific user has specific system resource usage rights, such as folders, the use of specific system instructions, or storage restrictions.

3.5.2 Identity introduction

****Owner identity (file owner, document creator by default)****Because Linux is a multi-user and multi-tasking operating system, there may often be multiple people working on a host at the same time, but everyone File permissions can be set on the host to make it a personal "private file", that is, the individual owner. Because the appropriate file permissions are set, users other than me (the file owner) cannot view the file contents. For example, a MM sent you an email love letter, and you converted the love letter into a file and archived it in your home folder. In order to prevent others from seeing the content of the love letter, you can use the identity of the owner to set the appropriate permissions of the file, so that even if your love rival wants to peek at the content of your love letter, it is impossible. |

****Group identity (users in the same group as the file owner)**** is very useful for team collaboration. For example, there are two groups A and B on the host, A has three members a1, a2, and a3, and B has two members b1 and b2. These two groups need to complete a report F together. Due to the setting of appropriate permissions, members of groups A and B can modify each other's data, but members of group C cannot modify the content of F, and even have no permission to view it. At the same time, members of the group can also set their own private files, so that other members of the team cannot read the file data. In Linux, each account supports multiple user groups. For example, users a1 and b1 can belong to user group A or user group B. 【Main Group and Additional Group】

****Others identity (others) **** relative concept, other users

****root user (super user)**** There is a super user besides users and user groups. Please use it with caution in specific operations. Manage common users.

3.5.3. Linux permission introduction

To set permissions, you need to know some basic attributes of the file and the rules for assigning permissions. In Linux, the Is command is often used to view the attributes of a file, and is used to display the file name and related attributes of the file. ll is equivalent to ls -l

The file list information is divided into:

File type, permission, number of links, user, user group, file size, last modification time, file name.

[External link picture transfer failed, the source site may have an anti-leech link mechanism, it is recommended to save the picture and upload it directly (img-Y17sp07Y-1665395778266)(.../.../courseware/qy134/framework/linux/assets/image-20201218154738386.png )]

Linux has a total of 7 file types, as follows:

-: ordinary file d: directory file l: soft link (similar to Windows shortcut)

(The following four are special files)

b: block device file (such as hard disk, CD-ROM, etc.) p: pipeline file

c: character device file (such as serial device such as cat)

s: socket file/data interface file (for example, a mysql.sock file will be generated when starting a MySql server)

File Permission Correspondence

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-StndFxGN-1665395778266)(.../.../courseware/qy134/framework/linux/assets/wps3-1608278036897.jpg )]

There are concepts of users, user groups and others in Linux, and each has different permissions. For a file, its permissions

The specific distribution is as follows:

In the permission assignment, it is a combination of the three parameters of rwx, and the position order will not change. If there is no corresponding permission, use - instead.

Of course, we can also modify the permissions of the file. The chmod command in Linux can be used to change the permissions of files or directories.

Syntax: chmod (option) mode filename

Common options: -r

Note: If you want to set permissions for a document, the operator must either be the root user or the owner of the document.

1. Letter form

Option letter description

Identity u user, representing the file owner

identity g usergroup

identity o other user

identity a all

Operation + Add Permission

Action - Reduce privileges

Action = OK Permissions

permission r readable

Permission w is writable

permission x executable

此时我们ll 操作一波

-rw-r--r--. 1 root root 7998 Dec 18 15:43 student.html

需要将拥有者的权限改成 读写可执行
chmod   u+x  student.html

需要将所有人的权限干掉读
chmod   a-r  student.html
chmod   +r   student.html


2 digital form

Numeric permission directory list

​ 0 No permission—

​ 1 executable --x

​ 2 Can write -w-

​ 3 writable, executable -wx

4 Read r–

5 Readable and executable rx

​ 6 Readable and writable rw-

​ 7 Readable, writable and executable rwx

              var  a  = 0xbb;  
			  var  b  = 456;
			  var  c  = 0456;
			  var  d  = 0B10;
			  二进制与十进制之间的转换
数字设定权限
chmod  644 student.html 

3.6 User Operation

Linux is an operating system that can realize multi-user login. Users share some host resources, but they also have their own user space for storing their own files. But in fact their files are placed on the same physical disk or even in the same logical partition or directory, but due to Linux user management and permission mechanism, different users cannot easily view and modify each other's files.

3.6.1 User Operation

A who View the currently logged in user

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-sSL1mE9v-1665395778267)(.../.../courseware/qy134/framework/linux/assets/wps4-1608280286778.jpg )]

A cat /etc/passwd to view all user information

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-qYiIf9BG-1665395778268)(.../.../courseware/qy134/framework/linux/assets/wps5-1608280286779.jpg )]

Super user (root, UID=0) means that the user with UID 0 is a super user, as long as the UID of the corresponding user in /etc/passwd is changed to 0, the user becomes a super user

Ordinary users (uid 500-60000) are the users we usually use

Pseudo (system) users (UID 1-499) Pseudo-users are related to system and program services, because they are not real users, so they are called pseudo-users, such as bin, daemon, shutdown, halt, etc., any Linux system has these by default Pseudo-users; mail, ftp, sshd, etc., are related to the process of the Linux system;

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

1: Username, the username used when the user logs in to the system

2: password bits

3: UID, user identification number

4: GID, the default group identification number

5: Annotative description

6: Host directory, the default directory after the user logs in to the system

7: The shell used by the user, the default is bash

3.6.2 Add new user

useradd 添加用户
    -c comment 指定一段注释性描述。
    -d 目录 指定用户主目录,如果此目录不存在,则同时使用-m选项,可以创建主目录。
    -g 用户组 指定用户所属的用户组。
    -G 用户组,用户组 指定用户所属的附加组。
    -s Shell文件 指定用户的登录Shell。
    -u 用户号 指定用户的用户号,如果同时有-o选项,则可以重复使用其他用户的标识号。
useradd  -u  10086  -g root  -G root  -c 'hahahah'   zhangsan
useradd  lisi
添加密码  passwd  zhangsan

3.6.3 Switch user

切换用户
① 可以重新连接
② su zhangsan

4.5 修改用户  usermod
-l 用户名login   -g group所属组 -G 所属从组  -L 锁定  -U 解锁
usermod -l zhangsanfeng  zhangsan
4.6 删除用户
userdel -r zhangsanfeng
4.7 查看组  cat  /etc/passwd
4.8 添加组  groupadd AAA
4.9 修改组  groupmod -n BBB  AAA
4.10 删除组 groupdel BBB

3.7 Process Management

5.1 View process top ps

Filter and find the process ps -ef | grep ps
filter the network port number
A install netstat yum -y install net-tools
B find the port number netstat -tp | grep 8080
C find the process number according to the process

5.2 Killing a process

kill -9 5222

[root@localhost ~]# ps -ef | grep ping
root 3989 3972 0 16:54 pts/0 00:00:00 ping www.baidu.com
root 3992 3908 0 16:55 pts/1 00:00:00 grep --color=auto ping
[root@localhost ~]# kill -9 3989

Guess you like

Origin blog.csdn.net/Liu_wen_wen/article/details/127243614