Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Questions tagged [bash]

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

2
votes
2answers
45 views

Systemd: Tell if script was run by systemd or by user

How can I tell if a script was called from systemd or from a user? I created a service for an old school daemon. We just switched to systemd and some of my admin like to call the rc-script directly. ...
0
votes
0answers
17 views

I have 2 identical servers but mail.domain.com for one is not working properly [closed]

I have two servers that are setup to be their own mail servers. I have mail.domain1.com working perfect. mail.daddysmoonshine.com however, is not working at all. When I ping mail.daddysmoonshine.com ...
0
votes
0answers
3 views

simple cat echo process substitution hangs [migrated]

Simple process substitution with cat seems to hang: cat >( echo hola; ) never finishes. Also tryed: cat >( echo hola; exit; ) Manually closing the standard out file descript from the ...
0
votes
1answer
14 views

How can I run many heavy process on many files without significantly bogging down my server? [closed]

I have a process that monitors a mounted CIFS share for new files. When a new file appears, I want to run a command on that file. (Basically I've implemented a poor man's inotify - I can't use inotify ...
0
votes
0answers
11 views

Backup upgradable packages with dpkg-repack on debian

I want to list upgradable packages and automatically repack them to .debs. My try: fakeroot -u dpkg-repack `apt list --upgradable | cut -f1 -d"/" | awk '{if(NR>2)print}'` So it gets package names,...
0
votes
1answer
69 views

Get IPv6 route for VM

is there any option to get something like this for IPv6 (inet6 or -6): ip route get 8.8.8.8 Result: 8.8.8.8 via 94.**.***.1 dev ens3 src 94.**.**.112 uid 0 cache Where I can get the local IPv6 ...
3
votes
2answers
54 views

Upgrading a MySQL database using numbered scripts compared to a version field [closed]

I have been given a task to upgrade a MySQL 5.7 DB using a directory of sequenced scripts and comparing them to a version field in a DB. You should query the DB, then compare the returned table ...
0
votes
1answer
28 views

Defining array in shell script

I am trying to define array in my shell script which would have content like below cassandra_hosts=(cassandra1.test-dev.local cassandra2.test-dev.local cassandra3.test-dev.local) But it doesn't let ...
0
votes
0answers
9 views

How do I make my backspace key functional in a bash script for Linux being accessed remotely from Windows? [migrated]

I have a bash script on CentOS 7.4 with the following line that lets a user input a variable and then lets them confirm that what they entered is indeed correct: read -p "Enter the name of the ...
-1
votes
1answer
50 views

When someone gains remote access to a server are there other ways to execute system commands other than the bash shell?

I am hardening a server and attempting to build a restrictive layer to a potential hacker even with root access to the server to do harm. If a user gains root or user access to the shell via say ...
0
votes
0answers
31 views

How to grep from tee? [migrated]

I want to check wether the output of my command contains "rerun" (and then rerun) but I also want to display the whole output. I know that I could use one of these: command | tee >(grep rerun) ...
0
votes
0answers
34 views

Ubuntu 18.04 cron.hourly script not running

I have a script in /etc/cron.hourly that I want to run. The script is something like this: #!/bin/sh -e echo "Doing something" eval $(do_something) exec >> /tmp/log 2>&1 and $ ls /etc/...
0
votes
0answers
7 views

POST JSON using CURL on Mac without bash errors [migrated]

I am trying to post a JSON using curl on a mac. curl --request POST \ --url 'https://sample.com/form'\ --header 'Content-Type: application/json'\ --header 'x-token: 123456789'\ --data '{ -- json ...
0
votes
0answers
25 views

How to get Linux commands history in Splunk without Splunk Forwarder?

We have tons of Linux machines which are all connected to Active Directory (AD). AD logs are being pulled in Splunk. Is there a way to get the command history of all Linux machines in Splunk from AD ...
0
votes
0answers
30 views

override .bash_profile on puppet config, for nodes

I have a puppet master configuration, which i have yet to identify what is overriding(deleting them replacing with a core file) the bash configs. I have solved one of two of my issues, the first ...
0
votes
1answer
32 views

Bash checking if IP/Port is UP

im trying to check with a bash script the status of an IP/Port via netstat. Unfortunately it dont works ... I get an exit 1 even if it should be exit 0. RUNBOT=$(netstat -tulpen |grep ${IP}:${PORT} | ...
0
votes
1answer
38 views

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 ...
-2
votes
2answers
46 views

how to find nginx command without problems [closed]

I have a problem with nginx, doing: nginx -t i get -bash: nginx: command not found root@vpslive /# find /usr/ -name 'nginx' /usr/share/nginx the nginx server is running, i'm afraid I'll have ...
0
votes
2answers
132 views

CentOS 7 custom service failure (Interactive authentication required)

I am trying to setup an OFBiz fork called Scipio as a service on CentOS 7. The service wrapper script changes the user to a dedicated one for the program. All of the program's files are owned and in ...
3
votes
1answer
152 views

How to share/persist a SSH connection from a shell script that runs multiple commands

I have a shell script that connects via SSH to the same host (my-server) and runs a variety of commands mixed throughout the script. For example: ssh -o ConnectTimeout=3 -o ConnectionAttempts=3 user@...
0
votes
0answers
24 views

Fix terminal when it doesn't do carriage return

Every so often, a terminal will get confused and screw up newlines. For example, when you hit return, the cursor will go one down, but not back to the left. Another symptom is up-arrow doesn't go back ...
3
votes
1answer
112 views

How to check via aws cli if a specific rds instance exists?

I want my bash script to detect, if an AWS RDS instance with a specific name exists already. This is what I tried: #!/usr/bin/env bash DBINSTANCEIDENTIFIER=greatdb EXISTINGINSTANCE=$(aws rds ...
0
votes
1answer
79 views

Restart or reload Apache as “www-data” user

I have a webhook script written in Python on my Debian/Apache2.4 server, so that it runs a deploy .sh script when pushing on GitHub. So, the script is executed by standard Apache user "www-data". My ...
0
votes
0answers
40 views

systemd timer OnCalendar is not restarting

I have a problem with systemd timers. I want to run a bash-script every minute. This is my runmyscript.service file: [Unit] Description=RunMyScript [Service] User=myuser Type=simple ExecStart=/bin/...
0
votes
1answer
53 views

systemd cannot restart service file

I have written a bash script which I want to run every 60s (don't worry, I have tried the Script out, it runs perfectly). Now I wanted to implement it in systemd .service file, but so far it doesn't ...
0
votes
0answers
29 views

How come I have an SSH_CONNECTION env variable when I open a terminal?

I just learned in Getting hostname of the computer connected to the ssh session about a wonderful env variable called SSH_CONNECTION. I want to use it to detect if my terminal tab is connected to ...
0
votes
1answer
21 views

access SpamAssassin SpamBox from command line

I am trying to create a CRONjob to delete spam older than x days. I can do this from the command line with non-spam emails by using the following script: find "/home/account/mail/example.com/username/...
2
votes
3answers
121 views

Stop a process (script) from invoking oom killer

I had a very unfortunate situation, where a bash script that contained a subtle error gone wild and took all available memory and then started killing other tasks (production apps!) to get even more. ...
0
votes
1answer
45 views

RHEL 7.5 Cannot Yum install from text file [duplicate]

I cannot figure out why installing packages listed in a text file with Yum wouldn't work but for some reason it does not. Yum cycles through all the listed package names and and lists them as ...
1
vote
1answer
88 views

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, ...
3
votes
2answers
108 views

How to run a script on a server 1 minute after a commit has been made?

Apart from creating a 2nd script which would check the time of the last commit and then run the main script and which would be too complex of a solution, is there a simpler one?
0
votes
0answers
18 views

Bash echo vs here string not consistent

Look at these equivalent commands with correct expected behaviour: me@vm:~$ echo "hello" | cat hello me@vm:~$ cat <<< "hello" hello Both are correctly sending text to cat's STDIN this is ...
-1
votes
2answers
296 views

Docker run file not found

I am trying to write a simple dockerfile that wraps around a bash script. The docker file looks like this: FROM openjdk:8-jre-alpine COPY . /build/demo WORKDIR /build/demo/ RUN pwd; ls RUN chmod +x ...
0
votes
0answers
29 views

debian 9 script to add sudo user

I was trying to make a script to set up a sudo user . Copy pasting one by one Debian commands work , but not running in script . Debian9=$(lsb_release -a 2>/dev/null | grep '^Description' | awk '{...
0
votes
1answer
31 views

Nagio NRPE - Always return 0

I'm trying to execute a bash script in nagios by using nrpe client, but it is always returning "0" value as output. If i'm using this command in the script: _VAR=$(atop -r file.atop | grep '^DSK' |...
0
votes
1answer
52 views

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 ...
0
votes
1answer
115 views

ansible-playbook doesn't work inside a bash script

I am not sure what is going on and hence I enquiring here as well in hopes that some of you might. I am trying to figure out why the same one-liner will successfully connect on my remote server ...
1
vote
5answers
210 views

How to detect crypto mining?

I would like to make a Nagios plugin which can detect crypto miners. The problem is if the miner is single threaded and running on a multi core host, then the load avg will be below 1, which isn't by ...
0
votes
1answer
67 views

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 ...
0
votes
1answer
36 views

Corrupt `reverse i-search` database: why and how?

I made a recording of this as it's never happened to me before and seemed pretty weird: https://asciinema.org/a/qVSUzkIX2wLia7EzCFhCYHb9Q Under which conditions would the bash completion database ...
0
votes
2answers
22 views

Ubuntu: how to create a user with ----disabled-password and still have them sudo (which fails as there is no password)

I am trying to write a linode stackscript, which is a bash file which is run as root when you build a new image. It can prompt for parameters such as USER, KEY and possibly, but not ideally, PASSWORD. ...
0
votes
1answer
97 views

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 ...
1
vote
2answers
29 views

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 ...
-1
votes
3answers
264 views

Bash script: save last line output from terminal

I am writing a bash script in which I would like to save the output of the last command in to a variable before running my next one so I can display it later. I have tried a few different methods ...
0
votes
0answers
40 views

Maintaining openVPN connection on CentOS 7 Server

Morning all, I have a headless CentOS 7 server that has an openVPN tunnel to another server at a different location. I have looked around the net and found that if I place a script inside the /etc/...
0
votes
3answers
187 views

Execute local bash scripts on remote server but needs user input

I am using SSH command to execute the bash scripts remotely: ssh user@server 'bash -s' < $script_dir/script.sh And inside the script.sh, I will have the command like below to add ssh keys: ssh-...
0
votes
1answer
93 views

Copy large CSV (110 mil rows) to Postgres 10 in chucks, resume on failure

I want to \COPY large CSV file to Postgres 10, and various types of error is expected from malformed rows i.e. extra quotes, additional column expected etc. I would like to run \COPY command, and on ...
0
votes
1answer
23 views

Nagios Docker Stack Plugin works locally but not remote

I have a plugin to check the services running on docker. I've gone through all of the suggestions from the dozens of posts I have seen here, but I'm still not able to get this to work. The commands ...
0
votes
1answer
35 views

It is possible to insert words in a command?

Hi I'm try to do an installer which is compatible among different linux distros. It is possible to achieve something like this (see the last line of code). PACKAGE_MANAGER=$1 INSTALL_PACKAGE_CMD="" #...
0
votes
2answers
29 views

BASH/Linux - Need a command to recursively compress a specific file type within a multiple level directory

I need to compress a considerable number of pdf and txt files but I want to leave the file structure untouched. The directories have many, many subdirectories. When I want to compress files of a ...