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
1answer
17 views

Bash - Run 'chage' Command Against Each User Account

I have to audit the users accounts on our linux servers in each environment so I want to script checking whether each account is expired or not. I have a for loop that's pulling user accounts listed ...
0
votes
0answers
10 views

The iptables configuration for OpenVPN does not work

I have a problem and it is that the configuration that I have of iptables so that the VPN works I do not know why I have everything right but it does not work correctly. I pass you the code so that ...
0
votes
1answer
30 views

exec 2>&1 – execlude some command from being logged to file

I have the following in my bash script: # catch input for log-data exec > >(tee -i ${LOG}) exec 2>&1 I want to exclude one command from being written to this log file, but the following ...
0
votes
1answer
76 views

When I run `sudo passwd` I set my password and the script exits okay. Running `sudo chsh -s /bin/bash` immediately after fails

Long time lurker, first time poster. My linux server is behaving strangely. When I run sudo passwd, I can set my password up correctly. However, if I run sudo chsh -s /bin/bash, the command returns ...
1
vote
1answer
25 views

Bash-Skript (Cronjob): Programm öffnen hat falsche Sprache

Which ENV must be exported that a bash cronjob script opens the program in the correct language? If I open the bash script so manually in the command-line the program is opened in the correct language....
1
vote
2answers
19 views

Bash-script: run another script on bottom as an other user

I have a bash script that runs over crontab as root. On the bottom of that script I want to run another bash script as another user in a subshell (detached). How can I do that The normal command would ...
0
votes
1answer
23 views

Simple bash syntax failing passwd

Whenever I try to enter the password for a new user through pipe it doesn't work for me.. this is the command: echo "${PASSWORD}" | passwd ${USER_NAME} However it fails to work, what am I ...
0
votes
1answer
18 views

Get total %cpu,%mem for a process including all threads or sub processes?

Get total %cpu,%mem for a process including all threads or sub processes? For example rsync if you do the following, you get the %cpu,%mem for the parent process only. Where 9215 is pid of active ...
0
votes
0answers
11 views

Find files older than X days using mtime (looks at Modifed attribute)?

On ubuntu I am trying to find all files older than x days in a folder based on: https://stackoverflow.com/questions/31389483/find-and-delete-file-or-folder-older-than-x-days As an experiment I just ...
0
votes
0answers
14 views

How to rename all file and subfolder to first capital letter (and rename filename extension)

This is first task for any moving site from Window to Linux - need to carefully setup name of each files. For example file /one/index.htm and /one/TWO/index.html and /one/two/three/image100.JPG need ...
0
votes
0answers
26 views

Can I use SCP while having multiple AuthenticationMethods, like publickey,password?

My task is to create a bash script that will copy files from server2 in my server1. The issue is that I can't connect from one server to another. I have whitelisted server1 IP on my server2 22 port. ...
0
votes
1answer
15 views

How do I find files and directories not owned by a given user?

I have a set of files within a directory owned by 'alfred'. From a quick inspection, most of the files within are also owned by 'alfred'. I'd like to change ownership of the folder and everything ...
-1
votes
0answers
14 views

bash - dialog command - “select all” button

The link below: Multi-select menu in bash script It correctly shows how to create a menu using the "dialog" command but does not show how to create the "select all" shortcut button....
0
votes
0answers
34 views

Shutdown NAS Synology after backup

We have 2 NAS Synology Disk Station 1618+ with DS1618+ OS' version. The first one (NAS1) receives backups from multiple servers and the second one (NAS2) is supposed to be the backup of that NAS. So, ...
0
votes
0answers
19 views

Find VFAT Partition on USB bus

I have to find a way to mount the first "external" vfat partition on 250 different headless hosts via shell. It could be sdb sdb1 sdc sdc1 etc. I need the device name to mount it with ...
0
votes
2answers
55 views

bash commands to print file name and contents

We have a git repo with a ton of projects and each project has an OWNERS file with one line like 'teams/search' with no quotes. I would like to somehow find all those files and create an array of ...
0
votes
1answer
49 views

Unable to open PHP script files, even though I own them and have permissions

I'm using RHEL 8, and I have run into a crazy problem. My user account is unable to open PHP files. If I have a file, owned by my user, and readable by my user, and I add <?php as the first line, ...
1
vote
1answer
31 views

how to create a script shell command

Hi evry one can someone help me to get this command with scrit shell ? root@VPS:/work# cpan Loading internal logger. Log::Log4perl recommended for better logging CPAN.pm requires configuration, but ...
0
votes
1answer
56 views

On CentOS 8 in profile.d do I need to add my script related to environment variables to both an .sh and .csh file?

I need to add environmental variables related to proxy servers to allow my node.js app to communicate with reCAPTCHA Enterprise on Google Cloud. When I run the scripts from Accessing Google Cloud APIs ...
0
votes
0answers
26 views

Systemd Service Start/Stop Before/After

So I currently have 2 scripts, let's call them script A and script B. What I need when the server boots is for Script A to start (this brings up a database) once that's done, it will bring up Script B ...
0
votes
2answers
49 views

Piping nc to sed and evaluate datetime for each row

Could someone provide any idea, how could i pipe data from nc to sed (or awk, or anything) and evaluate and write to file a timestamp after each row? What i have: # cat /etc/systemd/system/ncserver....
0
votes
0answers
40 views

How to warn someone of a script failure, without email?

I have a script that does hourly backup and sign-encrypting of my Keepass DB on my headless Mac Mini with this code : #!/bin/bash DATE=$(gdate +"%d%m%y_%H%M") LDATE=$(gdate --rfc-3339=...
0
votes
2answers
119 views

8: Syntax error: word unexpected (expecting “)”)

The following code: weekday=$(date +%a) day=$(date +%d) month=$(date +%m) if [[ ( $month == 03 || $month == 10 ) && $weekday = "Sun" && $day > 24 ]] then # ...
0
votes
0answers
30 views

Issues with Bash Script to SSH and Copy String Variables from a CSV to a remote file

Here is my script #!/bin/bash clear PSQLSTART="INSERT INTO TABLE (Name, Description, Field3, Field4, Field5, Field6, Field7, Field8, Field9, Field10, Field11, Field12, Field13, Field14, Field15,...
0
votes
0answers
32 views

How can i Fix ping through iptables?

I am making a script with iptables on the firewall machine and when executing it and I want to ping a web page I get an error: ping: www.facebook.com: Temprary failed to name resolution and this ...
0
votes
1answer
52 views

Bash array with dynamic name

I made the following code : tableList=("books" "centres" "contacts" "courses") for tbName in ${tableList[@]}; do declare -a tableName="ar_${tbName}...
0
votes
1answer
21 views

Display first few characters of first few lines of a text file

On Linux in a bash shell, I have a text file with long lines and would like to look at the first few characters of the the first few lines. Thus, I need something like head, but with the ability to ...
0
votes
0answers
18 views

Output to log file from Script not working

I have an interactive script example.sh for updates, part of which is something like this: echo "Performing Backup of Old software" zip -r backup/backup-$now.zip /var/www/html/...
0
votes
0answers
12 views

Linux read -s command and string with spaces

I want to use read -s fubar to read in a string without echoing it to the screen. This works fine when I input a string with no spaces- with spaces, it seems to not work. How can I store a password ...
0
votes
1answer
79 views

Jenkins vs shell scripts

why would Jenkins get a different result from shell scripts(redhat 7) alone? I have shell scripts that run fine if I execute them from a terminal, however when I run the scripts from Jenkins they get ...
0
votes
1answer
29 views

Writing script runs to tmp file with hour_seconds file name

I'm trying to make sure my cron task is executing every minute, I want to record the output of every run into a location in /var/tmp. This is how my cron file looks like : hours_minutes_file=/var/tmp/...
-1
votes
2answers
43 views

SCP exit 0 when using un-initialized variable and fail to copy

I am trying to test if a file fails to transfer using SCP. I noticed if I use a un-initialized variable, I get exit 0 even though the SCP fails. For example, I have an empty variable called ...
0
votes
0answers
67 views

IPtables rules in python using bash script

Here is my python script in bash, I am using subprocess.run to call iptables command , but I am getting an error subprocess.run(["/usr/sbin/iptables", "-A", "INPUT", &...
1
vote
1answer
57 views

overwriting default $PATH

I am trying to lock down regular users on a Raspbian installation. I'll be using rbash for that. I want to edit the PATH file so that only ~/bin files can be executed. I've stripped $PATH from /etc/...
0
votes
0answers
36 views

Requiring TOTP before every comand in Linux shell

Is it possible to configure say Bash or any other shell in Linux so that a TOTP code is required for every command that is run? As the use case, let's say that I have a production system that is very ...
1
vote
1answer
34 views

How to fix infinite bash loop (bashrc + bash_profile) when ssh-ing into an ec2 server?

I mistakenly have source .bash_profile in the bashrc file and vice versa. Now when I tried to ssh into the machine (ec2), it will stuck at loading bash and get connection closed in a second. Is there ...
0
votes
0answers
31 views

Centos 7.9: Unable to increase the ulimit process for a user

I have an issue with the increasing the limit of user process on the Centos 7.6 server, The user is a non-root user, i am not able to increase the process limit size. It always shows 35 only, inspite ...
0
votes
1answer
99 views

Corrupted curl download when using the resume option?

I'm using curl to download a 10MB file over a poor connection. I use the -C - option in a loop to resume the download if it breaks (see the snippet below). The resuming works when I test locally and ...
0
votes
1answer
21 views

Application stopped to find shared library

wkhtmltopdf is used to create pdf files in Debian Linux. wkhtmltopdf suddenly stopped working. Running it from shell throws library not found error: root@x:/usr/local/bin# ./wkhtmltopdf ./wkhtmltopdf: ...
1
vote
2answers
71 views

How to use expect command with .run program in replace for yes command

The program.run I'm trying to run: Asks 2 questions that need the answer "y" Asks a third question at the end which is "press any key to exit" In addition, it doesn't have the &...
0
votes
1answer
31 views

Add Error Logging to script

I have the following Big Sur Mac OS script: #!/bin/zsh /usr/local/bin/aws s3 cp /Library/FileMaker\ Server/Data/Backups/S3/noon_db_* s3://testbackupnoon rm -rf /Library/FileMaker\ Server/Data/...
1
vote
2answers
67 views

Bash script - check if a variable is located between 2 others variables?

In a Bash script I want to check if var1 is located between var2 and var3. But I can't find how to do it. Something like this. var1=15 var2=10 var3=20 if [ "$var1" is located beetween "...
0
votes
2answers
45 views

Json file with bash

I need delete space and value kubernetes from json file with use bash script: Content json file Input "spec": { "finalizers": [ "kubernetes" ]...
0
votes
0answers
19 views

Using cron to automate backing up server with rsync doesn't work [duplicate]

I have a linux server hosting Minecraft that I can connect to using ssh, I should probably also mention that I do have an ssh key with no passphrase. I want to backup my Minecraft world every hour to ...
1
vote
0answers
82 views

Initramfs - Set hostname from custom initrd script

In our company, I'm creating an Ubuntu Autoinstaller (v. 20.04). For some company reasons, its required modify initramfs. (initrd file). I'm created a script, and added a link to init file in main ...
0
votes
0answers
127 views

Is there a way to programmatically push to GitHub using an oauth token?

I want to use a bash script to push to a "build repository" for my Symfony app, which can then be deployed directly to a server. I have the following so far: #!/bin/bash cd .. rm -rf ...
0
votes
1answer
60 views

Linux user and password copy between servers with cron script [duplicate]

I have two Red Hat 7 Linux servers that I want to keep user accounts synced. I have a bash script that copies these files between servers: /etc/passwd /etc/shadow /etc/group /etc/gshadow /etc/subuid /...
1
vote
1answer
145 views

tail -F still stops on logrotate sometimes

Linux ip-10-10-64-122 4.1.7-15.23.amzn1.x86_64 #1 SMP Mon Sep 14 23:20:33 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux I'm using tail -F in a bash script which in turn loops over the results. This script ...
0
votes
1answer
52 views

Monitor Docker Container for No Output

I have a long running process in a docker container that is setup like this: Dockerfile ... ENTRYPOINT ["./invoke.sh"] invoke.sh #!/bin/bash ./long-running-command If long-running-command ...
0
votes
1answer
53 views

Tranforme each item in JSON array to JSON Object

I need to transform this simple JSON array : ["169","19","33"] To a more complicated JSON Object for each item, like : { "groups": [ { "...

1
2 3 4 5
67