Questions tagged [bash]
Bash is the Bourne Again SHell, the successor to the classic Unix sh (shell).
3,511
questions
0
votes
0
answers
11
views
MacOS (Ventura) Daemons failed to run script
Below is my shell scripts (install.sh) to install my apps to /Users/.my-guard folder.
sudo mkdir /Users/.my-guard
sudo launchctl stop com.test.guard
sudo launchctl bootout system /Library/...
-1
votes
1
answer
25
views
Copy/Move Entire Line To End Of The Line Above
I have a file that looks like the following:
/path/to/a/very/long/path
0 0 0 0 0 0
I need to move the line starting with a number (this can be any value not necessarily 0) to the end of the ...
0
votes
0
answers
20
views
PROMPT_COMMAND duplicating commands on new sessions
Im playing around with PROMPT_COMMAND variable
Was testing out some ways to save all commands into a log file and got some ways using PROMPT_COMMAND + logger + rsyslog
Example export im using
export ...
0
votes
1
answer
31
views
Loggin bash_history using UTC timestamp when not using UTC as system time
I am aware that it is possible to add timestamps to bash_history.
The examples I've seen so far it always uses the current system time. And here is the problem for me: On the one hand, I like to keep ...
0
votes
0
answers
25
views
How to automate mybb installation using ssh bash script [migrated]
I have created this bash script to install mybb application automatically on Centos stream 8.
SSH Bash script
#!/bin/bash
# Define variables for MyBB installation
DB_NAME=mybb_db
DB_USER=mybb_user
...
0
votes
0
answers
21
views
Find directories not containing subdirectories with today file date
Can you please help me with a bash string for finding and listing only parent directories NOT containing subdirectories with today file date, so i can delete them recursively?
My Env is CentOS and dir ...
1
vote
0
answers
29
views
is there a shortcut for /dev/stdout like "-" is for /dev/stdin?
is there a bash shorcut for /dev/stdout like there is "-" for /dev/stdin ?
One of the use cases is to get bash history without line numbers. There is simply no option for that in the history ...
0
votes
1
answer
31
views
Command that run fine... but give me an error when "piped" to grep, inside a docker RUN?
Sorry for the title, I really can't explain better. I'm learning shell programming.
I'm trying to detect if Composer has a script named "post-install-cmd". To do that, one can call composer ...
0
votes
2
answers
82
views
Get the actual value of free memory is sun sparc
I am trying to get the current (not the average) free memory size of SUN SPARC remote server, but I don't have the permission to use free -m command or prtconf. So, I used command vmstat 2 and the ...
0
votes
1
answer
78
views
systemd not able to run some bash scripts
(Update with more info May 16, see end of post for journalctl messages)
I've created a systemd timer and service with the purpose of running a handful of bash scripts. In particular I'm aimed at ...
1
vote
1
answer
41
views
/etc/cron.d not running job [duplicate]
I need to run a script as a user to backup my database every night. I added the following cron job in /etc/cron.d/backup-mysql via ansible.
0 3 * * * backup_mysql /path/backup-mysql.sh
I can see the ...
1
vote
1
answer
31
views
How do you compare time date strings not actual dates and times?
I have a bunch of directories with video files that I would like to merge into larger videos. The logic is that the filenames have date time stamps in them that can be used to figure out which should ...
0
votes
1
answer
84
views
Cleaning up WordPress thumbnails; trying to find all thumbnails and delete them on Ubuntu 22
So, I'm trying to clean up some backups I have, and they're getting bigger and bigger because of, mainly, the number of thumbnails generated by WordPress per image. I came close to finding a solution, ...
0
votes
1
answer
65
views
$'\r': command not found error when executing find in a bash script
I wrote the following script; it's modified for simplicity and privacy reasons:
FILES_ROOT='/data/FILES'
BACK_B2B_RETURNS_S="$FILES_ROOT"'/wms-m-company/w2z/b2breturns/backup'
...
0
votes
0
answers
11
views
Exim.conf Redirect email to an another folder
I am trying to redirect/route incoming emails to another folder depending if they are listed inside the /etc/email_list file (ON/OFF). I am unsure how would I approach this, I am clearly messing ...
1
vote
1
answer
22
views
Linux, do I need if, else, or statements to accomplish automation of compiling programs from source [closed]
I am wondering what would be the best way to write a bash script to install packages from source, would it even be needed to go in depth with how to automate the task?
For example let's say I want to ...
0
votes
0
answers
25
views
Automatize using bash downloading deb files and dependencies and later extracting them to a unique folder and compress it to use in a live filesystem
I am developing a Live filesystem and need to be able to download deb files with its dependencies which I manually do using:
apt download $(apt-cache depends --recurse --no-recommends --no-suggests \
-...
0
votes
1
answer
53
views
What does lower case "g" mean in top output?
Can someone please help explain this, I have always used to interprete the "g" in top output to be size in Gigabytes even though the convention is to use uppercase "G" but now I am ...
0
votes
1
answer
57
views
Incremental backup of an entire FTP server with Linux [closed]
I'm looking for a simple way to schedule full + incremental backup of a remote FTP server (that also supports SFTP, but without SSH access) from My NAS that is based on Linux, WITH full SSH access. I'...
0
votes
1
answer
39
views
Is posible to write script that checks for differences between two patterns in configuration files
Linux. I have for example two config files.
First:
criticalexceptions => [
'yum-updatesd-helper: error',
'cups: cupsd shutdown succeeded',
'hda: drive_cmd: error',
'end_request: ...
2
votes
1
answer
199
views
How to load modules on Synology NAS on boot?
I have a Synology NAS (DSM 6.2.4) and I would like to load usbserial.ko and cp210x.ko on boot.
When I run:
sudo insmod /lib/modules/usbserial.ko
sudo insmod /lib/modules/cp210x.ko
The drivers work ...
2
votes
1
answer
125
views
Is sudo -u username command the same as doing sudo -i -u username then command?
Is a terminal prompt sudo -u username command
same as doing
sudo -i -u username then command in the next line?
If no, what is the differences? What are the use cases when doing the first is better or ...
0
votes
1
answer
71
views
Why can't ssh run rbenv in the shell?
I'm trying to run a bash script on a remote server to install ruby via rbenv.
#!/bin/bash
# ssh deploy@192.168.50.2 'bash -s' < configure.sh
echo "ruby 3.2.1"
rbenv install 3.2.1 --...
1
vote
1
answer
118
views
Redirecting stdout and stderr doesn't work with cron
I have the following cron task. Expected behavior is that every output (standard output and standard error output) of this task will be redirected to /dev/null. Unfortunately this doesn't work. Emails ...
0
votes
1
answer
321
views
openssl functions randomly returns warning: command substitution: ignored null byte in input
I try to encrypt some loads, here is a minimum working example (is RSA private key)
to_be_signed="2f93992bb1db9cab0b3b8fc2de0a2863"
#to_be_signed="7d6d2a584a227574e1c113aab56ea490&...
0
votes
0
answers
40
views
running "ssh $hostname -o ConnectTimeout=..." again and again in close time seems to disable ConnectTimeout option
I am improving a script made by third parts.
The script runs on a Ubuntu OS.
This scripts contains a loop in which about there are about 10 if statements (they involve only localhost), and each one ...
3
votes
1
answer
682
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 ...
0
votes
1
answer
30
views
searching for multiple files, but if one file is missing I want to know from the output + find
$ find ./ -name "AABE*" ## this returns nothing
$ echo $?
0
$ find ./ -name "AWGT*" ## this returns locations of were files matching the criteria
./Atempt3A/AWGT-modified.txt
....
0
votes
2
answers
39
views
Bash sed command with sed itself as replacement, quotes not outputted
I need to modify the content of a file, with the following sed command (which works fine):
sed -i 's@date.timezone.*@'"date.timezone = $TZ"'@' $PHP_INI_DIR/conf.d/symfony.ini
This line ...
0
votes
1
answer
31
views
How do I configure users on my ubuntu system without shell and execute only one command?
I need to build a Ubuntu server where users will be logged in but I dont want them to give a shell access. As soon as the user logs in one custom command will be executed and it will be allow certain ...
0
votes
1
answer
171
views
ansible print folder path from register variable
I'm trying to print just the path of a register var that has multiple values, however I can only print a specific value. how can I print multiple values?
---
- name: find directories
find:
...
0
votes
1
answer
67
views
Odd behavior of bash array
I've recently encountered a strange script behavior and still don't understand y the array behaves this way.
Here is a piece of the script:
for nCDATAReg in $(seq 1 4)
do
sTestBuffer1=$(...
0
votes
0
answers
19
views
forwarding agent via Apache http
In my web application (Apache httpd) at Centos 7, I'm making an SSH connection with forward agent
example:
ssh -A $user@$proxyIP $user@DestinationIP ls -l
if I want it to run in the terminal of ...
0
votes
0
answers
222
views
how to make a shell execute with suid
I'm trying to suid a shell and it's not working. I need help understanding why, and how to fix it...
I'm following these steps (as root)
cp /usr/bin/bash /usr/bin/bash-emergency
chmod 4755 /usr/bin/...
0
votes
3
answers
373
views
Check if IP Belongs to a CIDR
We have a list of CIDR's
1.10.10.0/24
5.154.0.0/16
5.181.219.0/24
23.90.68.0/24
31.40.214.0/24
I want to check if a IP for example : 23.90.68.56 belongs to any of the above CIDR's. If yes then we get ...
0
votes
0
answers
9
views
Is there a way to script addons for Java Dev Eclipse on Linux (specifically C++ pluggins)?
I am trying to write a deployment script via USB for computer science linux labs in academia. To deploy we are having an admin user run the script locally on each machine, each user that needs to ...
0
votes
1
answer
71
views
How can I verify if time is set correctly on server in my bash script?
I'm working on ultimate backup script for very important server. My script already:
creates a backup
verifies copied file(-s)
verifies gz archive
compares MD5 on local and remote after sending file ...
0
votes
1
answer
312
views
How to use gpg without --keyserver (which is deprecated too, just like apt-key)
The background
For some time now, apt-key warn users with deprecated messages like this one:
use of apt-key is deprecated, except for the use of apt-key del in maintainer scripts to remove existing ...
0
votes
1
answer
239
views
bash heredoc and code block
Script has to log everyting in it to output and to log file
Like this it works OK:
#!/usr/bin/env bash
some_command_1
((
echo "Some text (in parenthness too)"
echo "Another text ...
0
votes
0
answers
57
views
Bash Shell Script Executing 3 Times in /etc/profile.d within Nanoseconds apart
g'day all.. in a spot of bother and a starter of ten for someone. I have placed a simple bash shell script into the root of "/etc/profile.d" and without fail, the script executes 3 times ...
0
votes
1
answer
216
views
Bash loop through dates
I'm trying to copy data from psql via a bash script now I'm stuck with a loop my bash script is as following:
#!/bin/bash
DATEBEGIN=2016-03-01
DATEEND=2016-03-31
DATEMONTH=2016-03
echo "Copy ...
0
votes
2
answers
113
views
Unable to delete file in Centos
I can't remove certain file in Linux. Here the example:
[root@HBL01 home]# ls -ltira index.php
393591 -r--r--r-- 1 apache apache 14335 Nov 23 2021 index.php
[root@HBL01 home]# rm -rf index.php
...
0
votes
1
answer
284
views
i want to restrict all commands for user except ssh command
I am a root user and don't want that users can execute all linux command except ssh. They only have to use ssh command in their user. How to do that? please anyone help.
1
vote
1
answer
104
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 ...
1
vote
1
answer
320
views
Dump a Table from MySQL Database directly from sql server using bash
How can I dump a table from a MySQL database using a bash script?
Like we can use the below command to dump a table
mysql -u username -p database_name > file.sql
But how can I dump only a single ...
0
votes
1
answer
63
views
Fswatch observing folder for new files error from the example doc
I am trying to "listen in" on changes in a particular folder, then once a file comes in, I want to copy the file to another folder. I figured fswatch would be a great choice for this.
And as ...
0
votes
1
answer
71
views
is my crontab syntax invalid?
simple question:
10 4 * * * rm -rf ~/code/rehlds/build/ && ~/code/rehlds/build.sh --compiler=gcc --jobs=4 > /dev/null 2>&1
I checked an there is no /build folder which indicates ...
0
votes
1
answer
990
views
Bash script buildscript error. Line 20: syntax error near unexpected token 'fi'
In my bash script I'm getting an error:
./buildscriptbuild.sh: line 20: syntax error near unexpected token 'fi'
I have tested the below bash script in my local system.
Can anyone help me in this ...
0
votes
0
answers
47
views
GAWK not running in crontab
I have the below script running successfully manually. But when it is executed in crontab (below), I dont see anything happening.
Script
#!/usr/bin/gawk -f
#!/bin/bash
PATH=/usr/local/bin:/usr/bin
#...
0
votes
0
answers
7
views
Narrow Down Ubuntu Lock And Active User?
I have been trying to create a bash Script to Locked and Active ,locked User.Can anyone please guide me to narrow down locked and Active User list.tnx