Questions tagged [bash]

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

480 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5 votes
0 answers
6k views

WARNING: git-filter-branch has a glut of gotchas generating mangled history rewrites

I want to clean a large file from my local git repository (and incidentally clean my repository to reduce size). This is my bash: #!/bin/bash bigfile="/path_to_mygitproject/bigfile.tar.gz" git filter-...
acgbox's user avatar
  • 398
5 votes
0 answers
805 views

How to get PCI Tx/Rx byte counters?

I know how to read statistics about the configured network interfaces, for example via cat /proc/net/dev. Is there a way to read similar byte counters of PCI or PCIe traffic? Apparently, according ...
perde's user avatar
  • 51
5 votes
0 answers
3k views

How to set TeamCity Command Line Runner default shell?

I'm starting my TeamCity agent on Ubuntu 15.10 via an init.d script like so: #!/bin/sh ### BEGIN INIT INFO # Provides: TeamCity Build Agent # Required-Start: $remote_fs $syslog # Required-...
Mario Tacke's user avatar
5 votes
2 answers
3k views

Change Alpine Linux default shell

Alpine defaults to ash as the login shell, I want to change it to bash. What I did so far: installed bash by sudo apk add bash installed shadow by sudo apk add shadow I changed my user's login shell ...
elsni's user avatar
  • 455
4 votes
1 answer
1k views

Echo something before SSH prompt with pam_exec

I want to echo some text from a pam_exec script after a successful SSH login (pubkey) but before the script itself exits (2FA purposes). Whatever the script prints during its execution is displayed ...
Riccardo Salve's user avatar
4 votes
0 answers
854 views

Dante Socks Multiple instances

I have correctly installed Dante on Ubuntu server as a proxy, and it works, but I must have e multiple instances of it (each of them has to works in different port). I have tried it in this way: ...
CuriousPanda's user avatar
4 votes
0 answers
397 views

Git Pull on CGI and Command Line have different results

I have an "after push" webhook on GitHub that calls a CGI script to update a Jekyll website. The script: user@server [~/_repo]# cat cgi-bin/githook.cgi #!/bin/bash echo Content-type: text/plain echo ...
yakatz's user avatar
  • 1,243
3 votes
2 answers
5k views

Use Logrotate to truncate log files after every entry or clear last 'n' entries

i have created a logrotate config file: touch /etc/logrotate.d/.test with the conficurations: /home/myUser/test*.log{ size 0 hourly rotate 0 nocreate nocompress ...
ioaniatr's user avatar
  • 131
3 votes
1 answer
584 views

Is rbash secure if user login and ssh passwords are disabled?

I've got a server that I want to use as an SSH gateway for remote and local port forwarding. I don't want arbitrary commands to be able to be executed on it, only my scripts. I keep reading about how ...
Ivan X's user avatar
  • 131
3 votes
2 answers
585 views

How to exit after starting a service in Linux for loop

I have a for loop I'm using to stop and start number of development servers here is an example. for i in `cat hosts` ; do ssh $i -i .ssh/key.key -t sudo /etc/init.d/jboss-as start ; done This will ...
user1007727's user avatar
3 votes
1 answer
2k views

JBoss EAP 6.2 on RHEL 6: ./bin/init.d/jboss-as-standalone.sh hangs while calling via SSH

I'm using jboss-as-standalone.sh to manage JBoss EAP standalone as a service. I can start/stop the service with "service jboss-as-standalone.sh start/stop" while I'm on a terminal. But I would like ...
roehrijn's user avatar
  • 223
2 votes
1 answer
6k views

Not able to access groovy variable inside shell script in JenkinsFile

def NAMESPACE = "Dev" def BODY= sh( script:'''body=$(cat <<-EOF { "name": "${NAMESPACE}", "type": "regularwebapp" } EOF ) (echo $body)''...
Sidd's user avatar
  • 21
2 votes
0 answers
3k views

Apache 2.4 environment variables in config

Ok, so I'm building a docker image for apache. I want to allow users to specify custom apache config with the environment variable. TL;DR The question could be simplified to this: how to use ...
pavel.sheiman's user avatar
2 votes
0 answers
168 views

How to auto init direnv on Google Cloud Shell?

my .bashrc has these lines at the bottom: if [ -f $HOME/tools/bashrc ]; then source $HOME/tools/bashrc fi and $HOME/tools/bashrc has this code at the bottom: eval "$(pyenv init -)" pyenv ...
Noel Pure's user avatar
  • 121
2 votes
0 answers
1k views

How to temporarily remove limit on ufw logging rule

I'm trying to debug some ufw firewall rules, but I've found that the logs don't consistently log the connections. It appears this might be because ufw adds limits to the underlying iptables rules: ...
vy218's user avatar
  • 151
2 votes
0 answers
2k views

WSL issue: cannot execute C:\Windows\System32\Bash.exe from elevated PowerShell - “access is denied” - works in normal CMD/PS prompt (no admin rights)

I have an issue with WSL (Windows Subsystem for Linux) in PowerShell. If I run the Ubuntu 18.04 LTS app (the UWP app) it works as expected. However, if I run and run Bash.exe from an elevated ...
SamAndrew81's user avatar
2 votes
0 answers
10k views

How to kill rsync daemon that keeps respawning

How do I kill these rsync daemons that keep respawning root@que2 ~ # ps aux | grep rsync root 9660 0.0 0.0 19928 2844 ? S 13:35 0:00 rsync -rlptD --progress --delete --exclude=server/...
Vituvo's user avatar
  • 337
2 votes
0 answers
703 views

stream a command's stdout, and merge with terminal's stdin to a single stdout

This answer shows numerous ways to stream multiple commands into another command, but since they use subshells you can't do stdin. While you can achieve this with named pipes, it's somewhat ugly and ...
J V's user avatar
  • 173
2 votes
0 answers
1k views

Systemd forking chained scripts

Consider this scenario: Systemd Type=forking service starts one shell script, which in turn starts another script and exits, which will then start the actual service/daemon process. Now systemd will ...
Mastacheata's user avatar
2 votes
0 answers
350 views

Monitoring ports with netcat on a remote server and Zenoss

I'm pretty new to using Zenoss, so excuse if this is something simple. I have a bash one-liner that checks a bunch of services are running on certain ports: for i in {80,443,5009,5010,5020,5030,5040,...
Theo's user avatar
  • 21
2 votes
2 answers
2k views

unable to run generated python (selenium) script from PHP

I have an Ubuntu machine for headless selenium tests. I generate a python script in /var/www/tmp/random123name.py via PHP and execute them. The script works when run from command line user, fails ...
fab's user avatar
  • 151
2 votes
0 answers
2k views

Running inotifywait on startup of machine

I want to start this inotifywait script on startup of the machine, in order to monitor the folders from the moment of booting: #!/bin/bash while inotifywait -r -e modify,attrib,close_write,move,...
Biffy's user avatar
  • 121
2 votes
1 answer
2k views

lftp mirror leaves empty folders on remote

My script is set up with this for lftp lftp -p 2218 -u $login,$pass sftp://$host << EOF set mirror:use-pget-n 5 mirror -c -P5 --depth-first --Remove-source-files --log=/home/dog/...
heartbt's user avatar
  • 21
2 votes
0 answers
908 views

Bash and background processes PGID and receiving signals

My actual problem is that a process I run in an rcfile in docker as docker run container bash --rcfile rcfile remains attached to the bash session by sharing the PGID which means that when I Ctrl-C an ...
Arkaitz Jimenez's user avatar
2 votes
1 answer
245 views

SNMPget and bash gives strange results (gauge32 values incorrect)

Reallly strange to me but here is the problem. If I use an SNMP client such as ManageEngineMibBrowser to query the appliance I get what look like reasonable Numbers: dpStatusMemoryStatusUsage.0 97 ...
Seer's user avatar
  • 141
2 votes
3 answers
2k views

Dynamic logic in environment variable?

I regularly invoke a particular remote server from a (Linux/bash) command line via tools like cURL or wget. This server requires an authentication token that expires every 10 minutes. I have a program ...
Brandon Yarbrough's user avatar
2 votes
0 answers
654 views

use socat to provide password to bsign

I have many servers, where I deploy various binaries. For this purpose I use a script that packs them into archives, publishes to the local repository and then ssh-es to the target servers and ...
gluk47's user avatar
  • 221
2 votes
0 answers
532 views

Error in killing Tshark from shell script

I'm getting this error: * glibc detected * /usr/sbin/tshark: double free or corruption While doing as below, any idea why? #!/bin/bash trap 'my_exit; exit' SIGINT SIGQUIT count=0 /usr/sbin/...
shark_t-shark's user avatar
2 votes
1 answer
751 views

init script terminating with ssh session

We need to run pt-stalk on a handful of servers to keep an eye on mySQL, and I was sick of manually starting it every time the server rebooted. A little googling turned up an init script for pt-stalk, ...
Sammitch's user avatar
  • 2,151
2 votes
2 answers
164 views

Are passwords sent via a bash script retrievable?

As part of running a backup script for a linux server, I have commands like mysqldump within a bash script which contain the mysql root password, and certain ftp server passwords. Are these ...
Joel G Mathew's user avatar
2 votes
1 answer
154 views

Supervisord unable to shutdown fcgi processes

I've managed to set up supervisord with fastcgi on a django project of mine, the problem is that when I make mi program stop, the server keeps running somehow, and my page keeps online. Here is my ...
danielrvt's user avatar
  • 239
2 votes
1 answer
128 views

IBMi bash upgrade

I am trying to install rvm in PASE on IBMi (v7.1) but it is failing because it states bash version 3.2.25 is required. Running bash --version via CALL QP2TERM states I am running the following ...
aaronbartell's user avatar
2 votes
1 answer
2k views

pbs/Torque interactive jobs: bash trick to run command after launch

I'm using pbs interactive jobs in bash, launched using qsub -I, and I'd like to run some command after launch. After this command is run, I'd like to continue to use the interactive reservation as ...
BigChief's user avatar
  • 398
2 votes
1 answer
3k views

run several bash scripts with expect code and leave them running

I have a bunch of several bash scripts that will perform some actions that require user input, therefore I'm using expect with it. However, I need one to keep running. But if I use expect, the expect ...
Andreas Calvo's user avatar
2 votes
0 answers
491 views

How to run script only if load balancer is NOT routing requests to it via bash script?

I have 4 cloud instances. First is a load balancer (LB), and then 2 instances with the identical setup holding the application code (APP1 & APP2). And finally, I have a database instance (DB). DB:...
Housni's user avatar
  • 21
2 votes
1 answer
43 views

Generating and testing variable from a MAC vs PC in Linux Bash script

I am supporting two groups. I have one script, and I would like to keep it at one. I am having trouble with a test function: convtype=./Sample*/ if [[ -n convtype ]]; then where it runs fine for ...
Michele's user avatar
  • 21
1 vote
0 answers
62 views

Executing a list of commands on distinct lines with bash -c?

I pass a list of commands to a bash script through an environment variable as shown in the example below: CMDS=' date > date.txt cat date.txt date | rev ' script What is the correct ...
chmike's user avatar
  • 448
1 vote
2 answers
178 views

DHCP starting before network is ready

I am having a problem with my DHCP server. When it restarts the isc-dhcp-server does not get ready because the network (it uses NetworkManager) is not ready. I put a sleep command in the isc-dhcp-...
Anderson Silvestre's user avatar
1 vote
0 answers
41 views

crontab -> shellscript -> docker -> redirect output to localfile

I am currently switching from rsync to a borg based backup. Everything is working, except getting the output of borg to my logfile. My setup is as follows: I am trying to do everything in docker to ...
peez80's user avatar
  • 191
1 vote
0 answers
148 views

Set GitHub secret keys in bulk – sh file

I’m in the initial stages of building a simple automated deploy pipeline. One of the steps I’d like to implement would be setting the GitHub Actions secrets in bulk, since I have many of them in my ...
Jorge Mauricio's user avatar
1 vote
1 answer
94 views

Bash has problems with cmdline nft cmd vs script

linux mint. uname -r yields 5.15.0-56. dpkg-query -l bash yields 5.1.6ubuntu1. My script shows this problematic output when bash -x script invoked: attrib =' '\''{type nat hook prerouting priority ...
ArrowInTree's user avatar
1 vote
0 answers
420 views

AuthorizedKeysCommand setup prompts for password

The issue: Even though I've set up AuthorizedKeysCommand and password authentication is stopped when I attempt to log in from my Mac, I am still being asked to enter the password: OS: Rocky Linux 9.2 ...
zamunda68's user avatar
1 vote
1 answer
219 views

why "grep -v" or "tail -f" stop my program's output?

I have a server for Euro Truck Simulator 2 which is called by the following command: LD_LIBRARY_PATH='$ORIGIN/../../linux64' eurotrucks2_server When the server is running, sometimes I get these lines ...
roughnecks's user avatar
1 vote
0 answers
49 views

How can I install application as root and start and stop it as non root?

I have a script which will install mysql server, java and then my java application. I want to create a test user and group testg, the application will start and stop by non-root user (here test user) ...
user15566016's user avatar
1 vote
0 answers
140 views

Given a command whose STDOUT prints to several lines, how might I format each of them (e.g. prepend a string, change a color, etc.)

Okay, so, contrived example here, but it's the simplest instance I could come up with the produces the conditions I'm trying to alter. I'm trying to run a black-boxed command and alter the multi-line ...
NerdyDeeds's user avatar
1 vote
0 answers
226 views

How can I escape the "|" in file names in a bash script?

I have a list of files in the Linux file system. Some of them contains a "|" in the names. How can I escape the "|" in a bash script to perform file operation (copy, move) in the ...
MHW's user avatar
  • 11
1 vote
0 answers
515 views

How do I set environment variables so that they execute when calling WSL from PowerShell?

First let me clarify the question. I'm not asking how to sync environment variables. What I am asking is how to set JAVA_HOME so that when I call wsl echo `$JAVA_HOME from powershell it writes out the ...
Jason Thompson's user avatar
1 vote
0 answers
219 views

Bash slash does't work in wildcards square brackets

I'm curious why command ls -pd *[!/] or ls -pd *[!\/] doesn't match all files which don't end with /. My use case is that I want to list only files inside the current working directory. I know that it'...
Alex Misiulia's user avatar
1 vote
0 answers
135 views

ssh pass host fingerprint and private key without creating them as files

I'm trying to invoke ssh with a custom private key and host fingerprint stored in local vars rather than in files. I would like to avoid creating temp files because if my script is killed I'll get no ...
capr's user avatar
  • 231
1 vote
0 answers
685 views

How to export the details of a digital certificate (.cer file) to a csv file using powershell?

I have a digital certificate that I'm using for a specific task. I need to export the details of the certificate such as the serial number and issuer to a csv file that is already on my computer using ...
Darius's user avatar
  • 11

1
2 3 4 5
10