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.

176 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5 votes
1 answer
3k 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 ...
elsni's user avatar
  • 455
4 votes
1 answer
1k views

Echo something before SSH prompt with pam_exec

I want to echo some text from a pam_exec script after a successful SSH login (pubkey) but before the script itself exits (2FA purposes). Whatever the script prints during its execution is displayed ...
Riccardo Salve's user avatar
4 votes
1 answer
4k views

Systemd service: Failed to issue method call: Unit service failed

I am trying to make a custom service in my VPS. However, it doesn't let me to run it. It says the following. I am not sure what is going on but when I run it on my Ubuntu laptop, it works properly. ...
kobbycoder's user avatar
3 votes
0 answers
619 views

Reset root shell back to /bin/bash in suse 11

In my production server which is running SUse 11 SP1, the root shell is set to /bin/eksh. Not sure how come it is set to this..we are using /bin/bash as root's default shell. I tried to reset it like ...
Amit Jha's user avatar
3 votes
1 answer
793 views

reconstructing shell session from a typescript

There is a bunch of tools like 'script', 'screen', 'ttyrec' which allow record content of shell sessions. By design these tool records everything displayed on pty, including control characters. ...
abb's user avatar
  • 131
3 votes
5 answers
5k views

Search and delete lines matching a pattern along with comments in previous line if any

I have a requirement to write a shell script in csh to search and delete lines matching a pattern along with comments in previous line if any. For example if my file has the following lines Shell ...
user avatar
2 votes
1 answer
8k views

How to create .env multiline variable

The title may be a bit confusing, so a little explanation. I need to configure an application by passing a PKCS1 PEM encoded key using environment variable. The App is configured using a .env file ...
Krystian's user avatar
  • 306
2 votes
1 answer
6k 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)''...
Sidd's user avatar
  • 21
2 votes
1 answer
504 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 ...
user611005's user avatar
2 votes
0 answers
166 views

How to auto init direnv on Google Cloud Shell?

my .bashrc has these lines at the bottom: if [ -f $HOME/tools/bashrc ]; then source $HOME/tools/bashrc fi and $HOME/tools/bashrc has this code at the bottom: eval "$(pyenv init -)" pyenv ...
Noel Pure's user avatar
  • 121
2 votes
1 answer
19k views

How to manually setup network connection from Busybox shell (ash)?

An embedded device running Linux version 2.6.26.5, ARM Linux Kernel. Busybox v1.10.2 shell (ash), I'm in Busybox shell. I want to set up connection between embedded device and computer. Is it ...
minto's user avatar
  • 121
2 votes
0 answers
61 views

wrapper command to record network use of a command

Is there any command like time that can record a process's network I/O stats and print them on exit? Linux (and other *nix) has the time command that lets you record execution times - not just wall-...
Craig Ringer's user avatar
  • 11.2k
2 votes
0 answers
2k views

Restart ffmpeg process streaming rtmp video if it fails using shell script

We use ffmpeg to forward streams live. Often due to unknown reasons or due to the stream stopping temporarily the command stops running in the background. What's the best way to monitor and continue ...
Ben's user avatar
  • 121
2 votes
0 answers
487 views

ForceCommand vs Subsystem

Is there any particula reason why I should use ForceCommand internal-sftp instead of Subsystem sftp iternal-sftp and disabling the shell?
meso_2600's user avatar
  • 121
2 votes
0 answers
907 views

Bash and background processes PGID and receiving signals

My actual problem is that a process I run in an rcfile in docker as docker run container bash --rcfile rcfile remains attached to the bash session by sharing the PGID which means that when I Ctrl-C an ...
Arkaitz Jimenez's user avatar
2 votes
1 answer
2k views

Shell script won't run ruby script file

My shell script (my_shell.sh) won't run the ruby script (ruby_script_1.rb) in it. my_shell.sh: #!/bin/sh # Invoke the ruby script here ./ruby_script_1.rb It could not find where the ./...
user1972031's user avatar
2 votes
1 answer
81 views

Inspecting how $PATH gets created

Is it possible to "listen" to a variable's value during the start of a new shell? I have a script that checks for the $PATH variable in the typical places, but I'd like to try something different. ...
brock's user avatar
  • 123
2 votes
0 answers
2k views

EC2 - editing .bashrc causes terminal to hang and checks to fail

I've been testing this for the past few hours with no luck. When launching an Ubuntu 12.04 EC2 micro instance, I SSH to it, create a new user and continue with installing Ruby version manger under ...
dcd0181's user avatar
  • 121
2 votes
2 answers
164 views

Are passwords sent via a bash script retrievable?

As part of running a backup script for a linux server, I have commands like mysqldump within a bash script which contain the mysql root password, and certain ftp server passwords. Are these ...
Joel G Mathew's user avatar
2 votes
2 answers
3k views

Iptables prerouting and IP forwarding

I have a linux machine used as gateway for a Win XP machine. Both are in Virtual machine for testing purpose. Now I want to trick the Win XP user (me) with the forwarding of an IP address: I want to ...
Possa's user avatar
  • 185
1 vote
0 answers
119 views

unable to send response in expect command

I'm running below command and I'm also sending response using send but its not taking any input. kindly tell me where I'm missing? #!/usr/bin/expect -f set server_ip "<server?" spawn ...
Sreekanth Chityala's user avatar
1 vote
1 answer
790 views

Windows Feature Update Silent Install

We are trying to push out the latest Windows Feature update via our RMM but when running it doesn't appear to do anything. We've tried running the following: PowerShell Start-Process -FilePath "...
Ronald Simmons Jr's user avatar
1 vote
1 answer
623 views

'mail' not working in Script same way it is working from command line

The below line of code/command is working as expected if I run it from Unix terminal, but not if I include it in a script and run the script - exact same. I am expecting the X-Priority to show the ...
akpuvvada's user avatar
1 vote
0 answers
46 views

How can I install application as root and start and stop it as non root?

I have a script which will install mysql server, java and then my java application. I want to create a test user and group testg, the application will start and stop by non-root user (here test user) ...
user15566016's user avatar
1 vote
0 answers
137 views

Given a command whose STDOUT prints to several lines, how might I format each of them (e.g. prepend a string, change a color, etc.)

Okay, so, contrived example here, but it's the simplest instance I could come up with the produces the conditions I'm trying to alter. I'm trying to run a black-boxed command and alter the multi-line ...
NerdyDeeds's user avatar
1 vote
1 answer
410 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:...
Driftpeasant's user avatar
  • 3,238
1 vote
0 answers
74 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 ...
user13581602's user avatar
1 vote
0 answers
251 views

debugging zsh completion method

I am trying to debug a completion method. This method is supposed to present with all the directories within these three folders. I verified that compinit is loading it correctly. tried tracing and ...
scphantm's user avatar
  • 203
1 vote
0 answers
395 views

How to find out what causes user shell to be changed to /bin/false

I have the case when one of my users are getting login disabled automatically. I was trying to find out what is causing this. Found that rkhunter app was monitoring changes in /etc/passwd and ...
Misha Medgitov's user avatar
1 vote
1 answer
87 views

For a Mac OS user, is there a way to configure the shell to refuse any input whatsoever, beyond an SSH connection?

I am reasonably familiar with the implementation of SSH tunnelling (forward and reverse) for the purpose of creating a secure conduit by which insecure protocols (eg: VNC) can be carried. On Mac OS, I ...
Zirynx's user avatar
  • 11
1 vote
0 answers
318 views

Script command on alpine

I want to preserve colors of docker exec command. The only way I found is to use script command like so docker exec <container_name> script -q -c "./spiral migrate:status" /dev/null The ...
ogbofjnr's user avatar
  • 183
1 vote
1 answer
625 views

script to attach screen and run command but do NOT detach

I want to do something like this: #!/bin/bash screen -r session -X run 'long-cleanup-and-quit' doing-something-else ... Which is fine, but I want 'doing-something-else' to wait for screen. screen -X ...
hyy's user avatar
  • 11
1 vote
0 answers
86 views

What is shell's maximum background jobs PID stored exit-codes?

When running a shell job in the background, the shell keeps track of the exit-code that can be retrieved with wait <PID>. When a new background job is run, it gets its own new PID, even if ...
Léa Gris's user avatar
  • 113
1 vote
1 answer
690 views

Ubuntu 18 ignoring Samba AD user's `loginShell` attribute (set to ZSH, but user receives BASH after login)

We have a samba AD (4.3.11-Ubuntu) attaching to both Windows and Linux clients (Ubuntu 14, and Ubuntu 18) If I examine the LDAP for a user, his loginShell parameter is /bin/zsh. This was working for ...
BurningKrome's user avatar
1 vote
2 answers
6k views

Escape all characters that shell or sqlplus need escaped in any password given

You may try for yourself by creating this user: CREATE USER "karl" IDENTIFIED BY "/?'!@#$%^&*()_+=-~`" (Maybe there are other symbols I should have included for my testing, but that seemed ...
Karl Henselin's user avatar
1 vote
2 answers
884 views

Shell Scripting and Types of Text File Output RE: msinfo32

I ran the following script in my Windows 10 command prompt msinfo32 /report mysystem.txt, which saves all the system data of the machine in a single text file. However, when I ran strings on the ...
efw's user avatar
  • 111
1 vote
0 answers
2k views

why soft limit in /proc/{pid}/limits is different with ulimit -Sn

I found hard limit value in /proc/{pid}/limits match the output of ulimit -Hn while soft limit value doesn't my example output: tomcat@myLinux:/home/azhang$ ulimit -Sn 1024 tomcat@myLinux:/home/...
actan's user avatar
  • 111
1 vote
0 answers
286 views

Create a screen. Run said screen as a user. Detach

I'm essentially trying to combo Create screen and run command without attaching and another answer that allowed me to run a script as another user. I want to SSH from Server 1 -> Server 2 and run a ...
sfxworks's user avatar
  • 157
1 vote
1 answer
122 views

Can GNU screen leave you at shell prompt after command instead of exiting the TTY?

I commonly need to run a specific screen session with 9-10 windows, most of which need to run either an interactive command, or simply a setup-type of command. I do this via screen -c <config-that-...
Larold's user avatar
  • 812
1 vote
3 answers
791 views

If run as a cronjob my shell script doesn't launch a screen

Please have a look at the following simple shell script startCleanup.sh: #!/bin/sh screen -d -m -S cleaner /usr/bin/python3 /opt/cleanup.py My crontab looks like this: * * * * * /opt/startCleanup....
toom's user avatar
  • 227
1 vote
1 answer
843 views

rsync - on uncleaned shell and connection unexpectedly closed

I want to run rync to a remote server which has an uncleaned shell. If someone tries to connect it via ssh shell, it'll show some warnings. Due to this issue I couldn't able to copy files. protocol ...
TheDataGuy's user avatar
1 vote
0 answers
638 views

Traffic Control on a Linux-bonded / LACP interface

I have created a virtual interface (VIF) [Read Linux Bonding / LACP interfaces] using two physical ethernet interfaces of 1GBps each. When I apply traffic control on the same, I see that the egress ...
Ghost's user avatar
  • 111
1 vote
0 answers
329 views

How to log commands executed by users with non-interactive shells

I want to log commands executed by an application server(resin) to catch things like "cat /etc/passwd" or "whoami" being executed by user resin. However, since the user resin uses a /bin/false shell, ...
user435644's user avatar
1 vote
1 answer
481 views

How to do an automated Restore of Cassandra Backup(Snapshot)?

I do have a single node Cassandra EC2 instance (apache-cassandra-3.10), in which I take snapshots (backup) on daily basis and upload it on AWS S3. I also take the backup of complete "schema" and "...
Ashutosh Dwivedi's user avatar
1 vote
0 answers
1k views

mount a windows folder in solaris 11.3

I want to check a folder which is placed in a windows server by my Oracle RDBMS12C. therefore based on my research first I need to mount the windows folder in solaris 11.3. we are using spark server. ...
Amir's user avatar
  • 143
1 vote
1 answer
2k views

How to escape double quotes and exclamation mark in password?

I have the following code: curl -s --insecure -H "Content-Type: application/json" -X POST -d "{\"username\":\"$1\",\"password\":\"$2\"}" http://apiurl In the above curl command I want to escape the "...
me24hour's user avatar
1 vote
0 answers
775 views

How to get Deployment manager hostname and port dynamically in IBM WebSphere Application Server 8.5.5 using shell script in linux?

I need to get the deployment manager hostname and port dynamically in IBM WebSphere Application Server 8.5.5 using shell script.
Suganthan Raj's user avatar
1 vote
1 answer
150 views

Variable wildcards in shell

say I have this folder structure with these files inside: ./ |---- orig/ |--- 1a |--- 1b |--- 2a |--- 2b |---- 1/ <empty> |---- 2/ <empty> ...
Pizzicato's user avatar
  • 111
1 vote
0 answers
288 views

OOM using CRON but not using SHELL

When I start a java program by shell, everything is working well. However if I start the same program with the same command and same user by CRON, I get a java.lang.OutOfMemoryError just after a few ...
DOB's user avatar
  • 11
1 vote
0 answers
55 views

Monitor disk occupancy

The problem should be simple, but not so obvious to me. I have a process that creates temporaries in a specified directory, under MacOS X. I need to find the disk occupancy of the process, if ...
senseiwa's user avatar
  • 151