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
0answers
13 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
2answers
33 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
0answers
30 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
0answers
51 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:~$ ...
0
votes
2answers
26 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
1answer
32 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 ...
0
votes
0answers
33 views

monit: check specific python script running

i'm trying to run a few different python scripts, each in its own screen. if I run something like: SCREEN -dm -S script1screen python3 script1.py how do I check with Monit if this exact script is ...
1
vote
2answers
86 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 ...
0
votes
1answer
49 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
2answers
62 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,...
1
vote
1answer
28 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
0answers
56 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
1answer
28 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 -...
0
votes
0answers
22 views

wget or curl timeout after connection established, before download begins

I need to download data from a server in batch operations. The server shows the following behaviour with approximately 30 % of the downloads: DNS works, host gets resolved. Connection gets ...
0
votes
0answers
24 views

Asynchronous jobs in Shell Script

In most languages like Python, Java, Swift we can run functions/methods asynchronously and based on the outcome be it success/failure, we can implement and run different call backs. How can we ...
0
votes
1answer
37 views

Auto select solution for zypper

I need to automate package installation with zypper that requires selecting a solution. How can this be done in non-interactive mode? # zypper in /tmp/repos-sles15-sp2-current.x86_64.rpm Loading ...
1
vote
1answer
34 views

How to connect from Ubuntu VM on Azure to another without uploading the private key

My Topology Two Ubuntu servers, the edge which is exposed to the internet, and the core which is only connected locally. Both are on the same subnet and the core only accepts SSH from the edge server. ...
0
votes
0answers
36 views

Nagios SNMPTT trap Logs issues

I had a quick question regarding the nagios snmptt trap logs. The traps arent coming through in the snmptt.log with proper date..its stuck on May 17th.. it has logs for all days till May 17.. It is ...
1
vote
0answers
19 views

How to ensure execution of time consuming task on reboot/shutdown?

I have a bash script that is supposed to execute on reboot/shutdown of a remote Ubuntu server, connected over SSH: ls /etc/rc{0,6}.d/k99* /etc/rc0.d/k99_stop_all /etc/rc6.d/k99_stop_all The script ...
0
votes
0answers
40 views

How to bring command to foreground with bash script

At work, I login to a VPN connection. This VPN does a 2fa connection that text me a code. When I put the commands on a bash script, I don't get prompted for the code. The script just sits there and ...
1
vote
1answer
41 views

grep -P negative lookahead does not work [closed]

I'm trying to find some lines on a file. I use a regular expresion and execute it with grep -P but I have an error. The expression is :[A-Za-z0-9]{6}-[A-Za-z0-9]{6}-[A-Za-z0-9]{2} =>.*@(?!gmail.com)...
0
votes
1answer
38 views

Howto start and detach screen with user environment on startup?

I want to start screen and put a couple of programs running inside on startup. I've seen many similar posts but none answered my question. so I put in rc.local following 2 lines: screen -dmS scr ...
2
votes
1answer
97 views

Anyone know of a script, program, etc… to check folder/file permissions and repair/restore?

I am not a newb. I am a professional imploring to other professionals over their discoveries of a quick solution to a common problem, and I know what chmod -R is. This is in response to the -1 rating ...
1
vote
2answers
36 views

Howto create custom service in systemd?

Running Fedora 33/34 on multiple machines. I successfully activated rc-local.service which works fine. I have couple of other scripts that I need to run in /etc/init.d/ and I created similar service ...
0
votes
1answer
55 views

Sort df Output by Mount Point

I need to get the output of df -h sorted alphabetically by its mount point in the Mounted on column. However, df -h currently outputs similar to this: $ df -h Filesystem Size Used Avail Use% ...
0
votes
0answers
17 views

strings are over-writing variables when using echo

I've currently got an IP address in a variable and I'm trying to echo that variable with some string at the end: echo $INTERFACE_IP echo ":0.0" echo "${INTERFACE_IP}:0.0" And what ...
0
votes
1answer
75 views

Command works from bash prompt; does not work from within shell script

I'm trying to use IPMITOOL to query a bunch of OOB NICs to get their MAC addresses. When I run: ipmitool -I lanplus -H 1.2.3.4 -U USER -P PASS lan print I get: MAC Address : aa:bb:cc:dd:...
1
vote
0answers
32 views

Dynamic bandwidth in Tc (Bandwidth Changes over time)

Basically I wanted to change the bandwidth after every 10 seconds using tc. So how to do that thing in tc. This is my script. !/bin/bash # # tc uses the following units when passed as a parameter. # ...
0
votes
0answers
22 views

adding timestamp to each output of the script

I used a hint provided in https://serverfault.com/a/103569/550825 to record all output from a script to a log file. Now I need to improve it by adding timestamp leading each output line. I added ...
0
votes
1answer
37 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
1answer
37 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
84 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
28 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
24 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
19 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
13 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
17 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
30 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
22 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 ...
0
votes
0answers
55 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
20 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
80 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
57 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
34 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
57 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
38 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
56 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
42 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
345 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 # ...

1
2 3 4 5
67