Linux-网络管理
参考文献
hosts
1cat -n /etc/hosts
hostname
1cat /etc/hostname
查看ip地址
123hostname --ip-addresshostname -I
黑白名单
/etc/hosts.allow 白名单
123456789# /etc/hosts.allow: list of hosts that are allowed to access the system.# See the manual pages hosts_access(5) and hosts_options(5).## Example: ALL: LOCAL @some_netgroup# ALL: .foobar.edu EXCEPT terminalserver.foobar.edu## If you're going to protect the portmapper use the name "rpcbind" for the# daemon name. ...
Linux工具-rsync
参考文献
rsync
rsync用于在两个远程计算机之间同步文件和文件夹.它仅通过传输源和目标之间的差异来提供快速的增量文件传输.
rsync可用于镜像数据,增量备份,在系统之间复制文件,可替代scp,sftp和cp日常等使用的命令.
用法
rsync语法有三种,分别是本地到本地形式Local to Local,本地到远程Local to Remote,远程到本地Remote to Local
123Local to Local: rsync [OPTION]... [SRC]... DESTLocal to Remote: rsync [OPTION]... [SRC]... [USER@]HOST:DESTRemote to Local: rsync [OPTION]... [USER@]HOST:SRC... [DEST]
-a/--archive存档模式,等效于-rlptgoD.此选项指示rsync递归同步目录,传输特殊设备和块设备,保留符号链接,组,所有权和权限等.
-z/--compress,此选项将强制rsync在数据发送给目标计算机之前对数据进行压缩. ...
Linux工具-nmap
参考文献
nmap
端口扫描基础
许多传统的端口扫描器只列出所有端口是开放还是关闭的, Nmap的信息粒度比它们要细得多。 它把端口分成六个状态: open(开放的),closed(关闭的),filtered(被过滤的), unfiltered(未被过滤的), open|filtered(开放或者被过滤的),或者closed|filtered(关闭或者被过滤的)。
Nmap所识别的6个端口状态
状态
说明
open(开放的)
应用程序正在该端口接收TCP 连接或者UDP报文。发现这一点常常是端口扫描 的主要目标。安全意识强的人们知道每个开放的端口 都是攻击的入口。攻击者或者入侵测试者想要发现开放的端口。 而管理员则试图关闭它们或者用防火墙保护它们以免妨碍了合法用户。 非安全扫描可能对开放的端口也感兴趣,因为它们显示了网络上那些服务可供使用
closed(关闭的)
关闭的端口对于Nmap也是可访问的(它接受Nmap的探测报文并作出响应), 但没有应用程序在其上监听。 它们可以显示该IP地址上(主机发现,或者ping扫描)的主机正在运行up 也对部分操作系统探测有 ...
Linux-进程
参考文献
趣谈Linux操作系统
进程
在 Linux 里,要创建一个新的进程,需要一个老的进程调用 fork 来实现,其中老的进程叫作父进程(Parent Process),新的进程叫作子进程(Child Process)
进程ID
Linux采用延迟重用的算法来进行PID的分配,往简单了来说,原则就是
位图记录进程 ID 的分配情况( 0 为可用,1 为已占用).
将上次分配的进程 ID 记录到 last_pid 中,分配进程 ID 时,从 last_pid+1 开始找起,从位图中寻找可用的 ID .
如果找到位图集合的最后一位仍不可用,则回滚到位图集合的起始位置,从头开始找.既然是位图记录进程 ID 的分配情况,那么位图的大小就必须要考虑周全.位图的大小直接决定了系统允许同时存在的进程的最大个数,这个最大个数在系统中称为 pid_max .回绕时并不是从 0 开始找起,而是从 300 开始找起.
1234# cat /proc/sys/kernel/pid_max40960# sysctl kernel.pid_maxkernel.pid_max = 40960 ...
Linux-软件安装
参考文献
趣谈Linux系统
<<鸟哥的Linux私房菜>>
软件安装
Linux 现在常用的有两大体系,一个是 CentOS 体系,一个是 Ubuntu 体系,前者使用 rpm,后者使用 deb。
CentOS 下面使用rpm -i jdk-XXX_linux-x64_bin.rpm进行安装
Ubuntu 下面使用dpkg -i jdk-XXX_linux-x64_bin.deb。其中 -i 就是 install 的意思
rpm -qa和dpkg -l就可以查看安装的软件列表,-q 就是 query,a 就是 all,-l 的意思就是 list。
要删除,可以用rpm -e和dpkg -r。-e 就是 erase,-r 就是 remove
RPM(RedHat Package Manager)
由于RPM有数据库来记录软件的相关信息,所以RPM类型的套件所拥有的档案都放置在系统预设的目录底下
路径
说明
/etc
一些设定文件放置的目录,例如/etc/crontab
/usr/bin
一些可执行档案
/usr/ ...
Linux-LVM
参考文献
如何扩大ubuntu的ubuntu–vg-ubuntu–lv空间
解决 Linux /dev/mapper/ubuntu–vg-ubuntu–lv 磁盘空间不足的问题
LVM——让Linux磁盘空间的弹性管理
LVM
LVM(Logical Volume Manager)逻辑卷管理是在Linux2.4内核以上实现的磁盘管理技术
相关名词解释
Physical Volume(PV)
物理卷,将实际的磁盘分区(partition)系统识别码(system ID)修改为8e后,在通过pvcreate指令转化为LVM最底层的物理卷,作为后续空间管理的基础.
Volume Group(VG)
卷组,将数个PV进行整合,即形成了VG,在32位的操作系统中,LV的大小与PE的大小有关;在64位的操作系统中,LV几乎没有容量限制.
Physical Extent(PE)
物理区块,他是LVM中的最小存储单元.PE类似于文件系统中的block.
Logical Volume(LV)
逻辑卷,由VG划分而来,LV的大小与PE的大小及PE的数量有关,Size(LV)= Cou ...
Linux工具-crontab
参考文献
Linux Timed Tasks Crontab
crontab
crond是linux下的一个守护进程,用于定期执行某些任务或等待某些事件被处理,类似于windows下的计划任务,当操作系统安装完成后,会默认安装这个服务工具,并会自动启动crond进程,crond进程每分钟会定期检查是否有任务需要执行,如果有任务就会自动执行.如果有任务要执行,就会自动执行. /etc目录下有一个crontab文件,它是系统任务调度的配置文件
1234567891011121314151617# /etc/crontab: system-wide crontab# Unlike any other crontab you don't have to run the `crontab'# command to install the new version when you edit this file# and files in /etc/cron.d. These files also have username fields,# that none of t ...
Linux工具-certbot
参考文献
https://certbot.eff.org/instructions?ws=nginx&os=ubuntufocal
https://eff-certbot.readthedocs.io/en/stable/using.html
ssl 证书;certbot+nginx+docker
docker部署certbot与nginx来获取ssl证书添加https及自动更新
letsencrypt证书-管理工具certbot
certbot
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849# certbot --help- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - certbot [SUBCOMMAND] [options] [-d DOMAIN] [-d DOMAIN] ...Certbot can obtain and i ...
Linux工具-nsenter
参考文献
nsenter Command Examples in Linux
nsenter
nsenter 是一个 Linux 实用程序,允许您在正在运行的进程的命名空间中运行命令。命名空间是 Linux 内核的一项功能,可为进程提供隔离的环境,并被 Docker 等容器技术用来创建隔离的容器。
使用 nsenter,您可以在正在运行的进程的命名空间中运行命令,从而有效地允许您访问该进程的环境。这对于各种任务都很有用,例如调试进程、检查容器的文件系统或使用类似 chroot 的操作更改进程的根目录。
nsenter 对于管理 Docker 容器特别有用,因为它允许您进入容器的命名空间并执行操作,就像您在容器本身内部一样。这对于排除容器问题或执行维护任务而无需启动新容器特别有帮助。
使用说明
12345678910111213141516171819202122232425262728# nsenter --help用法: nsenter [选项] [<程序> [<参数>...]]以其他程序的名字空间运行某个程序。选项: -a, --all ...
Linux-常用环境配置
参考文献
Ubuntu基本环境配置
Ubuntu
具体配置(以Ubuntu18.04为例)
配置apt源
修改为阿里apt源
https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.709c1b11miR2ke
12345# 备份旧源sudo cp /etc/apt/sources.list /etc/apt/sources.list.old# 填充以下内容vim /etc/apt/sources.list
123456789101112131415deb https://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiversedeb-src https://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ bionic-security main ...