KALI学习笔记之配置静态ip、ssh远程连接和启动常见服务
一、配置静态IP:
修改命令:
2、查看22端口是否开启监听 (ssh需要使用22端口)
2.1,开启前:netstat -an | grep 22
2.2 开启22端口
二、开启mysql服务:
1、查看mysql状态:
命令:service mysql status
![在这里插入图片描述](https://img-blog.csdnimg.cn/39d6fdc2e0614d6fa49f75ec259c40b2.png)
2、查看mysql端口和进程是否开启:
查看端口命令:ps -ef |grep 22
查看进程命令:ps -ef |grep mysql
可以看到mysql服务没有开启。
3、开启mysql服务;
┌──(root㉿kali)-[~]
└─# service mysql start //开启mysql服务
┌──(root㉿kali)-[~]
└─# service mysql status //查看mysql状态
● mariadb.service - MariaDB 10.6.7 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Active: active (running) since Sun 2022-05-29 22:07:57 EDT; 5s ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Process: 6066 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Process: 6067 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 6070 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, sta>
Process: 6115 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 6117 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
Main PID: 6099 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 17 (limit: 2264)
Memory: 63.1M
CPU: 740ms
CGroup: /system.slice/mariadb.service
└─6099 /usr/sbin/mariadbd
5月 29 22:07:57 kali mariadbd[6099]: 2022-05-29 22:07:57 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
5月 29 22:07:57 kali mariadbd[6099]: 2022-05-29 22:07:57 0 [Note] InnoDB: 10.6.7 started; log sequence number 42341; transaction id 14
5月 29 22:07:57 kali mariadbd[6099]: 2022-05-29 22:07:57 0 [Note] Plugin 'FEEDBACK' is disabled.
5月 29 22:07:57 kali mariadbd[6099]: 2022-05-29 22:07:57 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
5月 29 22:07:57 kali mariadbd[6099]: 2022-05-29 22:07:57 0 [Note] InnoDB: Buffer pool(s) load completed at 220529 22:07:57
5月 29 22:07:57 kali mariadbd[6099]: 2022-05-29 22:07:57 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
5月 29 22:07:57 kali mariadbd[6099]: 2022-05-29 22:07:57 0 [Note] Server socket created on IP: '127.0.0.1'.
5月 29 22:07:57 kali mariadbd[6099]: 2022-05-29 22:07:57 0 [Note] /usr/sbin/mariadbd: ready for connections.
5月 29 22:07:57 kali mariadbd[6099]: Version: '10.6.7-MariaDB-3' socket: '/run/mysqld/mysqld.sock' port: 3306 Debian buildd-unstable
5月 29 22:07:57 kali systemd[1]: Started MariaDB 10.6.7 database server.
lines 1-28/28 (END)
┌──(root㉿kali)-[~]
└─# ps -ef |grep mysql //查看到服务已开启,属于mariadbd的服务
mysql 6099 1 0 22:07 ? 00:00:00 /usr/sbin/mariadbd
root 6259 1848 0 22:08 pts/0 00:00:00 grep --color=auto mysql
┌──(root㉿kali)-[~]
└─# ps -ef |grep 22 //查看对应端口已启动
root 22 2 0 21:50 ? 00:00:00 [cpuhp/2]
kali 976 966 0 21:50 ? 00:00:02 /usr/lib/x86_64-linux-gnu/xfce4/panel/wrapper-2.0 /usr/lib/x86_64-linux-gnu/xfce4/panel/plugins/libwhiskermenu.so 1 16777223 whiskermenu Whisker 菜单 显示一个易于访问已安装程序的菜单
kali 977 966 0 21:50 ? 00:00:09 /usr/lib/x86_64-linux-gnu/xfce4/panel/wrapper-2.0 /usr/lib/x86_64-linux-gnu/xfce4/panel/plugins/libcpugraph.so 13 16777224 cpugraph CPU 图像 图形化呈现 CPU 负载
kali 978 966 0 21:50 ? 00:00:00 /usr/lib/x86_64-linux-gnu/xfce4/panel/wrapper-2.0 /usr/lib/x86_64-linux-gnu/xfce4/panel/plugins/libsystray.so 14 16777225 systray 状态栏插件 提供状态通知程序项 (应用程序指示器) 和旧式系统托盘项
kali 979 966 0 21:50 ? 00:00:06 /usr/lib/x86_64-linux-gnu/xfce4/panel/wrapper-2.0 /usr/lib/x86_64-linux-gnu/xfce4/panel/plugins/libgenmon.so 15 16777226 genmon 一般监视器 显示命令的输出结果。
kali 980 966 0 21:50 ? 00:00:02 /usr/lib/x86_64-linux-gnu/xfce4/panel/wrapper-2.0 /usr/lib/x86_64-linux-gnu/xfce4/panel/plugins/libpulseaudio-plugin.so 16 16777227 pulseaudio PulseAudio 插件 调节 PulseAudio 声音系统的音量
kali 981 966 0 21:50 ? 00:00:00 /usr/lib/x86_64-linux-gnu/xfce4/panel/wrapper-2.0 /usr/lib/x86_64-linux-gnu/xfce4/panel/plugins/libnotification-plugin.so 17 16777228 notification-plugin 通知插件 Xfce 面板专用的通知插件
kali 984 966 0 21:50 ? 00:00:00 /usr/lib/x86_64-linux-gnu/xfce4/panel/wrapper-2.0 /usr/lib/x86_64-linux-gnu/xfce4/panel/plugins/libxfce4powermanager.so 18 16777229 power-manager-plugin 电量管理插件 显示设备电量并控制屏幕亮度
kali 987 966 0 21:50 ? 00:00:00 /usr/lib/x86_64-linux-gnu/xfce4/panel/wrapper-2.0 /usr/lib/x86_64-linux-gnu/xfce4/panel/plugins/libactions.so 22 16777230 actions 动作按钮 注销、锁屏或其它系统动作
root 4204 2 0 22:00 ? 00:00:00 [kworker/2:2-events]
root 4328 2 0 22:01 ? 00:00:00 [dio/sda1]
root 4334 2 0 22:01 ? 00:00:00 [kworker/3:2-rcu_par_gp]
root 4358 2 0 22:01 ? 00:00:00 [kworker/u64:1-events_unbound]
root 4810 2 0 22:02 ? 00:00:00 [kworker/1:2-events]
root 4811 2 0 22:02 ? 00:00:00 [kworker/0:0-events]
root 6064 2 0 22:07 ? 00:00:00 [kworker/2:0-ata_sff]
root 6069 2 0 22:07 ? 00:00:00 [kworker/3:1-events]
mysql 6099 1 0 22:07 ? 00:00:00 /usr/sbin/mariadbd
root 6291 1848 0 22:08 pts/0 00:00:00 ps -ef
root 6292 1848 0 22:08 pts/0 00:00:00 grep --color=auto 22
┌──(root㉿kali)-[~]
└─#
三、开启apache服务
1、查看apache服务状态
┌──(root㉿kali)-[~]
└─# service apache2 status
○ apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: https://httpd.apache.org/docs/2.4/
5月 29 21:54:37 kali systemd[1]: Starting The Apache HTTP Server...
5月 29 21:54:38 kali apachectl[2511]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
5月 29 21:54:38 kali systemd[1]: Started The Apache HTTP Server.
5月 29 22:13:34 kali systemd[1]: Stopping The Apache HTTP Server...
5月 29 22:13:34 kali apachectl[7630]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
5月 29 22:13:34 kali systemd[1]: apache2.service: Deactivated successfully.
5月 29 22:13:34 kali systemd[1]: Stopped The Apache HTTP Server.
┌──(root㉿kali)-[~]
└─# ps -ef |grep apache2
root 7847 1848 0 22:14 pts/0 00:00:00 grep --color=auto apache2
┌──(root㉿kali)-[~]
└─# ps -ef |grep 80
root 80 2 0 21:50 ? 00:00:00 [irq/43-pciehp]
root 180 2 0 21:50 ? 00:00:00 [kworker/2:1H-kblockd]
kali 980 966 0 21:50 ? 00:00:02 /usr/lib/x86_64-linux-gnu/xfce4/panel/wrapper-2.0 /usr/lib/x86_64-linux-gnu/xfce4/panel/plugins/libpulseaudio-plugin.so 16 16777227 pulseaudio PulseAudio 插件 调节 PulseAudio 声音系统的音量
kali 1180 931 0 21:50 ? 00:00:00 /usr/libexec/gvfsd-trash --spawner :1.15 /org/gtk/gvfs/exec_spaw/0
root 1802 966 0 21:52 ? 00:00:06 /usr/bin/x-terminal-emulator
root 1848 1802 0 21:52 pts/0 00:00:07 /usr/bin/zsh
root 7883 1848 0 22:14 pts/0 00:00:00 grep --color=auto 80
┌──(root㉿kali)-[~]
└─# service apache2 start
┌──(root㉿kali)-[~]
└─# service apache2 status
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; disabled; vendor preset: disabled)
Active: active (running) since Sun 2022-05-29 22:14:51 EDT; 6s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 8034 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 8039 (apache2)
Tasks: 6 (limit: 2264)
Memory: 12.1M
CPU: 117ms
CGroup: /system.slice/apache2.service
├─8039 /usr/sbin/apache2 -k start
├─8041 /usr/sbin/apache2 -k start
├─8042 /usr/sbin/apache2 -k start
├─8043 /usr/sbin/apache2 -k start
├─8044 /usr/sbin/apache2 -k start
└─8045 /usr/sbin/apache2 -k start
5月 29 22:14:51 kali systemd[1]: Starting The Apache HTTP Server...
5月 29 22:14:51 kali apachectl[8038]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
5月 29 22:14:51 kali systemd[1]: Started The Apache HTTP Server.
┌──(root㉿kali)-[~]
查看端口和进程是否开启;
┌──(root㉿kali)-[~]
└─# ps -ef |grep 80
root 80 2 0 21:50 ? 00:00:00 [irq/43-pciehp]
root 180 2 0 21:50 ? 00:00:00 [kworker/2:1H-kblockd]
kali 980 966 0 21:50 ? 00:00:03 /usr/lib/x86_64-linux-gnu/xfce4/panel/wrapper-2.0 /usr/lib/x86_64-linux-gnu/xfce4/panel/plugins/libpulseaudio-plugin.so 16 16777227 pulseaudio PulseAudio 插件 调节 PulseAudio 声音系统的音量
kali 1180 931 0 21:50 ? 00:00:00 /usr/libexec/gvfsd-trash --spawner :1.15 /org/gtk/gvfs/exec_spaw/0
root 1802 966 0 21:52 ? 00:00:11 /usr/bin/x-terminal-emulator
root 1848 1802 0 21:52 pts/0 00:00:11 /usr/bin/zsh
root 8035 2 0 22:14 ? 00:00:00 [kworker/1:1-rcu_par_gp]
root 8066 2 0 22:14 ? 00:00:00 [kworker/u64:0-flush-8:0]
root 9480 1 1 22:20 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 9482 9480 0 22:20 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 9483 9480 0 22:20 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 9484 9480 0 22:20 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 9485 9480 0 22:20 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 9486 9480 0 22:20 ? 00:00:00 /usr/sbin/apache2 -k start
root 9500 1848 0 22:20 pts/0 00:00:00 grep --color=auto 80
┌──(root㉿kali)-[~]
└─# ps -ef |grep apache2
root 9480 1 0 22:20 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 9482 9480 0 22:20 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 9483 9480 0 22:20 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 9484 9480 0 22:20 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 9485 9480 0 22:20 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 9486 9480 0 22:20 ? 00:00:00 /usr/sbin/apache2 -k start
root 9520 1848 0 22:20 pts/0 00:00:00 grep --color=auto apache2
┌──(root㉿kali)-[~]
└─#
四、启动nginx
1、修改端口配置。
注意:nginx里面默认端口为80,当我们执行命令:service nginx start时,启动失败,这是因为apache服务已经占用了80端口。我们需要修改80端口为其他端口再去执行启动命令。配置文件修改路径:/etc/nginx/sites-available/default
本例修改80端口为8088端口:
命令:vim /etc/nginx/sites-available/default
2、启动nginx服务。
──(root㉿kali)-[~]
└─# service nginx status
× nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sun 2022-05-29 21:56:16 EDT; 41min ago
Docs: man:nginx(8)
Process: 3077 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 3078 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
CPU: 64ms
5月 29 21:56:15 kali nginx[3078]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
5月 29 21:56:15 kali nginx[3078]: nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
5月 29 21:56:15 kali nginx[3078]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
5月 29 21:56:15 kali nginx[3078]: nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
5月 29 21:56:16 kali nginx[3078]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
5月 29 21:56:16 kali nginx[3078]: nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
5月 29 21:56:16 kali nginx[3078]: nginx: [emerg] still could not bind()
5月 29 21:56:16 kali systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
5月 29 21:56:16 kali systemd[1]: nginx.service: Failed with result 'exit-code'.
5月 29 21:56:16 kali systemd[1]: Failed to start A high performance web server and a reverse proxy server.
┌──(root㉿kali)-[~]
└─# /etc/init.d/nginx start **//启动nginx**
Starting nginx (via systemctl): nginx.service.
┌──(root㉿kali)-[~]
└─# service nginx status
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Sun 2022-05-29 22:37:33 EDT; 3s ago
Docs: man:nginx(8)
Process: 13906 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 13907 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 13908 (nginx)
Tasks: 5 (limit: 2264)
Memory: 4.7M
CPU: 69ms
CGroup: /system.slice/nginx.service
├─13908 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
├─13909 "nginx: worker process"
├─13910 "nginx: worker process"
├─13911 "nginx: worker process"
└─13912 "nginx: worker process"
5月 29 22:37:33 kali systemd[1]: Starting A high performance web server and a reverse proxy server...
5月 29 22:37:33 kali systemd[1]: Started A high performance web server and a reverse proxy server.
┌──(root㉿kali)-[~]
└─# ps -ef |grep nginx
root 13908 1 0 22:37 ? 00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 13909 13908 0 22:37 ? 00:00:00 nginx: worker process
www-data 13910 13908 0 22:37 ? 00:00:00 nginx: worker process
www-data 13911 13908 0 22:37 ? 00:00:00 nginx: worker process
www-data 13912 13908 0 22:37 ? 00:00:00 nginx: worker process
root 14063 1848 0 22:38 pts/0 00:00:00 grep --color=auto nginx
┌──(root㉿kali)-[~]
└─# ps -ef |grep 8088
root 14094 1848 0 22:38 pts/0 00:00:00 grep --color=auto 8088
┌──(root㉿kali)-[~]
└─#