Skip to content

Instantly share code, notes, and snippets.

What is Ip address?

An IP address is the identifier that enables our device to send or receive data packets across the internet. It holds information related to our location and therefore making devices available for two-way communication.

Most internet service providers still use IPv4. It’s based on 32 binary bits, consists of four numbers from 0 to 255, and is separated by dots. For example, 103.86.98.1.

Check Ip address with ip addr command

ip addr – Show information for all addresses ip addr show dev em1 – Display information only for device em1

Get Ip address with ifconfig command

The “ifconfig” command is another most common command used to view IP related information.

1、罗列式

[code] for VARIABLE in 1 2 3 4 5 .. N do command1 command2 commandN done [/code]

例如:

将字符串拆分成一个列表,其中每个单词都是一个列表中的元素:txt = "welcome to the jungle"

x = txt.split()

print(x)

1、定义和用法

Python for 循环

For … in 语句是另一种循环语句,其特点是会在一系列对象上进行迭代(Iterates),即它会遍历序列中的每一个项目

注意:

1、else 部分是可选的。当循环中包含它时,它循环中包含它时,它总会在 for 循环结束后开始执行,除非程序遇到了 break 语句。

2、for … in 能在任何队列中工作。有的是通过内置 range 函数生成一串数字列表,也可以是包含任何类型对象的队列。

append() 方法用于在列表末尾添加新的对象。

语法 append()方法语法:

list.append(obj) 1. 参数 obj -- 添加到列表末尾的对象。

GUI Installation on Ubuntu Server 20.04

  1. Update the apt package index and install tasksel.
$ sudo apt update
$ sudo apt install tasksel
  1. List the GUI we have installed and we can install:

Linux grep命令

Linux grep命令用于查找文件里符合条件的字符串;也可以用于查找内容包含指定的范本样式的文件。它能使用正则表达式搜索,用于在文件中搜索指定的字符串模式,列出含有匹配模式子符串的文件名,并输出含有该字符串的文本行。

grep的工作方式是这样的:它在一个或多个文件中搜索字符串模板。如果模板包括空格,则必须被引用,模板后的所有字符串被看作文件名。搜索的结果被送到标准输出,不影响原文件内容。

基本语法:

grep [options] pattern [files] [options]的主要参数:

Python 列表

序列是Python中最基本的数据结构。序列中的每个元素都分配一个数字 - 它的位置,或索引,第一个索引是0,第二个索引是1,依此类推。

Python有6个序列的内置类型,但最常见的是列表和元组。

序列都可以进行的操作包括索引,切片,加,乘,检查成员。

此外,Python已经内置确定序列的长度以及确定最大和最小的元素的方法。

用途 find命令用于在指定目录下查找文件。

全称 无

参数

-name :后跟需要匹配的文件名模式,需要使用引号引起来

linux 最常用的查看mac地址的方式 有很多种,下面给出4种方式,

ifconfig 这是最常用的方式

ip link show

cat /sys/class/net/eth0/address 查看eth0的mac地址

dmesg | grep eth0

how to check mac address in Linux