Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [shell]

A shell is terminology for a command-line interpreter most commonly used with Unix-like operating systems, but also used to interact with GUI-based operating systems in a more granular fashion. Not only does it allows the user to run programs from a text interface, but frequently offers basic programming features such as variables, substitution, output redirection, and wildcards.

Filter by
Sorted by
Tagged with
0 votes
0 answers
5 views

How to execute remote commands on linux and update return value?

As part of automation in gitlab ci. I am running a terraform template and creating a linux machine. After that, I need to run few commands on the remote machine. I am running those using the ssh ...
user avatar
0 votes
0 answers
16 views

How to preserve file access time when using `chmod`

I would like to know how can I preserve file access time ("atime") when using "chmod". Sometimes I need to use the code below: chmod -R 777 /directory It works fine, however all ...
user avatar
0 votes
1 answer
20 views

trying to generate ssh keys of the vm but getting the error option requires an argument -- P

I have executed the below command manually in the vm and i am able to generate the ssh keys but when i tried using the same script in the automation pipeline from github actions i am getting the error ...
user avatar
0 votes
2 answers
36 views

How to get the email I entered on Proxmox VE setup in the shell?

When I login to my Proxmox VE7 host, I'd like to get the email that I entered when I set up Proxmox on installation. Is it possible? The idea is to automate certbot initialization non-interactively ...
user avatar
-4 votes
2 answers
106 views

Shortcut for: | less [ENTER]

I often type | less [ENTER]. I would like to optimize this. Environment: Ubuntu 20.04 This needs to work for terminals running in the browser, too. Any idea how I could enter above string with less ...
user avatar
  • 2,914
0 votes
1 answer
34 views

Variables on set-hostname and mv command in shell script

I have the below script in Shell: read n for ((i=1;i<=$n;i++)) do echo "Connecting to $publicip" ssh -i ./key.txt root@$publicip 'hostnamectl set-hostname autotest$i.domain.com && ...
user avatar
0 votes
0 answers
31 views

Strange record in /etc/shadow after useradd -p and crypt function in bash script

Ubuntu 20.04 LTS. There is a simple bash script to add a new user via command line in interactive mode: #!/bin/bash # Script to add a user to Linux system if [ "$(id -u)" -eq 0 ]; then ...
user avatar
  • 1
0 votes
1 answer
31 views

export new env params without outputting to terminal

I'm trying to run a script and bash export is outputting text when I don't want it to because it's breaking up the output. I need to run a script which extracts some information and then inserts it ...
user avatar
0 votes
1 answer
74 views

Run commands that run in a shell as a script

Running the following commands in a shell runs without issues: ssh user@machine systemctl status my-service.service ssh user@machine sudo systemctl stop my-service.service scp -r ./my-service/* user@...
user avatar
0 votes
1 answer
25 views

How monitor open files and kill its PID by shell script?

My system gets me an error that saying 'Too many open files'. I investigated this error and turned out that /usr/bin/uwsgi created sockets(?) more than 1020. If it creates more than 1020, I guess, the ...
user avatar
-3 votes
1 answer
35 views

Nested directories file restore

I recently took backup of one of my server's drive on AWS using one of the software and now at the time of restoring it i found out it took too long to restore as its having billions of files to ...
user avatar
  • 39
0 votes
1 answer
47 views

Automating GDB memory dumps [closed]

I'm trying to dump memory from a process on my Linux machine using GDB, but I'm trying to automate this using a script. So far I've been using the following commands (example): $ gdb --pid [pid] (gdb) ...
user avatar
0 votes
1 answer
41 views

finding docker images with tag and name

when I do docker images I have below docker images as list where there are images with multiple tag and also image with latest tag value. REPOSITORY TAG ...
user avatar
  • 172
0 votes
0 answers
26 views

How can I get my shell to not tell me every time a job starts or stops?

I often run programs in parallel via the shell. generate_some_info (){ if [ $i -eq 4 ]; then echo "Here is some useful info." ; fi if [ $i -eq 7 ]; then ls --errorx; fi } for i in {...
user avatar
  • 111
0 votes
0 answers
35 views

How to duplicate iStat Menus memory usage from a shell?

I'm using MacOS 11.6. I've written a small cron job that measures memory usage of a process and, if that usage exceeds a threshold, pops up a notification on screen. (The point is to remind me when a ...
user avatar
  • 205
0 votes
1 answer
147 views

Postfix After-Queue Content Filter full example

i'm trying the Simple content filter example: i followed the steps mentioned here http://www.postfix.org/FILTER_README.html#simple_filter but in line 24 of the content filter that can be a simple ...
user avatar
0 votes
0 answers
39 views

Why does zsh behave differently when executed inside tmux?

I have zsh configured to browse command history with prefix search. For example when I type ssh and press ↑, only my last ssh commands are being displayed. However, when I use zsh within tmux session, ...
user avatar
  • 103
0 votes
1 answer
1k views

Not able to access groovy variable inside shell script in JenkinsFile

def NAMESPACE = "Dev" def BODY= sh( script:'''body=$(cat <<-EOF { "name": "${NAMESPACE}", "type": "regularwebapp" } EOF ) (echo $body)''...
user avatar
  • 1
1 vote
1 answer
38 views

Linux cp specific files from a text list of files to subdirectories from a text list too?

I ask for your help to solve my problem because I am stuck. I explain the situation to you: I want to copy files whose path I have on a txt file in specific subdirectories specified in a second file (...
user avatar
1 vote
2 answers
1k views

Why does `ps -x | grep foo` include the grep command?

I know that it does (often) include the grep process and I know adding | grep -v grep or grepping on [f]oo instead will prevent it, but my question is more about order of operations I guess. For ...
user avatar
  • 113
0 votes
2 answers
61 views

Default solutions for very limited remote linux shells

I have a user that needs to connect to a remote machine M (via ssh) and run one in a fixed set of commands (say N in total). These commands rely on python, libraries thereof, and privileged access to ...
user avatar
  • 103
0 votes
1 answer
38 views

How to know in my network which computers have the local administrator account active

As the title says: How do I know in my network which computers have the local administrator account active? Because, as per security consultant request, we have to know, and if possible, disable, ...
user avatar
0 votes
0 answers
24 views

is there any representation for search in ansible.buildin.replace ... /string/ s/toreplace/newstring/g

im wondering if there is no representation for the sed string sed -i -E '/searchString/ s/toreplace/newstring/g' file in ansible.buildin.replace to replace only the 'toreplace' string in lines which ...
user avatar
  • 1
0 votes
0 answers
15 views

Unable to get Compliant state for OS policy assignment on GCP console

I created a RHEL7 VM and a OS Policy assignment with a simple config. Here is the YAML I'm using to validate. Below is the same shell script used in yaml for reference: export num=$(stat --format '%a' ...
user avatar
0 votes
0 answers
23 views

Monit restart service output

I used to restart my services via init.d scripts on my debian servers. I moved to Monit to restart the services but now I don't have the output of the script when restarted. Basically, when the ...
user avatar
  • 91
0 votes
1 answer
81 views

CGroup not mounted on Fedora 34

I have freshly provisioned Linode instance with Fedora 34. The only thing I have installed on it is libcgroup. cgconfig service is starting properly and there are no errors but the subsystem is not ...
user avatar
0 votes
0 answers
144 views

Shell Scripting - Multiple Process ID's instead of one

I'm writing a simple bash script to shutdown tomcat, and if it doesn't stop gracefully then check if the tomcat's PID still exists and kill it. I pass the tomcat name as a variable to the script as ...
user avatar
  • 1
1 vote
2 answers
317 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 ...
user avatar
  • 13
0 votes
1 answer
299 views

Fastest way to copy files locally in linux

So for performance reasons I decided to move 2TB of small files, randomly written during some time - from a 14TB SATA HDD to a 4TB m.2 NVME SSD, both locally attached. I've been struggling for 2 days ...
user avatar
  • 255
0 votes
0 answers
118 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 ...
user avatar
  • 123
1 vote
1 answer
68 views

How can I create aliases upon connection to a remote machine via ssh?

I frequently connect to ephemeral servers. I'd like to be able to set up some commonly-used aliases on those servers upon connection to them. I thought maybe I could create a bash function/alias ...
user avatar
0 votes
0 answers
25 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 ...
user avatar
0 votes
1 answer
189 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:...
user avatar
  • 3,207
0 votes
1 answer
160 views

Download with Wget only if new version

Good morning, I have a custom software that updates with a custom script.sh. Part of the file goes something like this: if [[ $software == A ]] then echo "downloading package..." ...
user avatar
1 vote
2 answers
2k 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 # ...
user avatar
  • 43
0 votes
1 answer
100 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 ...
user avatar
  • 198
0 votes
0 answers
30 views

Copying files from remote, limited to 1k Lines and with compression

I want to fetch files from several remote machines. I want only files that match a specific regex and I want to keep the directory structure. Considerations: The files I want to fetch are plain text ...
user avatar
1 vote
1 answer
98 views

Windows 10 non-server edition Remote Shell

There a are two computers connected to the local network managed under organization domain. There are simple task list must be implemented on any machine. I want to abstract away that machine list to ...
user avatar
1 vote
0 answers
44 views

Iptables list is printed different to actual ruleset

I encountered something strange, when I run iptables --list-rules: -A INPUT -s 172.29.0.2/32 -j ACCEPT But the table prints something different to this, iptables -L: Chain INPUT (policy DROP) target ...
user avatar
0 votes
0 answers
43 views

Cannot run bash script via php possible permissions

I have ffmpeg installed on a CentOS 7 machine running a standard LAMP stack. I can run ffmpeg fine by itself in a terminal, like so: ffmpeg -i "rtsp://admin:password@10.0.0.152/play2.sdp" ...
user avatar
  • 1
1 vote
1 answer
2k views

Rsync over ssh into a Docker mounted volume

I would like to make a rsync backup of a Docker volume on a remote host. This method should have the following advantages: rsync files with user and owner permissions that are not granted to the ...
user avatar
0 votes
1 answer
257 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 ...
user avatar
0 votes
1 answer
39 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 ...
user avatar
0 votes
1 answer
114 views

Linux shell: Pipe stderr and stdout to one file AND to individual files at the same time (using tee?)

I would like to form a pipe-stream that captures stdout to one file and stderr to another file AND both in a third file (so also the complete terminal output is in one file) somehow like this: process ...
user avatar
1 vote
0 answers
504 views

How to check PCI type and version of free PCI slot in Linux shell

I know how to check how many PCI slots are not used yet on my server, by using dmidecode and looking for Available slots: # dmidecode [...] Handle 0x0014, DMI type 9, 13 bytes System Slot Information ...
user avatar
0 votes
0 answers
111 views

Updating IP in FreeDNS eg. in 5 seconds instead of an hour via script

Like the title says. At freedns.afraid.org website interface I can set the TTL if I'm premium. But how can I set it to 5s instead of the default 1h using/extending this script: #!/bin/sh #FreeDNS ...
user avatar
  • 1
0 votes
1 answer
139 views

ping script - host down vs host not on network

I have the following script where I am trying to differentiate between a server that is down and a server that is no longer on the network. If I use the ping command on the command line on a server ...
user avatar
0 votes
1 answer
108 views

How can I lock down an SSH and/or telnet user to only run a custom shell and no other commands or programs?

I asked this question on stack overflow, but I thought it might be more appropriate here on serverfault, because it has to do with system administration and security. I am looking to prototype a ...
user avatar
0 votes
0 answers
85 views

How to configure PATH in cron, so that it will be set for all crons?

I have a problem where scripts called by cron have very short, safe, path: /usr/bin:/bin I know, that I can: Change scripts to use better path in user crontab add PATH=... configuration But I'd like ...
user avatar
  • 405
2 votes
3 answers
4k views

Using if else statement inside shell module in ansible playbook

I am trying to run if else statement inside shell module in ansible playbook but looks like my else statement is not executing in any case. - name: verify application/database processes are not ...
user avatar

1
2 3 4 5
27