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 ...

learn more… | top users | synonyms

2
votes
2answers
2k views

Shell script for docker ps -a | grep to find number of certain containers running

I want to write a script that is executed by my development build server that will remove any 'similar' docker containers before building and running a new container. Below is pseudo code for the ...
6
votes
5answers
2k views

Run a script from anywhere

I have a script: #!/bin/bash echo "$(dirname $(readlink -e $1))/$(basename $1)" that sits here: /home/myuser/bin/abspath.sh which has execute permissions. If I run echo $PATH I get the following: ...
187
votes
5answers
72k views

What is the difference between double and single square brackets in bash?

I just wondered what exactly the difference between [[ $STRING != foo ]] and [ $STRING != foo ] is, apart from that the latter is posix-compliant, found in sh and the former is an extension ...
0
votes
0answers
16 views

Why wont my service run after reboot?

I have created the following service in the directory /etc/init.d of my Debian 7.2 Wheezy machine: #!/bin/sh ### BEGIN INIT INFO # Provides: myService # Required-Start: $all # ...
0
votes
1answer
22 views

Unable to SSH with shell into NAS: “error: openpty: Invalid argument”

I have a WD MyBook WorldEdition II (White Light) NAS here. This essentially is a ARM926EJ-S with two SATA drives attached. For quite some time, I was running Debian 6.0 Squeeze on it. Now I recently ...
-2
votes
0answers
29 views

Remove same php code from all php files [closed]

I need to remove everything between following tags in all php files using ssh <?php $rfghoh = $rfghoh=$yuoopi-1; ?> Thanks
0
votes
1answer
1k views

Monit failed to start shell script

So I am having a problem with monit starting a process this is my code: check process program_1 matching "program_1" start program = "/home/user1/files/start.sh" stop program = ...
8
votes
3answers
3k views

nc (netcat) hangs, waiting for more data, in UDP mode.

I'm trying to send a small string to statsd via nc inside of a read block: while read line; do printf "folder.counter:value|1c" | nc -q 0 -u $host $port done Unfortunately, when in UDP mode, nc ...
1
vote
0answers
12 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 ...
15
votes
5answers
10k views

How to split a PEM file

Note : This is not really a question because I already found the answer but since I didn't find it easily here I will post it so that it can benefit others. Question : How to read a concatenated PEM ...
0
votes
1answer
1k views

expect script not working with bash script

I want a script that ssh to remote server and then run a script which is at my local machine and then store the output on my local machine Expect script for ssh to remote server: #!/usr/bin/expect ...
8
votes
3answers
8k views

Can't run AWS CLI from CRON (credentials)

Trying to run a simple AWS CLI backup script. It loops through lines in an include file, backs those paths up to S3, and dumps output to a log file. When I run this command directly, it runs without ...
9
votes
10answers
9k views

How to determine if I'm logged in via SSH?

I'm currently setting up a fairly complex bash configuration which shall be used on multiple machines. I try to find out if it is possible to determine whether I'm logged in via SSH or on a local ...
5
votes
1answer
4k views

How to change default shell in FreeBSD?

The default shell in FreeBSD is sh and I really can't stand it: autocomplete is very limited, and rehash commands kill me. I feel like a one armed and one legged man... How can I change the shell ...
0
votes
0answers
6 views

sed use to replace string 2 lines after matching pattern in AIX 6.1 [migrated]

I try to replace a character, 2 lines after matching pattern. For this, I'm using this code: sed '/some_pattern/{N;N;s/word1/word2/}' /etc/filesystems > /etc/filesystems.tmp && mv -f ...
1
vote
1answer
44 views

error while playing ansible playbook

I just installed ansible on a server in aws and then created a playbook to run the same but while running i am getting error as below : ERROR! 'copy' is not a valid attribute for a Play The error ...
0
votes
2answers
2k views

Netstat count TIME_WAIT connections by port

I can obtain individual TIME_WAIT counts on a port, netstat -nat | grep :11300 | grep TIME_WAIT | wc -l; but how to do this based on all ports eg: 11300 2900 connection 3306 1200 connection ...
92
votes
9answers
104k views

Shell command to monitor changes in a file - What's it called again?

I know there was a command on Unix that I could use to monitor a file and see changes that are getting written to it. This was quite useful especially for checking log files. Do you know what it is ...
2
votes
6answers
8k views

Don't need the whole line, just the match from regular expression

I simply need to get the match from a regular expression: $ cat myfile.txt | SOMETHING_HERE "/(\w).+/" The output has to be only what was matched, inside the parenthesis. Don't think I can use ...
23
votes
4answers
14k views

How can I check in bash if a shell is running in interactive mode?

How can I tell (in ~/.bashrc) if I'm running in interactive mode, or, say, executing a command over ssh. I want to avoid printing of ANSI escape sequences in .bashrc if it's the latter.
19
votes
3answers
3k views

What is /usr/bin/[?

I was just poking around in /usr/bin and I found an ELF binary file called [. /usr/bin/[. I have never heard of this file and my first thought was that it was a clever way of hiding a program, ...
0
votes
0answers
10 views

MRTG Target field

Can I use OID and Shell Script in the MRTG Target field at the same time? For example Target[myrouter]: check_connection.sh&1.3.6.1.4.1.999.1:public@mydevice Please advise. Thanks
1
vote
1answer
57 views

How to create chroot'ed SFTP access on an Archlinux Server?

I've followed this instructions on the ArchWiki and GeekStuff to setup an user which can only access the server via SFTP (SSH) but without Shell (/bin/false) in a chrooted environment of his home dir. ...
0
votes
0answers
35 views

Terminal line wrapping issues only with Docker/Kubernetes

I'm on OS-X and running either iTerm or the standard OS-X terminal. In either case if I start a Debian docker container like docker run --rm -ti mycontainer:latest I get a command line prompt and line ...
8
votes
5answers
10k views

chsh: PAM authentication failed

i want to change default shell env and run chsh -s /bin/zsh as root user, but a error message appeared: chsh: PAM authentication failed. i find this thread ...
2
votes
2answers
53 views

printing user of subshell obtaining root via su -

Can I print the username which is obtaining root access via su - on the root console upon obtaining root? user1$ su - password: obtained root via user1 #
0
votes
2answers
146 views

how to put files in ram

I have a server with 30 Gb ram and i have a script that put a (.ts) file (10mb) in /var/www/html/tv and script replace (.ts) file every 2 mintues. so my question is: can i mount this folder ...
-2
votes
1answer
3k views

How to scp file to remote servers' root directory and run sudo commands?

NOTE: The servers does not share the same password but I will setup no-password login at first. Here's the use case, I need to do these below step by step in my deploy.sh: scp files to remote ...
7
votes
3answers
4k views

Is there a Windows CMD equivalent of Unix shell's exec?

Is there any equivalent in Windows to Unix Shell's "exec"? Basically, I need to avoid forking a new process, so that input/output pipes are preserved, as well as process id. Edit: So, here's my ...
7
votes
4answers
4k views

Count number of bytes piped from one process to another

I'm running a shell script that pipes data from one process to another process_a | process_b Does anyone know a way to find out how many bytes were passed between the two programs? The only ...
0
votes
1answer
4k views

rsync: getcwd(): No such file or directory (2)

I want to sync Server1 and Server2's logs to LogServer. For Server1: rsync -avz -e 'ssh -p 2188' user@server1:/usr/local/servers/logs/* /usr/local/logs/ This one works, but for Server2: rsync ...
0
votes
1answer
53 views

Looking for IPs by page visited in apache log (awk?)

I have a bunch of apache access log files and I want to know which IP addresses visited my /contacts folder. How can I collect them from all log files with shell command?
1
vote
1answer
54 views

Unix move folders with pattern

How can I move subfolders with a pattern to the new location? Example list of sources: /data/aaa/_old/ /data/bbb/_old/ The destinations should be: /archive/aaa/_old/ /archive/bbb/_old/ Is ...
1
vote
1answer
43 views

nginx - How often was accessed to specific file or path? [closed]

I'm looking for a command/line to get the information how often was a specific file/path accessed from the web-server. (source: default access-log from nignx) It should check all logs (current and ...
0
votes
2answers
65 views

Powershell equivalent of Ctrl+R?

In bash I can do Ctrl+R and start typing a command to have it search my history. How do I do that in powershell? Is there a way to bind a key to something like function GH($str) {get-history | ...
0
votes
0answers
18 views

Run a script if another process was spotted

I have CentOS 7 and looking for a sollution about a small issue. I want to have a sudo script to be run but only if the system executed a specific command remotely. For example: I've put my command ...
2
votes
1answer
242 views

How can I prevent shell access on a user account but show a custom message instead (on linux)?

For various reasons, I need to enable telnet access (over the private network), and when someone tries to log in with a specific user account (lets say CheckStatus), instead of giving the user a shell ...
0
votes
2answers
2k views

Installing PHP extensions to the correct PHP version

We have two versions of PHP on our Linux CentOS6 machine, 5.3.3 and 5.6.7, and wanted to install PHP extensions, memcache and imagick, to 5.6.7. Logged in as root, using yum, we installed both of ...
9
votes
8answers
18k views

Easy way to get IP address from hostname using a Unix shell

What is the easiest way to get the IP address from a hostname? I was thinking about trying a ping and parse it from the output. However, that doesn't seem very nice and will probably not work the ...
57
votes
8answers
93k views

How can I kill all stopped jobs?

When I try to exit from my Linux server I get the message: There are stopped jobs. : Is there a single command to kill these?
2
votes
2answers
3k views

'pargs' command in FreeBSD or Linux

What's the FreeBSD (or Linux) equivalent to the 'pargs' command, available in Solaris? Many times I want to know what are the environment variables for a given process space, with no help from these ...
1
vote
2answers
2k views

Linux Command Prompt - Ctrl + r - Not working so swell

Whenever I hit Ctrl+r in my command prompt it seems like I have 10 milliseconds to finish typing whatever I'm searching for and at that point it searches for whatever I've typed so far. It also ...
0
votes
1answer
901 views

Disable the ability to hide bash command history

User can hide the command history in bash by either append a space before the command unset HISTFILE How to disable this?
3
votes
2answers
2k views

Preventing bash (and ksh) history alteration in Linux

From the looks of things, fixing ksh to make history alteration impossible is fairly easy. I've seen all the recommendations to make HIST* environment variables read-only, and the use of chattr to ...
0
votes
2answers
65 views

making one computers bash prompt match anothers

The computer who's prompt I'm trying to copy: [root@CompanyName-LAMP-DEV:/current/path]$ We'll call that computer computer A. The prompt my computer - computer B - currently has: [root@ip-x-x-x-x ...
1
vote
2answers
186 views

Use sudo in shell script

I have access to another user's account using command: sudo su - other_user I do not have enter password. It seems that this is the only command that sudo allows me. After that I'm able to perform ...
2
votes
1answer
117 views

Function body defined in /etc/profile appears in shell history on login

We run IBM AIX here (currently 7100-03-03-1415) that is missing a fair amount of the utility preset in other versions of UNIX. One of the things that we need to do on a semi-regular basis is convert ...
-3
votes
1answer
26 views

How to cut a string after a number of characters in unix? [closed]

How to delete all characters in one line after point with with sed? I have a file with multiple lines like this: 123456789 3483 98765432 56345 985745634 3469 67495735 87654 Now I want to delete ...
0
votes
1answer
53 views

httpd reload as second command in bash fails

I am trying to run a command that carries out one action, to renew a certificate, and then reloads Apache. To do this I am running the following: sudo /home/ec2-user/letsencrypt/letsencrypt-auto ...
3
votes
2answers
52 views

Compare string on shell script

I'm creating a script to check the requirements about VM in one of my customer. The first part of the script is check if the OS is virtual or not. To achieve this goal I create the following script. ...