:1,$ /[a-z0-9]/p

이렇게 하면 원하는 문자열을 찾습니다. 노란색인가? 음영으로 되구요.

저 노란색으로(찾아진 문자열)된것만 따로 문서화일로 보내거나

노란색이 안된(원치않는 문자열등)것은 vi 자체내에서 삭제를 하고 싶습니다.

치환,찾기,삭제는 알겠는데, 도저히 머리를 써도 꽁수가 없네요 ㅠㅠ

가르침을 주세요 ㅠㅠ

Forums: 

 

 

특정 패턴이 [b]있는[/b] 줄을 모두 지우려면..[code:1]&

글쓴이: cdpark / 작성시간: 목, 2005/02/24 - 6:03오후

특정 패턴이 있는 줄을 모두 지우려면..
:g/pattern/d

특정 패턴이 없는 줄을 모두 지우려면..
:v/pattern/d

혹은 grep, sed 등의 프로그램을 사용해서도 원하는 걸 할 수도 있습니다.

자세한 옵션은 언제나 그렇듯이 RTFM!

 

:%s/[^0-9a-z]//g

글쓴이: impactbar / 작성시간: 금, 2005/02/25 - 12:10오전

:%s/[^0-9a-z]//g

 

 

특정패턴만 추출하고 싶은데..

글쓴이: 익명 사용자 / 작성시간: 목, 2012/02/09 - 3:50오후

찾고자 하는 특정 패턴이 [0-9a-z] 같은 경우가 아니라
[p]\+[a]\+[th]\+[="]\+[a-zA-Z0-9/"]\+ <--- 이것처럼 복잡한 경우에는 어떻게 해야하나요 ?

찾고자 하는 문자열(highlight된 영역)을 제외하고 나머지 부분을 모두 삭제,
또는 찾고자 하는 문자열만 화면에 띄우고 싶은데
사용할일은 엄청 많을것 같은데 방법을 모르겠네요.

 

 

제가 쓰는 방법입니다

글쓴이: garam111 / 작성시간: 금, 2012/02/10 - 7:33오전

한 줄에 한번만 나온다면
:%s/\(.*\)\(pattern\)\(.*\)/g

여러번 나올 수 있다면
:%s/pattern/\r&\r/g
:v/pattern/d

===================================
행동할 때 열정은 자라난다.

 

 

제가 쓰는 방법입니다

글쓴이: garam111 / 작성시간: 금, 2012/02/10 - 7:33오전

한 줄에 한번만 나온다면
:%s/\(.*\)\(pattern\)\(.*\)/g

여러번 나올 수 있다면
:%s/pattern/\r&\r/g
:v/pattern/d

===================================
행동할 때 열정은 자라난다.

 

오타 정정합니다

글쓴이: garam111 / 작성시간: 금, 2012/02/10 - 7:36오전

한 줄에 한번만 나온다면
:%s/\(.*\)\(pattern\)\(.*\)/\2/g

===================================
행동할 때 열정은 자라난다.

 

 

:%s/.*\(pattern\).*/\1/g

글쓴이: Prentice / 작성시간: 토, 2012/02/11 - 12:01오후

:%s/.*\(pattern\).*/\1/g

Environment

  • Red Hat Enterprise Linux
  • 네트워크 서비스

Issue

  • 갑자기 특정 포트에 바인딩되는 일부 프로그램들이 포트예약 충돌때문에 시작할 수가 없습니다.
  • 해당 포트에 대한 telnet 명령은 소켓이 열려있는 것을 보여 주지만 프로세스는 특정되지 않습니다.
  • 다음과 같이 "PID / Program Name"열에 대시 (-)가 표시됩니다.

Resolution

  • 'root'사용자로 'netstat'명령을 실행하십시오.

  • 일반적으로 사용자가 옵션 'e'에서 netstat를 사용하면 프로세스의 UID 및 Inode가 표시됩니다.

I can’t SSH out on my Kali Linux machine

Ask Question

Asked 1 year ago

Active 9 months ago

Viewed 2k times

1

I have 2 VPS in DigitalOcean. I was able to SSH into them with password before today. But now, when I try to SSH with my machine which is Kali Linux, after type the password, I get this response:

packet_write_wait: Connection to X.X.X.X port 22: Broken pipe

I tried to add SSH key of my machine (I am not sure did it right) but no success. I know the problem is in Kali because I can SSH into with my other machine which is Windows.

What can be the problem?

linux ssh kali-linux

share

 

 

 

improve this question

edited Nov 28 '18 at 16:25

JakeGould

35.1k1010 gold badges112112 silver badges152152 bronze badges

asked Sep 6 '18 at 13:14

Eren Koçak

1433 bronze badges

  • 1

    I'm having the same problem when trying to push code to Gitlab over SSH. It only started happening a couple of days ago. I fixed it by using Git over HTTPS, but I don't know what the cause of the problem is. Hopefully, someone will be able to figure it out. For the record, I'm using Manjaro Linux with all the latest updates installed. – Cromulent Sep 6 '18 at 13:30

  •  

    I suspected from some configuration or environment variables on my machine after checking ssh logs. The connection is actually opening but closed immediately after. So I thought give it a change to connect using something differentthan regular terminal. I tried yakuake but no succes. Then I tried Putty and that worked. However I have still no idea of the main cause of the problem – Eren Koçak Sep 7 '18 at 20:26 

add a comment

1 Answer

activeoldestvotes

2

I had the exact same problem in Kali and Parrot distros and have been looking for a solution for quit some time.

I was able to fix it by adding this to my ssh_config or ~/.ssh/config file:

IPQoS reliability

I hope this helps for you also...

The other day I was transferring a large file using rsync to another system on my local area network. Since it is very big file, It took around 20 minutes to complete. I don’t want to wait that much longer, and also I don’t want to manually terminate the process by pressing CTRL+C either. I was just wondering if there could be any easy ways to run a command for a specific time and kill it automatically once the time is out in Unix-like operating systems – hence this post. Read on.

Run A Command For A Specific Time In Linux

We can do this in two methods.

Method 1 – Using “timeout” command

The most common method is using timeout command for this purpose. For those who don’t know, the timeout command will effectively limit the absolute execution time of a process. The timeout command is part of the GNU coreutils package, so it comes pre-installed in all GNU/Linux systems.

Let us say, you want to run a command for only a specific time, and then kill it automatically once the time is passed. To do so, we use:

$ timeout <time-limit-interval> <command>

For example, the following command will terminate after 10 seconds.

$ timeout 10s tail -f /var/log/pacman.log

You also don’t have to specify the suffix “s” for seconds. The following command is same as above.

$ timeout 10 tail -f /var/log/pacman.log

The other available suffixes are:

  • ‘m’ for minutes,
  • ‘h’ for hours
  • ‘d’ for days.

If you run this tail -f /var/log/pacman.log command, it will keep running until you manually end it by pressing CTRL+C. However, if you run it along with timeout command, it will be killed automatically after the given time interval.

Just in case if the command is still running even after the time out, you can send a kill signal like below.

$ timeout -k 20 10 tail -f /var/log/pacman.log

In this case, if you the tail command still running after 10 seconds, the timeout command will send it a kill signal after 20 seconds and end it.

The Tmeout command can be especially useful when troubleshooting hardware issues. For instance, run the following command to display all messages from the kernel ring buffer, but for only 10 seconds.

$ timeout 10 dmesg -w

For more details, check the man pages.

$ man timeout

Sometimes, a particular program might take long time to complete and end up freezing your system. In such cases, you can use this trick to end the process automatically after a particular time.


Also, consider using Cpulimit , a simple application to limit the CPU usage of a process. For more details, check the following link.


Method 2 – Using “Timelimit” program

The Timelimit utility executes a given command with the supplied arguments and terminates the spawned process after a given time with a given signal. First, it will pass the warning signal and then after timeout, it will send the kill signal.

Unlike the timeout utility, the Timelimit has more options. You can pass number of arguments such as killsig, warnsig, killtime, warntime etc.

It is available in the default repositories of Debian-based systems. So, you can install it using command:

$ sudo apt-get install timelimit

For Arch-based systems, it is available in the AUR. So, you can install it using any AUR helper programs such as PacaurPackerYayYaourt etc.

For other distributions, download the source from here and manually install it.

After installing Timelimit program, run the following command for a specific time, for example 10 seconds:

$ timelimit -t10 tail -f /var/log/pacman.log

If you run timelimit without any arguments, it will use the default values: warntime=3600 secondswarnsig=15killtime=120killsig=9.

For more details, refer the man pages and the project’s website given at the end of this guide.

$ man timelimit

And, that’s all for today. I hope this was useful. More good stuffs to come. Stay tuned!

Cheers!

+ Recent posts