netstat -p flag not working [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I'm trying to close some CLOSE_WAIT localhost processes, and so am trying to get their process id's using 'netstat -anp'.
I've seen multiple posts recommending this, however, everytime I enter this command into terminal, i get this man page message:
netstat: option requires an argument -- p
Usage: netstat [-AaLlnW] [-f address_family | -p protocol]
netstat [-gilns] [-f address_family]
netstat -i | -I interface [-w wait] [-abdgRt]
netstat -s [-s] [-f address_family | -p protocol] [-w wait]
netstat -i | -I interface -s [-f address_family | -p protocol]
netstat -m [-m]
netstat -r [-Aaln] [-f address_family]
netstat -rs [-s]
I don't know what the problem is.

Are you using linux? or any other BSD version such as OS X?
In Linux, -p references to process id (PID - the you are expecting) while in OS X (maybe in free/open BSD too, but can't confirm it) -p references to a protocol and need it to be specified.
Regarding the output you are posting, this seems to be the problem, you can use instead:
(maybe you would change the port range, I put the whole line as an example)
lsof -i tcp:1-1024 -P |grep CLOSE_WAIT

Related

Closing an open ssh port in Linux with one line [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I often ssh tunnel into Rstudio on a server I have set up. I'm trying to devise a single command that I can use to close the ssh port. I know that I can find the PID for localhost:1234 with:
sudo lsof -i :1234
And I also know that I can kill the process with:
sudo kill $(sudo lsof -t -i:1234)
The issue is that if I have Chrome open to run Rstudio server, the 2nd command will kill the open Chrome browswer as well. Is there a way to modify the 2nd command so that I close the open ssh port, but not the Chrome browser? There are two PID numbers, so I could theoretically grep for 'ssh' but I'm not sure how.
EDIT FOR CLARITY:
For example, I get the following output from the first command. I want to modify the 2nd command so that I can kill PID 15834, but not 30117. Apologies, I hope that makes more sense.
try this
sudo kill $(sudo lsof -t -i:1234 -c ssh)
-c => selects the listing of files for processes executing the command that begins with the characters of c.
Just firewall the port:
sudo iptables -I INPUT -p tcp --dport 1234 -j DROP

Auto accept "Configuring iptables-persistent" [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 4 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
i'm created bash script where i need to configure network, but in one of stage he ask me to save new rule, how to prevent it and set "Yes" automatically.
sudo iptables -t nat -A PREROUTING -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 1443
sudo apt-get -y install iptables-persistent
sudo service netfilter-persistent save
message where he ask to save
For non-terminal programs
Actually, you can always automatize input of eny word with several methods:
yes word | command
(in this word will be entered as an input of command)
or using expect, if you need more sophisticated dialog.
For terminal programs (your case)
For interactive sessions you can try it this way:
start it in a tmux session
send "Enter" using tmux send-keys
That is exactly what you want.
tmux send-keys Enter
Everything combined:
sudo tmux -L dialog-session new-session -d service netfilter-persistent save
sudo tmux -L dialog-session send-keys Enter
(actually you don't need sudo here, but I use sudo because of your sudo)

In Linux how do you make a command run in the background without it outputting to the screen? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I know this sounds like a silly question at first glance, but I've tried everything.
I want to execute the command arpspoof in the Kali Linux terminal but I do not want to see the endless output.
First I try this:
arpspoof -t 10.1.1.1 10.1.1.2 >/dev/null
And it still outputs to the screen.
Then I try this:
arpspoof -t 10.1.1.1 10.1.1.2 & >/dev/null
And it still outputs to the screen.
Then I add another one at the end:
arpspoof -t 10.1.1.1 10.1.1.2 & >/dev/null &
And it still outputs to the freakin screen.
Try
arpspoof -t 10.1.1.1 10.1.1.2 2>/dev/null 1>/dev/null &
where:
arpspoof -t 10.1.1.1 10.1.1.2 is your command
2>/dev/null redirects standard error (STDERR) to the "bit bucket"
1>/dev/null redirects standard out (STDOUT) to the "bit bucket"
& sets the entire command line to run in the background
This line of code is more verbose and perhaps clearer to understand.
A somewhat redundant answer but I prefer the format:
arpspoof -t 10.1.1.1 10.1.1.2 >/dev/null 2>&1
Be sure that you don't have background processes still running (therefore still writing to the console/screen) from previous attempts to redirect the output.

scp to another linux system via ssh where not using port 22 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I'm trying to copy a folder from one system to another using scp (secure copy) however I cannot work out how to specify the port.
I understand that to scp, I can...
scp /file/location/folderName user#192.***.*.***:/destination/location/
however I have changed the destination system's SSH port so I get get this error...
ssh: connect to host ..*.*** port 22: Connection refused lost
connection
Is there some sort of -p command I can use to specify port number?
I also tried adding the port like this...
scp /file/location/folderName user#192.***.*.***:>>portNumHere<</destination/location/
Updated with solution...
I was struggling not only with using the wrong -P but also where to place. I know understand and this works for me...
scp -r -P >>portNumHere<< /file/location/folderName user#192.***.*.***:/destination/location/
Use a capital -P port. The lower case -p option conflicts with the -p "preserve" option from cp.
Per the man page:
scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
[-l limit] [-o ssh_option] [-P port] [-S program]
[[user#]host1:]file1 ... [[user#]host2:]file2
...
-P port
Specifies the port to connect to on the remote host. Note that
this option is written with a capital ā€˜Pā€™, because -p is
already reserved for preserving the times and modes of the
file.

Google Compute Engine - troubleshooting SSH default port [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
when running
gcutil ssh myproject_name
ssh run with the following command
ssh -o UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no -i /Users/MyUser/.ssh/google_compute_engine -A -p 22 MyUser#xxx.xxx.xxx.xxx
i've changed my ssh port to 1234 in sshd_config file and opened a firewall rule at my compute engine console. executing the following command works perfect and connection is established
ssh -o UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no -i /Users/MyUser/.ssh/google_compute_engine -A -p 1234 MyUser#xxx.xxx.xxx.xxx
but when running this command gcutil ssh myproject_name port 22 is being called.
How & where can i change the default port of ssh so I wont have to use the long command in order to connect to my instance
gcutil supports alternate ports via the --ssh_port flag. In your case, this should work:
gcutil ssh --ssh_port 1234 INSTANCE_NAME

Resources