Questions tagged [bash]

Bash is the Bourne Again SHell, the successor to the classic Unix sh (shell).

bash is the Bourne Again SHell, the successor to the classic Unix Bourne shell (sh). It's the default shell on many Linux distributions, including RedHat, CentOS, Debian, and Ubuntu.

The premier online guide is the BashGuide.

3527 questions
66
votes
6 answers

Straight forward way to run ssh-agent and ssh-add on login via SSH?

I'm trying to have the following commands be auto-executed when I login to my server via ssh: ssh-agent /bin/bash ssh-add ~/.ssh/id_rsa My ssh key has a passphrase and I'm fine with entering it once per login. I tried putting this in my .bashrc…
Click Upvote
  • 855
  • 2
  • 8
  • 12
66
votes
2 answers

Bash: Difference between > and >> operator?

I don't know much about bash. My instructor asked me to make a cat script and to observe the output and then tell what is the operator > and what is the difference between the operators > & >>. I am unable to find any justifications. Could you…
jumbo18
  • 677
  • 1
  • 5
  • 3
65
votes
18 answers

How to ping in linux until host is known?

How can I ping a certain address and when found, stop pinging. I want to use it in a bash script, so when the host is starting up, the script keeps on pinging and from the moment the host is available, the script continues...
Sander Versluys
  • 911
  • 1
  • 10
  • 12
62
votes
6 answers

How to pass password to scp command used in bash script?

Possible Duplicate: Connect through SSH and type in password automatically, without using a public key I have a bash script that makes dump of DB then copies file from one server to another but it always asks for password before connection. scp…
chubbyk
  • 883
  • 2
  • 10
  • 15
60
votes
1 answer

What is the difference between a 'Login' and an 'Interactive' bash shell

What is the difference between a ‘Login’ and an ‘Interactive’ bash shell? I have quoted Wikipedia below but can anybody give a better answer? EDIT: This is a community wiki so maybe rather than voting to close you could provide examples of which…
Gareth
  • 8,573
  • 13
  • 44
  • 44
59
votes
6 answers

bash: variable loses value at end of while read loop

I have a problem in one of my shell scripts. Asked a few colleagues, but they all just shake their heads (after some scratching), so I've come here for an answer. According to my understanding the following shell script should print "Count is 5" as…
wolfgangsz
  • 8,847
  • 3
  • 30
  • 34
58
votes
5 answers

Bash find command verbose output

Is there way to tell the bash find command to output what it is doing (verbose mode)? For example for the command: find /media/1Tb/videos -maxdepth 1 -type d -mtime +7 -exec rm -rf {} \; to output: Found /media/1Tb/videos/102, executing rm -rf…
Alex
  • 1,828
  • 4
  • 31
  • 52
56
votes
9 answers

How do I run a local bash script on remote machines via ssh?

I am looking for a way to push configuration from one central machine to several remote machines without the need to install anything on the remote machines. The aim is to do something like you would find with tools like cfengine, but on a set of…
tremoloqui
  • 1,303
  • 1
  • 10
  • 9
54
votes
3 answers

get notification when systemd-monitored service enters failed state

I need to have network messages sent when a systemd service I have crashes or is hung (i.e., enters failed state; I monitor for hung by using WatchdogSec=). I noticed that newer systemd have FailureAction=, but then saw that this doesn't allow…
Display Name
  • 761
  • 1
  • 8
  • 13
54
votes
12 answers

What are useful .screenrc settings?

Basically like some of my own that I've posted below. I'm looking for added functionality to the programme 'screen'. At the very least have a look at the last line for a fantastic 'menu bar' at the bottom of a screen session. ## gyaresu's .screenrc…
Gareth
  • 8,573
  • 13
  • 44
  • 44
54
votes
16 answers

Stop ssh login from printing motd from the client?

I've got SSH passwordless set up, however it prints the MoTD when it logs in. Is there anyway to stop that happening from the client side? I've tried ssh -q but that doesn't work. I don't want to use ~/.hushlogin nor do I want to change the server…
Amandasaurus
  • 31,471
  • 65
  • 192
  • 253
54
votes
6 answers

Cron: Only get errors in emails?

I finally set up a realistic backup schedule on my data through a shell script, which are handled by cron on tight intervals. Unfortunately, I keep getting empty emails each time the CRON has been executed and not only when things go wrong. Is it…
Industrial
  • 1,579
  • 6
  • 24
  • 37
53
votes
9 answers

Determine if filesystem or partition is mounted RO or RW via Bash Script?

Is there an easy way to determine if a mounted filesystem is mounted as Read-Only or Read-Write? I was thinking just to pipe mount but I thought there might be an easier way.
Jake Wilson
  • 8,814
  • 29
  • 97
  • 125
53
votes
7 answers

Force SSH to use a specific shell

Is there any way to force SSH to use a particular shell on the remote end, regardless of what the user's default shell is? I've tried solutions akin to: ssh host.domain.com /bin/bash -c 'complicated, multi-line command' but unfortunately the…
plinehan
  • 675
  • 1
  • 5
  • 6
52
votes
8 answers

bash/sed/awk/etc remove every other newline

a bash commands outputs this: Runtime Name: vmhba2:C0:T3:L14 Group State: active Runtime Name: vmhba3:C0:T0:L14 Group State: active unoptimized Runtime Name: vmhba2:C0:T1:L14 Group State: active unoptimized Runtime Name: vmhba3:C0:T3:L14 Group…
carillonator
  • 815
  • 3
  • 12
  • 22