Post

Linux Hacker基础

Linux Hacker基础

1 基础知识

whereis和which

whereis和which均用于查找二进制文件。which查找PATH变量中的二进制文件。

find

示例:

1
find / -type f -name apache

通配符: ? - 单个任意字符 [] - 匹配括号内的字符,举例:[h,b]at匹配hat和bat

cat

显示文件内容:

1
cat file.txt

将内容写入文件(覆盖):

1
2
cat > file.txt
Helloworld!

将内容写至文件末尾:

1
2
cat >> file.txt
Helloworld!

2 文本操作

head、tail和nl

head - 查看前10行(默认),可指定行数:

1
head -20 snort.conf

tail - 默认查看后10行,可指定行数。 nl - 标显行数:

1
nl snort.conf

使用sed查找和替换

1
sed s/mysql/MySQL/g /etc/snort/snort.conf > snort2.conf

snort.conf中的mysql替换成MySQL并保存到snort2.conf。其中s指search;g指global(全局替换)。

This post is licensed under CC BY 4.0 by the author.