Linux-Basics-For-Hacker(文本操作)

admin 2023年2月16日23:28:22评论29 views字数 2467阅读8分13秒阅读模式

文本操作

在 Linux 系统中,我们处理的一切都是文件,并且绝大多数都是文本文件;举个例子,在 Linux 系统中,所有的配置文件都是文本文件。所以我们只需要打开文件,更改文件的内容,保存文件,再重新启动应用就可以更改应用配置.

查看文件cat

查看文件最基本的命令就是 cat,但是cat存在限制,例如我们使用cat命令打印位于etc/apache2下的配置文件(apache2.conf)

┌──(rootðkali)-[/etc/apache2]
└─$cat apache2.conf
# This is the main Apache server configuration file. It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.4/ for detailed information about
# the directives and /usr/share/doc/apache2/README.Debian about Debian specific
# hints.
#
#
# Summary of how the Apache 2 configuration works in Debian:
# The Apache 2 web server configuration in Debian is quite different to
.
.
.
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

# vim: syntax=apache ts=4 sw=4      
┌──(rootðkali)-[/etc/apache2]
└─$


cat会立刻把整个屏幕占满,显示整个的conf文件,但是这不是最方便与实用的方法,headtail两个命令只显示部分内容,用来简单的查看关键点。

查看开头head

head命令默认显示文件的前十行

┌──(rootðkali)-[/etc/apache2]
└─$ head apache2.conf                                                              
# This is the main Apache server configuration file. It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.4/ for detailed information about
# the directives and /usr/share/doc/apache2/README.Debian about Debian specific
# hints.
#
#
# Summary of how the Apache 2 configuration works in Debian:
# The Apache 2 web server configuration in Debian is quite different to
# upstream's suggested way to configure the web server. This is because Debian's

#如果想看多于或者少于默认10行,可以使用连接符 -

┌──(rootðkali)-[/etc/apache2]
└─$head -5 apache2.conf
# This is the main Apache server configuration file. It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.4/ for detailed information about
# the directives and /usr/share/doc/apache2/README.Debian about Debian specific
# hints.
                                       


查看结尾tail

tail 命令 和 head 命令相似。只是 tail 命令用于查看文件最后几行。使用 tail 查看apache2.conf

┌──(rootðkali)-[/etc/apache2]
└─$ tail apache2.conf                  
# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

#同样的,tail默认也是打印10行,如果需要更多的,同head一样使用连接符- 在此就不再做演示

TIKS:

**查看端口**
netstat -tunlp

-t 查看tcp协议

-u 查看udp协议

-n 以数字形式查看

-l 监听的端口

-p 查看哪个程序使用

Web服务程序 -- apache2

**显示运行系统进程**
ps aux

**systemctl 系统服务控制工具**

systemctl [options...] command...
systemctl 命令 服务名称
常用命令:
start启动
stop 停止
restart 重启
systemctl start apache2

**查看命令执行状态**
echo $?

**ssh服务**
常用于远程连接(安全)
默认端口号 tcp/22


原文始发于微信公众号(黑荆棘安全攻防实验室):Linux-Basics-For-Hacker(文本操作)

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年2月16日23:28:22
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Linux-Basics-For-Hacker(文本操作)http://cn-sec.com/archives/1276100.html

发表评论

匿名网友 填写信息