Questions tagged [bash]

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

Filter by
Sorted by
Tagged with
-1
votes
0answers
21 views

Unattended mariadb installation and database creaation on ubuntu 20.04 bash script fails because of sanity checks

I'm trying to create a learning environment on ubuntu, where maria.bd is needed for databases. I'd like to install mariadb with apt-get install mariadb-server and create a user and database ...
0
votes
2answers
16 views

StrongSwan: manually expire security association

I am working on automating some software tests involving IPSec and StrongSwan. These tests basically apply a swanctl.conf file to two gateway machines, then establish a tunnel between them. It then ...
0
votes
0answers
40 views
+50

Can many script instances write to tty (parallel)?

I have recently migrated my upstart scripts to systemd, unlike upstart, I don't see any output on the tty for services being started/stopped. To get that visual feedback, I added something like ...
0
votes
1answer
26 views

I need bash find behaviour explained when using -newermt and -exec ls {}

I have this command: find /var/cache/pkg -newermt 2020-01-30 | grep 'kdeaccessibility-4.14.3_1' Which returns nothing. I change it to this: find /var/cache/pkg -newermt 2020-01-30 -exec ls -D '%...
0
votes
0answers
20 views

BASH: No Such File or directory when comparing Strings

I am trying to create a script to compare an inputted string to an empty value. The logic works, but I keep receiving the following error: ./demo.sh: line 13: [[/var: No such file or directory ...
0
votes
0answers
16 views

Need to re-login during installation [closed]

I need to install and set-up a docker container unattended on Linux hosts (Raspberry Pi). This involves first installing docker on the machine and then building the container. This is all done from ...
0
votes
2answers
51 views

Bash script to login to server using ssh and run commands [closed]

Below is the script which i use to create user on server but everytime i need to copy the script on server.I want to create a script which ill run on my machine.ill enter dest IP adddress and hostname ...
1
vote
1answer
24 views

Append to crontab only if entry does not exist

I am looking for a programmatic way to append to crontab only if the entry does not exist. Also, the exit code must be 0 for both cases where the entry does not exist, or the entry exists. I tried: (...
1
vote
1answer
42 views

linux getfacl shows the correct permissions but user cannot rm a file from command line. “Permission denied”

This scratch file was created by apache -rw-rw-r--+ 1 apache apache 1960 Nov 16 2019 zlz7v5y9.php When executing the following: -bash-4.2$ rm zlz7v5y9.php I get: rm: cannot remove ‘zlz7v5y9....
0
votes
1answer
24 views

How to terminate real time logging after it has been initiated with journalctl -f &

Environment: CentOS 8 I turned on real time logging with the command, $ journalctl -f & I got the information I needed but unfortunately I'm not sure how to stop it. [CTRL] -c does not stop it....
0
votes
0answers
173 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-...
0
votes
0answers
18 views

Bash interactive mode causes process to run in background

cat <<EOF > test.sh bash -i -c date bash -i -c date EOF chmod +x test.sh ./test.sh Wed May 20 09:50:47 PDT 2020 [3]+ Stopped ./test.sh Could someone explain what is ...
0
votes
0answers
24 views

CentOS 8 /etc/profile.d/ not executed

On CentOS 8, the $PATH is not being updated with the value set in my script '/etc/profile.d/app-server-profile.sh' (SSH login). I am logging into the box via SSH. I expect for '/etc/profile' to ...
0
votes
2answers
29 views

Mysql Command over SSH

I am trying to execute a mysql query over ssh it works fine unless i put a where=xxx clause can anyone guide me? here is an example of a working one ssh mysql1.server.xxx "sudo mysql -u root --...
0
votes
1answer
15 views

moreutils chronic - append full output to logfile?

chronic, which is part of moreutils, is a great tool for selective failure-only email notification of cron tasks: chronic runs a command, and arranges for its standard out and standard error to only ...
0
votes
0answers
35 views

Centos Forwardind by portfwd

I have Centos 7 I used portfwd to forwarding incoming connections form my centos 7 server to windows game server, But the Centos 7 server does not receive the connection from the Windows game server "...
0
votes
2answers
40 views

CentOS 7 Forward port to another IP:PORT

I have CentOS 7 that uses IPTABLES for Forwarding port 30120 to windows server For example : Windows games server IP: 192.168.1.3 Linux Centos 7 server IP : 192.168.1.5 iptables -t nat -A PREROUTING ...
0
votes
1answer
35 views

cron not running bash commands

I am using the whenever gem to generate cron commands. I can check these commands with crontab -l. The generated commands are 24 15 * * * /bin/bash -l -c 'cd /Users/Chris/Sites/covid_tracker &&...
0
votes
1answer
23 views

Using Password-Protected SSH Keys for Unattended Scripts on Remote Server

From PC1, I SSH into SERVER1 where I have a bash script, that will SSH & auth to SERVER2 using an SSH-key that's password-protected. Everything works fine when I manually execute my script, using ...
0
votes
0answers
15 views

Removing contents separated with line separator by searching a pattern

I have a file containing below output. ---------- ID: alternatives_create_editor Function: alternatives.install Name: editor Result: None Comment: Alternative will be ...
0
votes
0answers
16 views

Why is there an error on running host program using git bash terminal?

I am using git bash as a terminal to run code. I doing a course where it has asked us to use the host program to look up host names using DNS. However when I run nslookup it works fine. screenshot of ...
1
vote
1answer
112 views

Running a bash script from Putty on a remote server

I was advised to post here after my question was closed on Stack Overflow. I'm trying to run a bash script on a remote server using Putty over SSH. I'm on a Windows 10 machine and the script is saved ...
0
votes
1answer
22 views

Shell Script to kill long running PIDs

I was hoping someone could answer a question regarding this shell script that I've just gotten while taking over a website previously owned by someone else. This was their backup fix to catch any long ...
0
votes
1answer
56 views

Programatically managing groups & users in Gsuite via the API

I have a script that leverages the gcloud tool to create service accounts for a project. I'd like to be able to create Gsuite groups and add the service accounts to them within the same script as ...
1
vote
3answers
69 views

Avoid to write clear password in a sh script

I'm writing shell script on my custom board. In this script I use openssl to encode file at runtime using this command: openssl des3 -salt -in file.txt -out my_file.des3 -k my_password Is there a ...
0
votes
0answers
7 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 ...
1
vote
1answer
24 views

MYSQL Start unit not found

Im using AWS Linux 2 AMI Currently I have AWS EC2 Recently the mysql doesn't work anymore but it worked before. when I tried to do this sudo service mysql start or sudo service mysqld start It ...
0
votes
0answers
29 views

Trying to get SSH output from within a for loop in a script

I'm trying to SSH into a bunch of hosts in order, and run a command to get a list of users on each one. Outside of a for loop, the output shows up just fine one-by-one. Inside a for loop, it ...
1
vote
0answers
54 views

Send and receive SMS with mySMS

Sending and receiving SMS with mySMS using just bash & curl. (Breaking the rules here - don't have a question - but I found this a challenge to make work, with few good examples out there, so ...
0
votes
0answers
94 views

Internet speed test from bash/linux command line hangs

I am running this python script on a remote ubuntu server from command line for speed testing: https://github.com/sivel/speedtest-cli with: $ curl -s https://raw.githubusercontent.com/sivel/...
1
vote
1answer
26 views

How do I parse /* or */* to a bash shell script

I am trying to write a script that will let me get the arguments while running the script. I am able to do so with $@ in the script. But if I run the script with /* or */* it gives the list of all the ...
0
votes
0answers
47 views

How to tunnel all traffic through shadowsocks with v2ray plugin?

Recently I was working ShadowSocks with V2ray plugin, but there was a problem since I encounter routing all the system traffic through ShadowSocks. The problem is I don't know to forward the whole ...
0
votes
0answers
66 views

Tomcat does not shut down correctly with init.d script on system-shutdown - restart prevented

I want to start Apache Tomcat 7 on my Redhat 7 server (RHEL7) automatically at system startup. In order to do that, I did the following steps: creation of the following init.d script and make it ...
0
votes
1answer
27 views

How to grep lines only with matched words in Linux [closed]

I have a little question. I have a list of processes. After this command ps aux | grep postgres I see postgres 1178 0.0 0.2 320064 27060 ? S Apr12 0:05 /usr/lib/postgresql/10/bin/...
2
votes
2answers
43 views

Extract missing paths from bash array of paths [closed]

I have an array of paths: paths=( /foo/exists1 /foo/exists2 /foo/missing1 ) To find those that are missing: ls "${paths[@]}" 1>/dev/null Shows: ls: cannot access '/foo/missing1': No ...
0
votes
0answers
12 views

Unable to delete Computer name form DC using realm?

I am using below command to remove the servers from Active Directory: realm leave --user=<username>@EXAMPLE.COM --remove <DChostname> Can some one let me know which command should we use ...
0
votes
0answers
4k views

Butterfly Backup server

I have a Butterfly Backup server. I implemented a solution as described in this article: dev.to. In my sever list, I have two NAS, used as user file repositories; the files change and are changed ...
0
votes
2answers
27 views

touch -d '20 seconds ago' not working in alpine

I'm trying to use touch -d '20 seconds ago' file.txt Which works in Ubuntu, but not in Alpine. Anybody knows if there's an additional package that does this, or is it not supported by Alpine itself?...
1
vote
2answers
87 views

How to replace files names in multiple directories with bash script?

I have multiple directories with multiple files in each: folder1 file1.jpg file2.jpg file3.jpg folder2 file1.jpg file2.jpg file3.jpg I want to replace like this: folder1 0001....
0
votes
1answer
25 views

Using multiple users in crontab script, silently fails when changing users

I'm trying to run a bash script on a centos server. I've running the script as the root user (both for file permissions), but I also need to use the aws service permissions that belong to a service ...
0
votes
2answers
33 views

Restart service when memory is used over 90%

I am not sure if it is even possible, but can I somehow restart service when memory has been already used over 90%? I mean script will check memory, and if memory has been used over 90% it will ...
0
votes
0answers
16 views

Run script only when docker stops

I want to run script when my docker stops. I implemet it by trap SIGTERM. It works perfect, but when I restart the container the script is running too. (I guess restart does 'stop' and 'start'). I ...
0
votes
0answers
20 views

How Connect Webform To Ansible Or BASH/Python, To Start a Server Service

I'm a newbie with servers. My webmin service often stops after I'm done using it, so I have to SSH in to restart it. BUT that could be a security advantage. So I'd like to use an Ansible script (or ...
1
vote
1answer
33 views

Trust gpg key via script

When performing an automated server deployment, I can upload and import gpg keys via script. But I cannot trust keys. I tried gpg --batch --yes --edit-key keyname trust 5 and echo 5 | gpg --batch -...
0
votes
1answer
38 views

source /etc/environment from script

I have a need to update IP address My environment file: [root@server ~]# cat /etc/environment ip1=192.168.1.1 ip2=192.168.1.2 My script looks like: #!/bin/bash echo ip3=192.168.1.3 >> /etc/...
1
vote
2answers
56 views

GPG I am trying to create a script to automaticaly associate an imported ssh key to a primary key

I am trying to attach an imported ssh key to an existing primary key. The imported ssh key exists inside ~/.gnupg/private-keys-v1.d/ and is usable through the gpg-agent. When I associate it manually ...
0
votes
1answer
53 views

Error: KDC reply did not match expectations

I was facing issues while joining a machine to domain using below command. the server has OS as Almazon Linux 2 server which has to join to example.com. I have done all the prerequisites which are ...
0
votes
2answers
27 views

Is there a way to set up postgres to authenticate users based on the user they are logged in as?

I want to run queries on my postgres databases from scripts and whatnot, without having to do what I do currently: sudo su - postgres psql -U USER ...etc This is cumbersome because I have to type 2 ...
0
votes
0answers
29 views

Use mps-youtube from bash script to generate Youtube URL's

This question is related to my previous question Search YouTube from Linux CLI and return URL. I'm familiar with the mps-youtube application and returning YouTube URL's in a 'manual search'. I have ...
2
votes
1answer
16 views

Bash - Math: Returns integer instead of float

Bash returns value 4 instead of 4.2 when dividing 21/5. And returns 36 when doing 9 * (21/5) instead of 37.8. echo "$(( 21/5 ))" 4 echo "21/5" | bc 4 Similarly ( 9 * ( 21/5 ) ) returns 36 but it ...

1
2 3 4 5
64