linux 开发角度学习总结(持续更新中···)

学前必看

	一个不会运维的开发就是打代码的流氓。
		作为新晋的开发小生,虽然开发近两年来学习和接触了不少的测试和开发环境,由于linux相较于window更适合做服务容器,所以linux是必不可少的知识范围。
		记得在开视频学习时老师说的一个很不错的一句话:"要有目的性的学习";学习了就要做点事情,首先我们的目标是在linux上搭建我们想要运行的项目,例如:一个java开发的webapp,这样就抱着目的性的学习会增加很多效率。

linux基础概念

linux历史不重要,就算我把他的历史写下来你也记不住,所以只要记得的是他有比window有更高的效率和安全性就行了。
学习linux我们可以对比着window来学习,例如:查看文件,新建文件,编辑文件,各种服务的设置,开启,关闭等(例如:net start mysql 熟悉吧),以及安装和卸载软件。

各文件目录解释

文件名字解释
bin存放二进制可执行文件(ls,cat,mkdir等)
boot存放用于系统引导时使用的各种文件
dev用于存放设备文件
etc存放视同配置文件
h o n e \color{red}{hone} hone存放视同配置文件
etc存放所有用户文件的根目录
lib存放跟文件系统中的程序运行所需要的的共享库以及内置模块
mnt系统管理员安装临时文件系统的安装点
opt额外安装的可选应用程序包所放置的位置
proc虚拟文件系统,可存放当前的内存的映射
root超级用户目录
sbin存放二进制可执行文件,只有root才能访问
tmp用于存放各种临时文件
u s r \color{red}{usr} usr用户存放系统应用程序,比较重要的目录/usr/local/ 本地管理员软件安装目录
var用于存放运行时需要改变数据的文件

注意: 除了上面红色字体的目录其他的目录我们讲道理我们是不可以动的,一般我们安装的东西都是在 /usr/local/目录下 ;其他的均由系统自行维护,切记!!!

常用命令

命令说明语法参数参数说明
ls显示文件和目录列表ls[-alrtAER][name...]-l列出文件的详细信息/td>
-a列出当前目录所有文件,包含隐藏文件
mkdir创建目录mkdir[-p]dirName-p父目录不存在情况下生成父目录
cd切换目录cd[dirName]
touch生成空文件
echo生成一个带内容文件echo abcd .1.txt ,echo 1234 >> 1.txt
cat显示文本内容cat[-AbeEnstTuv][-help][-version]fileName
cp复制文件或者目录cp[options]source dest
rm删除文件rm[options]name...-f强制删除文件或者目录
-r同时删除该目录下的所有文件
find在文件系统中直接指定的文件-name文件名
grep在指定的文件中查找指定的字符串
tree用于以树状图列出目录的内容
pwd显示当前工作目录
ln建立软连接
more分页显示文件内容
head显示文件开头内容
tail显示文件结尾内容-f跟踪输出

常用系统命令

命令名字 命令 语法 参数 参数说明
关机/重启shutdownshutdown[-t seconds][-rkhncfF]time[message]-t second设定在几秒钟后进行关机程序
-k并不会真的关机,只是将警告信息传送给所有使用者
-r关机后重新开机(重启)
-h关机后停机
-n不采用正常程序来关机,用强迫的方式杀掉所有执行中的程序后自行关机
-c取消目前进行中的关机动作
-F关机时,强迫进行fsck动作
time设置关机时间
message传送给所有使用者的警告信息
关机shutdown -h now
重启shutdown -r now
reboot

系统指令  极端重要!!!

指令名字解释
stat显示指定文件的相关信息比ls命令显示内容更多
who显示在线登录用户
hostname 显示主机名称
uname 显示系统信息
hostname 显示主机名称
top 显示当前系统中耗费资源最多的进程
ps 显示瞬间的进程状态
du显示指定的文件(目录)已使用的磁盘空间总量
df显示文件系统磁盘空间的使用情况
free显示当前内存和交换空间的使用情况
ifconfig显示网络接口信息
ping测试网络的连通性
netstat显示网络状态信息
clear清屏
kill杀死一个进程

常用配置

centos 7 配置 yum源。

在配置之前我们需要验证我们是否联网

 $ ping www.baidu.com

在这里插入图片描述
这样就代表我们是连接互联网的证据。

由上面表格里面的描述我们可以知道,在linux中所有的系统配置都在 /etc 目录下,所以我们先需要备份原来的配置。

1.先备份 CentOS-Base.repo 文件。

$ sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

2.把下面的这段话,复制到 /etc/yum.repos.d/CentOS-Base.repo中。

$ vim /etc/yum.repos.d/CentOS-Base.repo

3.按 I 键。 复制下面的代码。在vim 进去的面板里按 shift + insert 键。

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

4.最后更新软件包缓存。

$ sudo yum makecache

权威连接:https://mirrors.cnnic.cn/help/centos/

ubuntu 配置 apt-get源。

1. 原文件备份

sudo mv /etc/apt/sources.list /etc/apt/sources.list_bk

2. 编辑源列表文件

sudo vim /etc/apt/sources.list

3. 添加如下内容

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

4. 更新源

$ sudo apt-get update

【荐】资源连接推荐

【干货】docker 系统学习总结 -持续集成交付 (开发人员学习版本) 正在更新

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值