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
1 answer
3k views

How to set a command alias that will be respected in a shebang

I run multiple versions of PHP on my Linux server. I've added an alias in my bashrc to point the php command to a specific version alias php='/usr/bin/php7.3'. This works as expected when I execute a ...
Dom's user avatar
  • 488
1 vote
2 answers
247 views

Process filenames with spaces listed in text file

I have a list of files listed in a text file named "list.txt", like this: one file.jpg two file.jpg three file.jpg Now I want to copy all this files to another directory, and I try this: ...
Amarnasan's user avatar
  • 167
0 votes
0 answers
46 views

How to get old bash tab completion rules back - stopping before next subdirectory

Could anyone please confirm to me whether tab completion rules e.g. in Debian/Devuan/Ubuntu Linux have changed some time ago - and how (or from which debian package revision) I could quickly get the ...
flups's user avatar
  • 1
0 votes
1 answer
447 views

Bash: How to move files and directories from one directory to another?

I'm trying to write a script that moves files and (sub)directories from within one directory to another. That move operation should include not only regular files and directories but also any dot-...
Regis May's user avatar
  • 103
0 votes
1 answer
346 views

How to serve TFTP content via script (PHP-like)?

I am looking for a way to serve TFTP requests with an output from a script (bash, PHP?) called with the TFTP request path as an argument. A simple TFTP equivalent of Apache+PHP. Something like PHP + ...
Michał Sacharewicz's user avatar
0 votes
1 answer
636 views

Diff says file does not exists – why?

I transfer a file from a remote server to my local server. If this is done I do a diff to check if both files are identical to check if the transfer was successful. So I do this: ssh -o ...
user611630's user avatar
0 votes
1 answer
56 views

Variables (locally defined) not defined when running bash script from cron on MacOS

I have following script for backups creation: #!/usr/bin/env bash { declare -a directories=( "/Applications/Apache" "/Applications/Scripts" ) function ...
Radek Suski's user avatar
1 vote
1 answer
110 views

Misaligned AWK output

I have simple awk command generating output and then sending an email: awk '(NR==FNR){a[$2]=sprintf("%.2f",$1*value); next} {print $1,$2,a[$2]}' OFS="\t\t\t" value=$COST /tmp/1.txt ...
DisplayName's user avatar
2 votes
2 answers
557 views

Can't access instance after setting up iptables rules

I'm trying to setup some rules to block all ports except 21 and 22 on TCP (SSH and FTP). But when I try to run this script I get locked out of my instance and can't access it. This is the script: # ...
mj01100011's user avatar
2 votes
1 answer
385 views

ssh remote command parsing gone wrong

I am trying to execute a single remote command via ssh for debugging setup. This does not execute the correct command (I cannot see the output but it seems the PID is missing to gdbserver): ssh -t ...
Rolle's user avatar
  • 123
1 vote
0 answers
4k views

Warning: The unit file, source configuration file or drop-ins of X changed on disk. Run 'systemctl daemon-reload' to reload units

I am running Debian 10.4 on kernel 4.19.66+. It seems that my unit files are changing on their own (It sounds crazy, I know), with no interaction from me, the only user of the system. I found this ...
Brandon's user avatar
  • 11
0 votes
1 answer
194 views

Injecting ip address into command prompt

I have the following convoluted method for injecting the ip address on an ec2 instance into the command line. It works but has some obvious problems and I'm looking for a good way to solve them: TOKEN=...
StevieD's user avatar
  • 552
0 votes
2 answers
74 views

How do you detect if the file is in deferred state?

How do I know if a file or files are in deferred state using bash? Is there a way to detect this? sample: when saving a file, kernel cache the file and not yet written on the disk. this is the D state ...
camilox's user avatar
  • 23
0 votes
1 answer
279 views

Run xterm script from /etc/profile leads to "cannot load font"

I want to auto-start a shell script and therefore I added this line to my /etc/profile: /bin/su -c "/path/to/my/script" user - the script itself starts a xterm shell command and output ...
leon22's user avatar
  • 101
0 votes
1 answer
1k views

su -u www-data cat ... not working as expected

For a project I'm working on, I need the www-data user to be able to read /etc/openvpn/easy-rsa/pki/index.txt The permissions see fine for this: -rw-r-----+ 1 root www-data 1050 Dec 7 20:43 index.txt ...
Chemdream's user avatar
0 votes
1 answer
60 views

Multiply first column by variable depending on unit

I have du -sh output saved to txt file: 2.1G /home/x/sample/2GB/ 101M /home/x/sample/100MB/ ... What I want is to multiply each value in the first column by a value taken from variable ...
DisplayName's user avatar
0 votes
1 answer
185 views

type -p java does not work in a init.d script

I am trying to modify /etc/init.d/jenkins script, in order to add my custom java path. My solutions is this: JAVAPATH=$(type -p java) PATH=/bin:/usr/bin:/sbin:/usr/sbin:$JAVAPATH However, when I ...
Javier Cimas's user avatar
1 vote
1 answer
57 views

How to make Parent and children share same open file limit

When I have a parent process have a limit of 128 files i.e and I fork, the children will also have 128 files, and if that child forks we'd have another 128 totaling 384. My question is, is it possible ...
Linux Rookie's user avatar
3 votes
2 answers
1k views

equivalent for ifconfig dev 0.0.0.0

When I need to create a temporary bridge with interface on Linux I would use the following: brctl addbr br0 brctl addif br0 eth0 ifconfig eth0 0.0.0.0 ifconfig br0 192.168.10.100 netmask 255.255.255.0 ...
marshelgot's user avatar
2 votes
1 answer
627 views

Remote command has different umask

ssh user@host "umask" gives 0174 ssh user@host and the umask from server shell gives 0002 Could you please explain how can it happen? UPD: Actually, it was /etc/passwd overriding umask.
Oleksiy Svintsitskiy's user avatar
-2 votes
2 answers
1k views

Linux Bash Scripting using grep sed and cut command to display ip address with port number

Can any one please help me I need a output of "192.168.1.1#53" by using these 'grep' 'sed' and 'cut' command mandatory in linux bash scipting in given below text. ;; Query time: 29 msec ;; ...
hemanth singamala's user avatar
0 votes
3 answers
1k views

alias command that works in ssh too

I have some commands that I always use and they are rather hard to remember such as lsof -i -P -n | grep LISTEN. I would like to create an alias for them that also applies when logged in via ssh on ...
Romeo Mihalcea's user avatar
1 vote
1 answer
777 views

apachectl catch or suppress configtest's "Syntax OK"

Apache's configtest is useful to catch syntax errors. On success it prints "Syntax OK" and when running apachectl configtest in a bash script I want to suppress this. I have tried the usual ...
PeterB's user avatar
  • 628
0 votes
0 answers
2k views

Setting UMask in systemd override.conf is ignored

I'm using amavisd on fedora33 and trying to change the file permissions on the socket it creates so nagios and nrpe can read the file in the amavis group. The file permissions currently are as such: # ...
Alex Regan's user avatar
0 votes
2 answers
327 views

Bash script to create variables from and run commands on each item in an external list

On my local machine I have a text file containing a list of IP addresses and directory names. list.txt # Comment for Server 1 XXX.XX.XXX.X DIRECTORY-NAME # Comment for Server 2 XXX.XX.XXX.X DIRECTORY-...
Jay's user avatar
  • 157
0 votes
1 answer
621 views

User permission to create new File Descriptor

On CentOS 8 I have a Bash script which uses a non-standard file descriptor (/dev/fd/5) and needs to be executed by a standard user (not root). When the user executes the script it receives tee: /dev/...
Mat's user avatar
  • 1,903
0 votes
0 answers
72 views

why is the linefeed missing from each line when a directory listing is stored as a variable?

In Ubuntu 20.04, when I run this command, I get this result: On the CLI: #find /home/ftpusers/ -name '*.jpg' -type f -printf '%p %u %TY%Tm%Td%TH%TM%.2TS\n' | sort --stable --reverse --key=3,4 yields: ...
user3055756's user avatar
2 votes
2 answers
450 views

make ssh remember host's username

I connect to many servers daily. my ssh config default username is "admin" but servers comes from different environnements and username can changes. sometimes it will be "ec2-user" ...
exeral's user avatar
  • 1,872
0 votes
1 answer
105 views

BASH script variables have no values

I am writing a simple script to clean up log folders. This is the most basic thing I can think of, and yet it does not work because the variables don't seem to be set. Here is the shell script ...
Jay Imerman's user avatar
-1 votes
1 answer
930 views

Mac sed not the same as linux

I have a bash script that I have used before on Linux and it runs fine on different distros, but not on a MAC. I am trying to read a file and then delete the current line. For some reason on Mac I ...
user2236794's user avatar
0 votes
1 answer
279 views

Exclude or Include certain profile lines during a tmux session start

In my .bash_profile, I have a line to start tmux only if it is present on the system with: [ -z $TMUX ] && export TERM=xterm-256color && exec tmux In a similar vein, I would like to ...
YorSubs's user avatar
  • 135
1 vote
1 answer
171 views

Hotstrings on a bash console

I can do things like this to alias often used things alias iii='sudo yum install' and that works fine, but it's nice to be able to expand a command on the command line as I use it. For sure I can type ...
YorSubs's user avatar
  • 135
0 votes
1 answer
1k views

Stop cron jobs from sending emails as root but allow sendmail to work

I've recently got Postfix working as a send only MTA relaying through Google Workspace (formerly Google G Suite). I would now like to send emails after completed cron jobs to my personal email. The ...
willowen100's user avatar
-1 votes
1 answer
271 views

Can somebody help me on how to zip these individual log files within while loop

I am able to break o/p of a big logfile (filename.log) into individual log files of 1 min each (filename.log.140108) using while loop, but I want these files to be saved as zip files due to capacity ...
Nakul's user avatar
  • 1
0 votes
0 answers
99 views

Use chown every time a script is executed

I am running a bash script as a root user for all of my sftp users. This script creates some files and then move it to a destination folder (DestFolder) for each user. Now, I use chown at the end to ...
ssavva05's user avatar
0 votes
0 answers
169 views

find orphan veths on ubuntu 20.04

i use a system that adds ips, netns and veth's via script and deletes them if no longer needed. I was using centos 7 but i decided to switch to ubunutu. it seems that on ubuntu orphanded veths are not ...
Kjellson's user avatar
0 votes
1 answer
1k views

How to exclude rules in modsecurity corerule set for url encoding

The question is simple due to some specific need i want my apache mod_security with latest core rule set v3.3.0 to allow ../ in url encoded form i.e it should not block ..%2f in the request, and it ...
Avi gupta's user avatar
0 votes
1 answer
2k views

Is it a good practice to create a folder in /?

I'm currently working on a project where some install script of some other teams are creating a lot of files/scripts and others various stuff in a folder located in /. eg: /installfolder Is that ...
Tolsadus's user avatar
  • 1,193
0 votes
1 answer
12k views

Installed python script warns not on PATH

I have installed a script using pip, after installing the script returned the following error: WARNING: The script testapp is installed in '/home/pi/.local/bin' which is not on PATH. Consider ...
Imran's user avatar
  • 129
1 vote
1 answer
305 views

Ansible vs. custom made solution

I have a pool of around a dozen workstations running Linux and I need a system to somehow keep them in sync (same software installed, same configuration, same users, ...) and also allow me to evolve ...
Liviu's user avatar
  • 13
1 vote
3 answers
2k views

SSH from A through B to C, using IdentityFile on A

I've see some similar questions but without a clear way forward, if this was already answered before please close this one. My scenario is: Host C is not accessible from A. Host B is accessible from ...
João Loureiro's user avatar
0 votes
1 answer
61 views

how to parse some mails from html code [closed]

I want to build a little bash script to detect some mails in a HTML-code. currently, I am not sure how can I build the right regex to auto-detect emails from HTML. I tried this regex with curl: egrep -...
cyno's user avatar
  • 3
0 votes
2 answers
204 views

Bash script with output

I have a server that needs to send daily some files to remote machines. I have done this script in order to automate this task. What I need to insert on this script in order to see if this task as ...
plopes's user avatar
  • 11
-1 votes
1 answer
64 views

How to rename multiple files by adding word from that file?

I have files : file name: report_2020-10-13-17-11.txt Contain : ... this report was prepared by=John ... file name: report_2020-10-13-17-12.txt Contain : ... this report was prepared by=Doe ... ...
Mayang Sari's user avatar
0 votes
1 answer
338 views

Adding newuser in Dockerfile

I have the following dockerfile set up, where i am creating a newuser instead of using the root user. USER root RUN microdnf --setopt=tsflags=nodocs install -y nginx procps shadow-utils net-tools ca-...
M B's user avatar
  • 111
1 vote
0 answers
7k views

Running nginx as a non-root user on Dockerfile

I have created the following Dockerfile to use a non-root user for my Nginx service. However, when I ran the docker image that I have created and look at my docker logs i get the following error. 2020-...
M B's user avatar
  • 111
0 votes
1 answer
634 views

CentOS: convert HTML `<br>` tags to bash `\n\r` on the fly?

this is a tough question to pose and i'm not entirely sure this is the right place for it, but my question is this: how can i convert <br> tags to \n\r characters on the fly when running a PHP ...
WhiteRau's user avatar
  • 107
-2 votes
1 answer
311 views

new user does not recognize command `code`

I have Windows Terminal running bash in Ubuntu and had been working under root by default. I had isntalled the Remote wsl extension and successfuly opened vs code with code . on several occasions. ...
Matan's user avatar
  • 3
0 votes
0 answers
178 views

on expect: need to spawn a python script that fetches a string and send it back

The first script is basically an external lib that I don't want to tamper with. I already tried the following: set timeout 100 spawn python long-running-script-with-prompt.py expect "Type the 6 ...
Julian Dm's user avatar
  • 101
2 votes
0 answers
3k views

Apache 2.4 environment variables in config

Ok, so I'm building a docker image for apache. I want to allow users to specify custom apache config with the environment variable. TL;DR The question could be simplified to this: how to use ...
pavel.sheiman's user avatar

1
5 6
7
8 9
72