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
1
vote
1 answer

Is it possible to whitelist a domain and all subdomains in IPTABLES?

#!/bin/bash IPT="/sbin/iptables" Using a drop all policy for IPTABLES echo "Set default policy to 'DROP'" $IPT -P INPUT DROP $IPT -P FORWARD DROP $IPT -P OUTPUT DROP Trying to define specific rules for OUTPUT connections that include all…
Kickaha
  • 149
  • 2
  • 9
1
vote
1 answer

Find the source of a *nix process?

I have a dev and QA web server running on the same EC2. I've created a shell script (which is called via Cron) to check to see if a process is running and if not, restart it. Shell script: #!/bin/bash process="php" makerun="/usr/bin/php…
niczak
  • 191
  • 11
1
vote
1 answer

Replacing root filesystem with EC2 snapshot

This documentation describes "Restoring an Amazon EBS Volume from a Snapshot". Having done that this documentation explains "Making an Amazon EBS Volume Available for Use on Linux" What I'd now like to know is how to make the restored snapshot the…
glaucon
  • 253
  • 1
  • 6
  • 16
1
vote
2 answers

Bash script as use shell not working with SSH

I'm trying to use a specific bash script as a user shell. So that if the user logs in, the script will be executed. I've created the script and placed it into the home directory for the specific user. I modified /etc/passwd to use the script as a…
user485485
  • 11
  • 1
1
vote
1 answer

Issue to get Cookie: JSESSIONID and auth_cookie

I wanted to execute one API using the command line but need to pass Cookie: JSESSIONID=<>; auth_cookie=<> value while executing it. We have CAS authentication for the target API. Please let me know the curl or another command to get Cookie:…
Sunil Bhoi
  • 189
  • 1
  • 2
  • 9
1
vote
1 answer

Shell script popup with sound

I have a shell script running in crontab to perform certain checks. In case of any problem I want to alert user. For that purpose I am using zenity and play command zenity --error --text='Something has happened!' --display=:0.0 // for pop up play…
Sush
  • 13
  • 2
1
vote
1 answer

sudo followed by another command in ssh heredoc not working

This is my script: #!/bin/sh echo "I'm local" ssh -t -t remote.server << 'EOF' sudo echo "I'm remote and sudo" echo "I'm remote but not sudo" exit EOF This simply doesn't work, maybe because the line echo "I'm not sudo" is supplied as…
akai
  • 113
  • 5
1
vote
1 answer

smbclient - Download latest file

Trying to script a file download in Ubuntu from an SMB network server (windows-esque). I have a folder tree as follows: file1.tar.gz file2.tar.gz file3.tar.gz These files have different modified dates. I want to download the latest file using…
Jamesking56
  • 141
  • 4
1
vote
1 answer

Conditional logic based on cpu load issue

I'am developing bash script, which enabling/disabling ddos protection from cloudflare. Here is my code: #!/bin/bash PERC=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage}'); if [[ "$PERC" -gt 50 ]] then …
1
vote
2 answers

How to move/migrate indices from self hosted Elasticsearch to AWS Elasticsearch service (cloud)

I have a self hosted Elasticsearch 6.2 cluster (2 master nodes, ~200Gb data each). I plan to move to AWS Elasticsearch service & it's not possible to ssh into it. What's the fastest way to move all indices from an old ES cluster to the cloud one? On…
GTXBxaKgCANmT9D9
  • 415
  • 1
  • 7
  • 16
1
vote
2 answers

HKPK Public Key Pinning - Auto add bash script

I recently started using HKPK Public Key Pinning. I have an automated script that generates my csr, certificate, and installs into apache2 on opensuse leap 42.3 I'm looking for a way to add spki fingerprints to the Public Key Pin header in my…
Bennett
  • 11
  • 2
1
vote
2 answers

rsync include/exclude filters on subdirectories

I've read dozens of other answers for this but none of them are working. I have a number of directories like…
user5359531
  • 131
  • 1
  • 7
1
vote
2 answers

Script to delete file based on its name

Need some opinion on my scripting. I have some files like below format:- -rw-r--r-- 1 root root 0 Apr 12 15:56 hostdata_mm-xxx1_2018_04_03.csv -rw-r--r-- 1 root root 0 Apr 12 15:56 hostdata_mm-xxx1_2018_04_04.csv -rw-r--r-- 1 root root 0 Apr 12…
1
vote
5 answers

Is there a secure way to run multiple MySQL CLI commands without having to keep asking the user for a password?

I have a bash script that runs a bunch of MySQL commands, separated by user input. Each time a query is run, the password must be re-entered. I understand it's best to avoid putting the password on the commandline, so I am wary of asking the user…
Ben Holness
  • 944
  • 2
  • 10
  • 28
1
vote
0 answers

automate server downtime for different servers at different days and time

I have created script with Ansible and also with Python to put servers down in my work environment but If I can create group of all servers and set their downtime at once. Example: If I need to put 4 servers down on Monday and bring up next day.…
anuj tyagi
  • 111
  • 3