Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [bash]

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

0
votes
2answers
18 views

AWK, cut or ced…double parsing mail log to get authentication failures

I would like to parse mail log files, which originally look like this: 2018-10-23 23:27:51,026 INFO [ImapServer-4] [ip=10.10.11.50;oip=168.232.24.2;via=10.10.11.50(nginx/1.7.1);ua=Zimbra/8.8....
0
votes
0answers
13 views

How to query custom installed rpm package

Generally, if I need to query an rpm based package I use following commands: rpm -qi package rpm -ql package # to get installed binaries of package rpm -qf path to binary # to get related package ...
-1
votes
1answer
21 views

Can't login after installing with, playing with, and uninstalling zsh

The really bad news here (I think) is that I use the root account to log in to my Centos 7 box. The other day I saw an article about zsh, and installed it out of curiosity. Today I decided it's ...
0
votes
0answers
14 views

How can you add bash script in custom iso & after iso installation with pxe boot that script can used as start-up script?

I have created a automated VM with virt-install & install automated centos 7 on it with pxe network boot.. I want to run a bash script on this VM after reboot of centos 7 installation. How can ...
0
votes
1answer
20 views

~/.bashrc is NOT sourced on ssh 'command'

At the end of .bashrc I added: touch /tmp/bash_noninteractive_test Run: /usr/bin/ssh -v -C root@example.com 'ls' On the host (logged in interactively before): % ls -l /tmp/...
0
votes
1answer
23 views

.bash_profile not read over parallel ssh connection (hss)

I'm using hss (https://github.com/six-ddc/hss) to connect to 3 Ubuntu servers (the same edition). The problem is on 2 of them ~/.bash_profile is not read over hss, even though it is being read when I ...
-5
votes
0answers
38 views

How to find any entries that have no password from /etc/shadow as a user? [on hold]

need to find out no password entries without root access.
1
vote
1answer
21 views

write/wall message to users with color

Is it possible to send messages to other users (i.e. via the wall and/or write commands), with colors in the message? I have a shutdown script that kicks other users off of a shared file server, and I ...
-1
votes
0answers
16 views

VPS on Linux: why the need to use text shell [duplicate]

I'm new to Linux and VPSs. I'm reading tutorials on how to set up your own VPS after buying it from a hoster and each seems to focus on the shell commands. But why doesn't Linux have a GUI, like ...
-4
votes
0answers
16 views

extract, cut, process strings in a bash script [closed]

I have basically 4 txt files with records such as FILE 1 localhost_access_2018-07-19.tar.gz:13 localhost_access_2018-07-20.tar.gz:17 localhost_access_2018-07-21.tar.gz:12 localhost_access_2018-07-...
0
votes
2answers
30 views

how to filter with grep for hours?

I have the following log file, I want to cut the file with a grep but I only list the content that occurs from hours 7 to 19. Oct 11 05:26:56 cuervo sshd[983]: Server listening on :: port 22. Oct ...
0
votes
0answers
11 views

Is there a command or script which can pull out list of binaries and lib's installed using make and rpm separately [closed]

Is there a command or script which can pull out list of binaries and lib's installed using make and rpm separately For example let us consider I have 5 packages installed using rpm and 5 packages ...
1
vote
3answers
61 views

How to compress spaces in bash command output?

I work on a small screen and I'm trying to make the output of this command shorter, but I cannot get it to work. Command: docker container ls --all Output (too wide!): CONTAINER ID IMAGE ...
0
votes
1answer
23 views

Is it possible to whitelist a domain and all subdomains in IPTABLES?

#!/bin/bash IPT="/sbin/iptables" Using a drop all policy for IPTABLES echo "Set default policy to 'DROP'" $IPT -P INPUT DROP $IPT -P FORWARD DROP $IPT -P OUTPUT DROP Trying to define specific ...
1
vote
2answers
62 views

SSH from A through B to C, using private key on A

These is my scenario: Host C is not accessible from A. Host B is accessible from A. Host C is accessible from B. Both B and C have ~/.ssh/id_rsa.pub (from A) in authorized_keys B does not have the ...
0
votes
0answers
16 views

Find and cp whilst preserving modified date on files and folders

Morning all, I have this script that will find all files from the last 7 days and transfer them to a different location. I need it to maintain the modified date for the files and folder, currently ...
0
votes
1answer
26 views

Grepping 'nginx -t' for a result

Strangely enough this wont work for me. nginx -t | grep -c 'successful' | awk '{if ($0==0) print "not found"; else if ($0>0) print "found"}' It returns a not found even though the result is as ...
0
votes
2answers
37 views

Bash function doesn't work for remote ssh command execution although interactive shell function fine

I define a function in .bash_aliases file and include it in my .bashrc file. My .bash_aliases file: function dmidecode() { if [[ $1 == -t && $2 == 1 ]]; then cat ~/...
0
votes
1answer
15 views

SSH tunneling and running commands inside Docker image

I'm pretty new to Docker and have a docker image, I need to do following: perform SSH tunneling to three different addresses from inside the docker image that to the outside. Then, I need to run a ...
0
votes
1answer
54 views

How to execute 2 scripts on a server via ssh by chaining them and within only a single connection? [closed]

I have these 2 commands that I send to my server: - cat ./script1.sh var1 var2 | ssh my_user@my_server.com - cat ./script2.sh var3 var4 | ssh my_user@my_server.com This is a part of Gitlab CI, but ...
0
votes
1answer
33 views

How to simulate pressing Enter? [closed]

I have this in my bash script: ENV_VAR1=123 nohup my_app & When I run, it prints this $ nohup: appending output to 'nohup.out' # <here is a new line> and expects me to press Enter so ...
-2
votes
2answers
51 views

“kill -9 …” throws a warning when it's run from a script [closed]

In my script I have this: #!/bin/bash kill -9 $(ps aux | grep '[m]y_app' | awk '{print $2}') sleep 3 ENV_VAR=val123 nohup my_app & Why does it print this: kill: usage: kill [-s sigspec | -n ...
0
votes
0answers
25 views

“bash: cannot set terminal process group : Inappropriate ioctl for device” when opening an ssh session

Server is running Raspbian stretch, I am conncting from a Windows station. When I try to start a bash shell: C:>ssh myuserid@192.168.1.11 sudo /bin/bash -i I get: myuserid@192.168.1.11's password: ...
1
vote
1answer
41 views

Find the source of a *nix process?

I have a dev and QA web server running on the same EC2. I've created a shell script (which is called via Cron) to check to see if a process is running and if not, restart it. Shell script: #!/bin/...
0
votes
3answers
82 views

Allowing SSH To use ssh-agent in bash script

I am working on recon for a set of systems my company is taking over and they use a different authentication method than we do. Specifically we use AD auth and a jump server to access systems where ...
1
vote
1answer
42 views

Replacing root filesystem with EC2 snapshot

This documentation describes "Restoring an Amazon EBS Volume from a Snapshot". Having done that this documentation explains "Making an Amazon EBS Volume Available for Use on Linux" What I'd now ...
0
votes
1answer
28 views

Using sed to remove "(double-quotes) on code lines while leaving them on real comments in a vimrc [closed]

I'm finally learning how to use sed to edit configs while installing Ubuntu(Server/Desktop). After much gnashing of teeth and searching about for the proper syntax to not remove the "(comment double-...
-1
votes
1answer
50 views

Run commands in fish from bash script?

I have a rather long bash script for setting up a server cluster. I'd like to start switching over to fish interpreter but I'd like to do it in steps. Can I keep my bash script as is and add the fish ...
0
votes
1answer
35 views

get process id of openvpn client in bash script

In a bash script I am starting openvpn as a client like this: #!/bin/bash conf_file=/etc/openvpn/blahblah.conf openvpn_pid_file="/var/run/openvpn-client/ovpnc.pid" command_line="/usr/bin/openvpn --...
0
votes
0answers
35 views

inotifywait endless loop after system startup

I have a service to check if a src.ods file was changed. When the system is rebooted, it keeps looping. When I update the file it starts to behave correctly (restarts only at file change). How to ...
0
votes
1answer
22 views

How to exact match exact file extension .en.html with regular expression or other way in bash script

I am trying to match file name which ends with exactly .en.html using regex like .en.html$ For it works example z_.en.html but does not work with a.len.html - it matches with .len.html Any help?
2
votes
1answer
94 views

Ctrl+C no longer working to get a new blank line in bash

I have been using Ctrl+C on most terminals to easily cancel the line I was writing and open the way for a new line. (I'm not talking about killing a running bash script, but just opening a new blank ...
1
vote
2answers
106 views

Bash script as use shell not working with SSH

I'm trying to use a specific bash script as a user shell. So that if the user logs in, the script will be executed. I've created the script and placed it into the home directory for the specific user....
0
votes
1answer
38 views

TFS Run Shell doesn't work: Not found bash: null

Im trying to run a bash script in the Release in TFS 2015. For these im using the "Shell Script" - Job. Content: #!/bin/bash echo "Start SSH" ssh user@ip << EOF echo "Unzip" unzip -o -...
-3
votes
1answer
37 views

Show the command before execution and execute only after enter

Often I copy paste command from text editor to shell. Is there any way to show the command(after pasting) and to execute only after pressing enter. This way I can see the command first before ...
0
votes
1answer
158 views

: arguments must be process or job IDs

I want to run a simple bash script (referred as killprocess.sh below) to kill a particular process/service running in particular port (say 8080) in a remote machine where both are having OS Ubuntu 18....
0
votes
2answers
59 views

How to start a blocking process (server) and then curl it from the same script?

I am trying to operate DeepDetect (a machine learning server) in Docker [note this is not a DeepDetect question - it is simply a Bash question]. However, I am running into a more general Linux/bash ...
0
votes
1answer
56 views

dump all routes of all tables with iproute2

I want to save all routes of all routing tables. I have this script: #!/bin/bash DUMP=dump.log for i in `seq 0 255`; do routes="`ip route show table ${i}`" if [ ! -z "${routes}" ];then ...
0
votes
2answers
23 views

How do I change the date in Google Cloud Container-Optimized OS?

I try to set date: sudo date -s "28 OCT 2018 15:00:00" but before I need to disable NTP timedatectl set-ntp false Google Cloud Container-Optimized OS doesn't have timedatectl util -bash: ...
0
votes
0answers
64 views

Dante Socks Multiple instances

I have correctly installed Dante on Ubuntu server as a proxy, and it works, but I must have e multiple instances of it (each of them has to works in different port). I have tried it in this way: ...
0
votes
1answer
33 views

Bash SFTP Script - Too many login attempts looks like a DOS attack

I've managed to write a bash script, based on someone's previous work, to send out files via SFTP to a Limoma GoAnywhere application. I'm not fluent in bash or shell. Unfortunately, the GoAnywhere ...
0
votes
1answer
50 views

Issue to get Cookie: JSESSIONID and auth_cookie

I wanted to execute one API using the command line but need to pass Cookie: JSESSIONID=<>; auth_cookie=<> value while executing it. We have CAS authentication for the target API. Please let me ...
2
votes
3answers
93 views

Systemd: Tell if script was run by systemd or by user

How can I tell if a script was called from systemd or from a user? I created a service for an old school daemon. We just switched to systemd and some of my admin like to call the rc-script directly. ...
0
votes
0answers
14 views

Backup upgradable packages with dpkg-repack on debian

I want to list upgradable packages and automatically repack them to .debs. My try: fakeroot -u dpkg-repack `apt list --upgradable | cut -f1 -d"/" | awk '{if(NR>2)print}'` So it gets package names,...
0
votes
1answer
74 views

Get IPv6 route for VM

is there any option to get something like this for IPv6 (inet6 or -6): ip route get 8.8.8.8 Result: 8.8.8.8 via 94.**.***.1 dev ens3 src 94.**.**.112 uid 0 cache Where I can get the local IPv6 ...
3
votes
2answers
61 views

Upgrading a MySQL database using numbered scripts compared to a version field [closed]

I have been given a task to upgrade a MySQL 5.7 DB using a directory of sequenced scripts and comparing them to a version field in a DB. You should query the DB, then compare the returned table ...
0
votes
1answer
50 views

Defining array in shell script

I am trying to define array in my shell script which would have content like below cassandra_hosts=(cassandra1.test-dev.local cassandra2.test-dev.local cassandra3.test-dev.local) But it doesn't let ...
-1
votes
1answer
56 views

When someone gains remote access to a server are there other ways to execute system commands other than the bash shell?

I am hardening a server and attempting to build a restrictive layer to a potential hacker even with root access to the server to do harm. If a user gains root or user access to the shell via say ...
0
votes
0answers
213 views

Ubuntu 18.04 cron.hourly script not running

I have a script in /etc/cron.hourly that I want to run. The script is something like this: #!/bin/sh -e echo "Doing something" eval $(do_something) exec >> /tmp/log 2>&1 and $ ls /etc/...
0
votes
0answers
29 views

How to get Linux commands history in Splunk without Splunk Forwarder?

We have tons of Linux machines which are all connected to Active Directory (AD). AD logs are being pulled in Splunk. Is there a way to get the command history of all Linux machines in Splunk from AD ...