Questions tagged [bash]
Bash is the Bourne Again SHell, the successor to the classic Unix sh (shell).
3,559
questions
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 ...
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 ...
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 ...
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 ...
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",
}]
'
...
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 --...
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: ...
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&...
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 ...
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 ...
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
...
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 ...
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 ...
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 -...
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 ...
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)
...
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/...
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 ...
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 ...
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/...
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)''...
-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:...
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 ...
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:/...
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, ...
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"
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"
...
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 ...
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 ...
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 ...
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 ...
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....
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"
...
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 ...
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 ...
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, ...
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 ...
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
...
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 ...
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 ...
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 ...
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:~$ ...
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 ...
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 ...
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 ...
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 ...
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,...
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 ...
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 ...
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 -...