Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to delete a port by vnc

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to delete the port of vnc, the article is very detailed, has a certain reference value, interested friends must read it!

The interface of IIS7 server management tools is as follows:

Yum-y install tiger-server

! / usr/bin/env bash

Config_file= "/ etc/sysconfig/vncservers"

Port_file= "/ root/.vnc_port"

Vncserver_file=which vncserver

Sed-I's vncserver_file 5900\ + / 12000\ + / g'$vncserver_filesed-I\ + / 12000\ + / 5900\ + / g'$vncserver_file port modified to start port

Function port_init {

Last_port=5900

If [[- e $port_file]]; then

Old_port=cat $port_file

Sed-I "s/$old_port\ + / 5900\ + / g" $vncserver_file

Echo "5900" > $port_file

Fi

}

Modify Port

Function modfy_port {

Last_port=$1

If [[$last_port = = "]]; then

Echo "Please input the port you want"

Else

If [[- e $port_file]]; then

Old_port=cat $port_file

Sed-I "s/$old_port\ + / $last_port\ + / g" $vncserver_file

Echo $last_port > $port_file

Else

Sed-I "samp 5900\ + / $last_port\ + / g" $vncserver_file

Echo $last_port > $port_file

Fi

Fi

}

Add user

Function adduser {

If [[$1 = = "]]; then

Echo "Please input a user name"

Else

User_num=grep-w VNCSERVERS $config_file | awk'{print $NF}'| cut-d ":"-F1

Latest_user_num=expr $user_num + 1

Last_user=grep-w VNCSERVERS $config_file | awk'{print $NF}'| awk-F'"'{print $1}'

Sed-I "s/$last_user/$last_user\ $latest_user_num:$1/" $config_file

Echo "VNCSERVERSVNCSERVERARGS [$latest_user_num] =\"-geometry 1600x900-alwaysshared\ "> > $config_file

Useradd $1

Echo "* *" | passwd-stdin $1

Fi

}

Delete user

Function deleteuser {

If [[$1 = = "]]; then

Echo "Please input the username to delete"

Else

Delete_user_match=$ (egrep-w "[0-9] {1jue 3}: $1" $config_file | wc-l)

If [[$delete_user_match-ne 1]]; then

Echo "Please make sure the user name is correct"

Else

Delete_user_num=egrep-w "[0-9] {1Jing 3}: $1" $config_file | awk-F ": $1"'{print $1}'| awk'{print $NF}'

Sed-I "s /\ $delete_user_num:$1//" $config_file

Sed-I "sCompact. [$delete_user_num]. / /" $config_file

Userdel-r $1

Fi

Fi

}

Service start

Function start {

# user_list= `grep-w VNCSERVERS $config_file | awk-F' "'{print $2}'| sed's / [0-9]\ +: / / g '``user_list= `grep-w VNCSERVERS $config_file | awk-F''{print $2} '`echo $user_listfor I in $user_listdo user_port=$ (echo $I | cut-d": "- F1) user=$ (echo $I | cut-d": "- f2) # su-$user-c" vncserver-kill: $user_port "expect-c" set timeout 1200 Spawn / usr/bin/su-$user-c "vncserver\\: $user_port" expect {"Password:" {send "* *"\ rpolitics expandable continue} "Verify:" {send "* *"\ r;}} expect eof; "done

}

Function stop {

User_list=ps aux | grep vnc | grep rfbport | awk'{print $1 $12}'

For i in $user_list

Do

User_port=$ (echo $I | cut-d ":"-f2)

User=$ (echo $I | cut-d ":"-F1)

Su-$user-c "vncserver-kill: $user_port"

Done

}

Case $1 in

Adduser)

Adduser $2

Deleteuser)

Deleteuser $2

Stop)

Stop

Start)

Start

Default_port)

Port_init

Modify_port)

Modfy_port $2

*)

Echo-e "Usage:\ ncommands:\ nadduser#define:please input a user name,Don't use pure numbers\ ndeleteuser#define:please input a complete user name\ nstart # define:start all service\ nstop # define:stop all service\ ndefault_port # define:Modify port to default start segment\ nmodify_port#define:Modify the port to the segment you want"

Esac

The above is all the contents of the article "how to delete ports in vnc". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report