Most Popular

1500 questions
114
votes
6 answers

How to do an if statement from the result of an executed command

I am trying to do an IF statement from the output of an executed commmand. Here is how I am trying to do it, but it doesn't work. Does anyone know the right way to do this? if [ "`netstat -lnp | grep ':8080'`" == *java* ]; then echo "Found a…
djangofan
  • 4,002
  • 5
  • 21
  • 19
114
votes
7 answers

How to pass the output of one command as the command-line argument to another?

So I have a script that, when I give it two addresses, will search two HTML links: echo "http://maps.google.be/maps?saddr\=$1\&daddr\=$2" | sed 's/ /%/g' I want to send this to wget and then save the output in a file called temp.html. I tried this,…
Matt D
114
votes
6 answers

What does "The following packages have been kept back" mean?

When doing an apt-get upgrade I sometimes get a message saying "The following packages have been kept back". For example: $ sudo apt-get upgrade Reading…
Charles Roper
  • 1,245
  • 2
  • 9
  • 8
114
votes
2 answers

Is Vim immune to copy-paste attack?

You should never paste from web to your terminal. Instead, you should paste to your text editor, check the command and then paste to the terminal. That's OK, but what if Vim is my text editor? Could one forge a content that switches Vim to command…
Adam Trhon
  • 1,623
  • 3
  • 17
  • 20
114
votes
2 answers

How does tcp-keepalive work in ssh?

I am trying to code a shell-script that uses a ssh-connection for doing "heartbeats". I want to terminate the client- and server-side of that connection after a certain timeout (after the connection drops). What I found so far: TCPKeepAlive yes/no…
Nils
  • 18,202
  • 11
  • 46
  • 82
114
votes
8 answers

Why is scp so slow and how to make it faster?

I'm trying to copy a batch of files with scp but it is very slow. This is an example with 10 files: $ time scp cap_* user@host:~/dir cap_20151023T113018_704979707.png 100% 413KB 413.2KB/s 00:00 cap_20151023T113019_999990226.png 100% …
laurent
  • 1,868
  • 3
  • 17
  • 22
114
votes
8 answers

SED: insert text after the last line?

This sed command inserts a tag to the beginning of a file: sed -i "1s/^/
user2362
114
votes
3 answers

How do I write all lines from less to a file?

I've piped a command to less, and now I want to save the command's output to a file. How do I do that? In this case, I don't want to use tee, I want a solution directly from less, so that I don't have to rerun a long-running command if I forgot to…
Flimm
  • 3,970
  • 7
  • 28
  • 36
114
votes
6 answers

How can I find available network interfaces?

This is in regard to linux, but if anyone knows of a general *nix method that would be good. I booted a system yesterday with an ethernet cable plugged in. "NetworkManager" is not installed, so once it started I went to look for the name of the…
goldilocks
  • 86,451
  • 30
  • 200
  • 258
114
votes
5 answers

Kill all descendant processes

I'm writing an application. It has the ability to spawn various external processes. When the application closes, I want any processes it has spawned to be killed. Sounds easy enough, right? Look up my PID, and recursively walk the process tree,…
MathematicalOrchid
  • 5,664
  • 7
  • 35
  • 62
113
votes
4 answers

what is the CentOS equivalent of /var/log/syslog (on Ubuntu)?

On ubuntu this file exists: /var/log/syslog. However the same file does not appear on CentOS Distributions. What is the equivalent file on CentOS?
brakertech
  • 1,385
  • 2
  • 11
  • 12
113
votes
4 answers

How do you use the command coproc in various shells?

Can someone provide a couple of examples on how to use coproc?
slm
  • 363,520
  • 117
  • 767
  • 871
113
votes
7 answers

How to kill SSH session that was started with the -f option (run in background)

I'm pretty lost on this. From the man page: -f Requests ssh to go to background just before command execution. After starting SSH with the -f option, I have a working tunnel. But after I finish using it I don't know how to further interaction…
MountainX
  • 17,168
  • 59
  • 155
  • 264
113
votes
5 answers

How to avoid the need to issue "y" several times when removing protected file

I'm looking for a solution to be used as a response to "rm: remove write-protected regular file [x] ?" I was thinking of issuing a character followed by carriage return for several amount of times, in bashrc. How do we do that?
Iancovici
  • 1,252
  • 2
  • 8
  • 11
113
votes
8 answers

tmux status-bar corrupted after catting a binary file, how to reset?

I accidentally screw up my tmux terminal after cating a binary file. Now my tmux is messed up. Detaching and re-attaching doesn't help, nor does a redraw (C-b r). Running reset only redraws the active pane, not the rest. Running ssty sane either in-…
gerrit
  • 3,457
  • 6
  • 25
  • 41