Questions tagged [bash]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
176 views

Remote deployment of a script on linux

We are creating a lab and wanted to setup like 10-15 hosts with ldap. We need to install on each computer some packages that are necessary to run ldap, so my question is - can I somehow run 1 bash ...
Pakuss's user avatar
  • 1
0 votes
1 answer
244 views

How to use a screen with bash script? [duplicate]

I tried to create an executable .sh file with command that create screen like this: screen -dmS ast [comand] And let my crontab execute it like this * * * * * bash /root/my_bash.sh But nothing ...
Шумер Ахмед's user avatar
0 votes
1 answer
102 views

Removing old files from home directories

I need to find and remove files older than 2 weeks from the home directories of my cluster. I do not want to let people just "touch" the file to change the modification date and keep it for ...
David's user avatar
  • 1
1 vote
2 answers
378 views

Zip all files returned from "grep-ril" command

I'm using grep -ril to be able to see all files that contain a certain string: [user@machine]$ grep -ril "test string" file1.log file2.log file3.log file4.log ... I then would like to zip ...
Ress's user avatar
  • 45
2 votes
2 answers
11k views

Curl Command Send Asynchronous Request

I using this curl request for sending data to API : curl --location --request POST 'MY_IP' \ --header 'Content-Type: text/plain' \ --data-raw ' [{ "event_id": "123", }] ' ...
Martin's user avatar
  • 21
1 vote
1 answer
863 views

rsync : write failed - No space left on device (28) despite using --inplace

I am using a script to make a backup of a running Debian Stretch based Linux Distro (NextCloudPi) The method in the script that does the backup uses rsync. backup() { mntimg sync rsync -aDH --...
FlexMcMurphy's user avatar
0 votes
1 answer
1k views

Ansible playbook rebooting the server , wait till reboot complete

I'm facing a issue while executing shell script with ansible playbook. Issue: I'm losing a connection with remote server because shell script is rebooting the server. My Ansible playbook - name: ...
vik2595's user avatar
0 votes
1 answer
36 views

Locate and Move files to a destination [closed]

I intend to locate some files matching a certain pattern. After the files have been located, i want to move them to a new directory. for i in $(find <search_location> -name '<search_pattern&...
Damola's user avatar
  • 31
1 vote
0 answers
4k views

Using URL's with special characters in nginx maps

When using nginx and maps it is possible to rewrite mutiple URL's with a map file. What is problematic is when the URL contains special characters. I have been breaking my head trying to get this ...
Adesso's user avatar
  • 203
0 votes
1 answer
1k views

rsync over multiplexed SSH connection and multiple jumphosts

I need to rsync a file from remote hosts to my local machine over multiple jumphosts. I'd like to use shared SSH connections so that I don't have to submit 2FA multiple times at some jumphosts. The ...
Petr Javorik's user avatar
1 vote
0 answers
120 views

How to do sudo grep in a bash script?

I would like to check if the given ip address is already in the config file. But /etc/ can only be accessed by root, and I'm running the a script as admin. It seems I can't just do sudo #!/bin/bash ...
Houman's user avatar
  • 1,675
1 vote
1 answer
394 views

Sending email with ssmtp From value issue

I am trying to send an email from my cron script using ssmtp, the email is working fine but the "From" value is always showing Ubuntu <[email protected]> which I don't want to use ...
A l w a y s S u n n y's user avatar
0 votes
0 answers
90 views

Trying to partition aws linux server using shell script

When I created Amazon linux server(similar to Centos 7). I had these partitions I am trying to create partitions using shell script lsblk gives me following information NAME MAJ:MIN RM SIZE ...
Daniel's user avatar
  • 109
0 votes
1 answer
47 views

script on changing directory ownership via bash

I am trying to find directories older than 150 days and change their ownership as root. Please can you advice on how do i fix the below pls? find /mnt/mailfolder/ -maxdepth 1 -type d -mtime +150 -...
nick's user avatar
  • 31
0 votes
1 answer
709 views

systemd script do not set correct file permissions at boot time

I have written a simple service that calls a bash script that should change file permissions at boot time. The issue is that it seems that the service is not working as the permissions are not changed ...
Georgi Koemdzhiev's user avatar
0 votes
1 answer
212 views

In Linux/bash how can I prevent asynchronous commands?

I have a makefile that calls external build scripts. Some of these scripts (which I can't change) make use of commands that are forked / backgrounded (or asynchronous as the bash manual names them) ...
Jay M's user avatar
  • 398
0 votes
1 answer
569 views

Add curl command to function for bash profile

How do I add this command as an alias or function to my bash_profile? curl -X GET -H "x-api-key:xxxxxxxxxxxxxx" -H "Content-Type: application/json" https://xxxxxxx.amazonaws.com/...
nipy's user avatar
  • 107
0 votes
1 answer
646 views

Postfix After-Queue Content Filter full example

i'm trying the Simple content filter example: i followed the steps mentioned here http://www.postfix.org/FILTER_README.html#simple_filter but in line 24 of the content filter that can be a simple ...
Byte legion's user avatar
1 vote
0 answers
209 views

trailing "-" as a placeholder

If reading this I then understanding, that you can set the stdin to be piped to the command as parameter to a placeholder "-" like: cat <<EOF | printf - hello new line EOF But it ...
Chris G.'s user avatar
  • 227
1 vote
1 answer
409 views

jcmd works in console but fails in script

I'm getting mad with what should be a simple task: a java process is running, runs out of memory and a script runs. SELinux is disabled. in setenv.sh : -XX:OnOutOfMemoryError='/opt/alfresco/scripts/...
Francesco Papini's user avatar
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
-1 votes
1 answer
2k views

Programatically get full path to binary in powershell (which, where, Get-Command)

How do I get the absolute path to a given binary and store it to a variable? What is the equivalent to the following for Linux Bash in Windows Powershell? user@disp985:~$ path=`which gpg` user@disp985:...
Michael Altfield's user avatar
1 vote
1 answer
520 views

How to get extra vars java link and download it in ansible and extract it

I want to download java from http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz then extract it tar -xzvf jdk-8u131-linux-x64.tar.gz but ...
Rajarshi Das's user avatar
0 votes
1 answer
83 views

Why is this bash script triggering so many false positives for monitoring memory usage?

I am monitoring hundreds of servers both dedicated and virtual using the following script: #!/bin/bash PATH=/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/...
JCats's user avatar
  • 87
0 votes
1 answer
233 views

command that cannot work in background (asterisk)

am trying to run script in background which contain command such like "asterisk -rvd >> xyz.log", when I run it directly it work well but when run it with any background way (service, ...
Centos's user avatar
  • 11
0 votes
1 answer
77 views

How to search for a file when 'find' is not an option

Is there a good way to search for a file if you are for ex. stuck in dracut/initrd? The only thing that I was able to do was: ls /**/**/**/**/* | grep "file name"
Iluvatar's user avatar
  • 121
0 votes
2 answers
6k views

cURL POST bash script adds single quotes to variables with spaces

The first 3 variables will always have no spaces. The fourth "slacksitename" has spaces ip=“x.x.x.x" record_name=“demo.xyz" slackuri:”WEBHOOK" slacksitename:”123 Main St" ...
northport's user avatar
0 votes
0 answers
224 views

SSH from A through B, C to D using private key on B to access C and D

I'm looking for a way to access to a server (D) through 2 proxy (B and C) using SSH keys stored on the first proxy (B). My computer (A) isn't allowed to save the key. I understand the way to access to ...
Thibaut Guirimand's user avatar
1 vote
0 answers
2k views

tar -xvf error "Can't restore time" when trying to extract in certain directories on mac osx but works in others

Strangest thing. I downloaded the openjdk release here: https://jdk.java.net/16/ When running tar -xvf on the file in the ~/Downloads directory it works fine. But when running in /tmp or another ...
Dr. Chocolate's user avatar
0 votes
1 answer
426 views

I Have a problems with qoutes in my bash script [closed]

how to do so that in this script which searches for something from the database. he searched for it and changed its name in the terminal. I have a problem with the quotes here. Maybe anyone know how ...
Black4Killer's user avatar
1 vote
0 answers
186 views

Running tshark and find in parallel + strict time-sorted output

I'm trying to obtain debug output of what "find" does compared to what happens on the network (tshark) Therefore I want to run these commands in parallel and have output meticulously ...
Marki's user avatar
  • 2,854
0 votes
1 answer
1k views

VPN tunnel IP is 172.16.4.2, how can I reverse shell to my local machine, from a box on an attached subnet?

This is the ifconfig: utun2: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1340 options=6403<RXCSUM,TXCSUM,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM> inet 172.16.4.2 --> 172.16....
Dr. Chocolate's user avatar
0 votes
0 answers
440 views

Create bash script to upload backup over FTP

im working on my own bash file to backup DB and transfer over ftp. problem is the output is: Could not open file for writing. my code is: DATE=`date +"%FT%T"` DB_NAME="clcl" ...
Nimafire's user avatar
0 votes
2 answers
2k views

How log commands executed by user

First at all, I have working some years with snoopy and it's not what I need, also checking history file isn't a solution for me. I have to give ROOT access to a developer to install a program on the ...
Nimafire's user avatar
0 votes
0 answers
961 views

Shell Scripting - Multiple Process ID's instead of one

I'm writing a simple bash script to shutdown tomcat, and if it doesn't stop gracefully then check if the tomcat's PID still exists and kill it. I pass the tomcat name as a variable to the script as ...
Raj K's user avatar
  • 1
2 votes
1 answer
2k views

Ansible Search for parent-directory-names of files

I'm trying to get the parent directory Name of files identified by a pattern. base/tool1/sub/test.log base/tool2/abc/values.log base/tool3/sub/test.log I want to get every directory absolute path, ...
Ralf157's user avatar
  • 21
1 vote
1 answer
208 views

spawn-fcgi doesn't start automatically even though has root permission Centos 7

I have very strange problem I don't know how to solve this. I have spawn-fcgi service only starts if I manually start as root but not with on boot systemctl enable spawn-cgi gives me this information ...
danone's user avatar
  • 166
1 vote
1 answer
216 views

How to delete the grepped iptables

I have iptables starting from cali- root@Ubuntu-18-VM:~# iptables -S | grep -oP '(?<!^:)cali-[^ ]+' cali-FORWARD cali-INPUT cali-OUTPUT cali-cidr-block cali-from-hep-forward ...
solveit's user avatar
  • 265
0 votes
1 answer
645 views

Restart services on multiple remote servers securely

I need to write a script so that my colleagues and myself can restart different services on multiple servers. We all connect to the servers with LDAP so i'd like my script to connect our LDAP users to ...
Ror's user avatar
  • 343
1 vote
2 answers
1k views

CENTOS apache ALL=(root) NOPASSWD: /path/to/shell.sh is not working

Trying to do a web interface IPtables management. Created a file test.php $output = shell_exec('sudo bash /usr/bin/iptables.sh 2>&1'); echo $output; Gave /usr/bin/iptables.sh NOPASSWD so I can ...
alvan's user avatar
  • 13
0 votes
0 answers
1k views

The ssh agent cannot 'resolve hostname' when called from within a bash script

I have a bash script #!/bin/bash scp -r some_directory remote_host:~ which I made executable with chmod u+x. The remote_host has been defined in my .ssh/config as follows: Host remote_host HostName ...
Marlo's user avatar
  • 105
0 votes
1 answer
4k views

How to get the permission of `/run/user/1000/gvfs` when system is newly installed?

System is newly installed debian 10. I cannot get the permission of /run/user/1000/gvfs properly,changed from d????????? ? ? ? ? ? to dr-x------ when cd /run/user/1000. me@pc:~$ ...
kittygirl's user avatar
  • 975
1 vote
2 answers
1k views

lxc send file or copy

I am trying to copy a file with lxc, now I am already desperate. Here are some commands that I have tried: #temp=$(cat 2.sh) #lxc-attach -n containerName echo $temp > /root/2.sh #lxc-attach -n ...
ICIM's user avatar
  • 162
0 votes
1 answer
2k views

Active Directory + NFS: Why is domain user's uidNumber, gidNumber not shown by `id` command in Windows?

I am connecting NFS v3 shares (ZFS datasets) from a Solaris file server owned by domain users to Windows computers, but the concept should apply to basically any POSIX-style server. I'm hoping to ...
Avery Freeman's user avatar
1 vote
3 answers
3k views

Ubuntu 20.04: su command bash-autocomplete stopped working

I am using Ubuntu 20.04. The su autocomplete stopped working. For example when I type: su TabTab It lists the files and directories of the current directory, where as it should list the available ...
Ajaib Singh's user avatar
1 vote
1 answer
4k views

Run script after Debian installation is complete

I am using preseed to auto install debian. I want to be able to run a script called "run.sh" at the end of the Debian installation: #!/bin/bash touch /root/example.txt I have tried several ...
ICIM's user avatar
  • 162
3 votes
3 answers
2k views

How can I quickly test a path in bash to determine if any segment of it is a symlink?

If I have a path like this with a symlink: /this/one/two/three Is there is a quick one-liner for determining if one more more segments in the path is a symlink? For example, I'd want to detect if this,...
StevieD's user avatar
  • 552
3 votes
2 answers
1k views

rsync: Remember copied files, even if they are deleted at the destination

I want to run an rsync job that copies data from A to B. The data at the destination will be deleted after processing. However, the processed data should no longer be copied. Is there a way that rsync ...
Linfux's user avatar
  • 31
1 vote
1 answer
787 views

bash over Windows SSH is not working

I have been using an OpenSSH client on Windows for a long time and an SSH server on Linux. Recently I have decided to use the OpenSSH server on Windows 10. I can install it, run the server and login ...
khoshahmad's user avatar
0 votes
1 answer
346 views

Bash: improper function/usage of command basename

What I want in the following command is to find particular files and move them to the other directories while appending ".log" to the destination filename. find /src/dir/ -type f -mtime +3 -...
aschkant's user avatar

1
3 4
5
6 7
72