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.
1,365
questions
4
votes
1
answer
1k
views
Linux - Limit user to one application in ssh
This is something that I looked into a while back and found some useful info for... but now that I actually need to do it, of course I can't find that guide I saw anymore.
Anyways, here's the ...
0
votes
2
answers
50
views
How to get the sub string part from a directory with shell command
I would need to extract only last 2 part from the following directory path using shell command
"Android/2.1/Packages/test/debug/"
Expected out put: /test/debug
This path is the dynamic where it ...
1
vote
2
answers
2k
views
Executing local bash script remotely, interactively, with arguments
From all of my testing it seems like it is not possible to execute a local script remotely while allowing an interactive shell and passing arguments.
Interactive (arguments try to run as a seperate ...
0
votes
1
answer
2k
views
How to use SFTP BatchMode inside EXPECT[Shell Script]
I have set of series SFTP commands which needs to run inside expect.
But when i run the below script due to some reasons am not getting any output. Please correct me if am wrong any where inside the ...
2
votes
3
answers
224
views
Is there a *NIX shell that has most all tools built-in - not symlinked, no external execs? [closed]
I am looking for a *NIX shell where most of the basic functionality - ls, cat, etc. - is done internally and not called via exec to outside programs. busybox does something with symlinked binary names ...
1
vote
0
answers
640
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 ...
0
votes
1
answer
1k
views
Bash script shows error for "pwd", simple script
I'm trying to make a Bash shell script but it is not working. Here is the contents of the script:
#!/bin/bash
pwd
I would expect this to print out the current directory. Instaed, it prints this:
...
1
vote
2
answers
246
views
Can different scripts share a lockfile to ensure they don't interfere with each other?
I've used flock a lot in the past to ensure that a process only spawns once (in case it gets hung up/etc) but I've never used it for two different processes.
In this scenario two different scripts ...
1
vote
2
answers
1k
views
shasum of tar file different on os x / ubuntu although files are identical
I have a problem that brings me to despair and is plaguing me for the last days and I hope somebody can give me a hint what I have overlooked, since bash/sh is not a field I work in everyday:
...
0
votes
1
answer
246
views
Can I separate shell script ifs into multiple files?
So here's is the scenario, I have a shell script that based on a network command it execute an action, it may be a service restart or stop. That part is working fine, but I'm stucked at a part that I ...
0
votes
1
answer
732
views
My shell script run perfectly by putty command but when I put it in crontab it doesnot work
I have two shell script named: backup_inventory_sourcecode.sh and backup_bash.sh. I run these two .sh file using as putty as follows:
sh /var/www/html/backup_inventory_sourcecode.sh
sh /var/www/html/...
0
votes
2
answers
1k
views
What are the security risks of using /bin/sh?
A friend of mine told me that you should never allow your users to ssh via /bin/sh because it has many security issues and people can perform attacks using it. Is it really true? If yes, what are the ...
8
votes
5
answers
8k
views
Calculate sum of several sizes of files in Bash
I have list of files in a file, cache_temp.
In file cache_temp:
/home/maildir/mydomain.com/een/new/1491397868.M395935P76076.nm1.mydomain.com,S=1740,W=1777
/home/maildir/mydomain.com/een/new/...
0
votes
3
answers
8k
views
Unable to start a script at startup ubuntu
I am trying to execute one script at startup on ubuntu 16.04 LTS desktop. I have added my script to /etc/init.d location. But after restart I am unable to see my script running using
pidof -s pgd
...
4
votes
2
answers
6k
views
How to identify ancient KornShell version?
We had a guy retire on us, and the documentation left behind is a little on the light side. Need a little help identifying and using part an older client-server system.
The server itself is ...
8
votes
1
answer
23k
views
SaltStack | How to assign the shell output from cmd.run to Jinja variable?
Problem
Unable to assign the output from cmd.run in my Salt State. The condition always return true even if the load_avg in the minion is not really equal or beyond the threshold. I also included in ...
0
votes
1
answer
212
views
getting multiple issues while creating a scrip to update hostnames in /etc/hosts file?
I'm completely new to the scripts and hence need help to fix this.
We've around 3000 VMs & 450 Physical servers which are Linux based servers (few of then ubuntu starting from 9.x & few of ...
5
votes
3
answers
11k
views
How to test RDP credentials in command line without X server installed?
I've been asked to test from time to time some RDP credentials, and it must be done through a linux server.
Is there any way to test some RDP credentials in command line, without a X11 server ?
0
votes
1
answer
104
views
How to create and close SOCKS5 tunnel after n seconds?
I'm creating SOCKS 5 tunnel via ssh:
ssh -D 1337 -f -C -c blowfish -q -N user@host
I only need it for a fast and loose client connection, and then it's no longer needed.
I would like it to close ...
0
votes
2
answers
3k
views
Exit code for ldap testing using nc or ncat
I am trying to write shell script to test if a server is able to reach a specified ip and port.
The commands i am using: ncat -w 5 <IP> 636 or 389 > /dev/null 2>&1 < /dev/null | ...
0
votes
2
answers
234
views
Create copy of file in the same location
I often need to create copy of files in varios locations(, and want to avoid excessive typing). (Then I will edit them)
Basically commands are like:
cp very/long/path/to/file/my-file_with-long.name ...
1
vote
0
answers
330
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, ...
1
vote
1
answer
484
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 "...
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.
...
0
votes
1
answer
1k
views
apache2 redirect http to https in vagrant box
I am trying to achieve apache2 http redirect to https in vagrant. Below is my Vagrantfile and bootstrap.sh script. I am not able to figure out what I am doing wrong here in case of vagrant box. I am ...
1
vote
1
answer
116
views
shell : warn about or deny command execution with help of an alias
executing
iptables -F
is very dangerous if your default policy for one or all chains is DROP
I would like to use an alias in bashrc like
alias iptables -F="echo \
'WARNING: due to the DROP ...
1
vote
2
answers
3k
views
Bash script entrypoint (PID=1) kills `tail` sub process ONLY if a fake trap (which does NOTHING) was there [closed]
I am facing a strange behavior in my Bash script, I have this Bash script which is running with PID 1 (it is an entrypoint for Docker container, if you are not familiar with Docker, I assume you can ...
0
votes
1
answer
219
views
CentOS - bash version not changing after upgrade
Current bash version is vulnerable to shellshock. But upgrading doesn't change the bash. I've tried rebooting.
CentOS version 5.6
[user@server ~]$ bash --version
GNU bash, version 3.2.25(1)-release (...
2
votes
2
answers
82
views
Is there an effective way to test whether a script only uses POSIX features?
If I wanted to be sure that a script I have written is as portable as possible and only uses POSIX features and no, say, bash features, is there an explicit way to check this?
Obviously, I could try ...
38
votes
3
answers
7k
views
#!/bin/sh vs #!/bin/bash for maximum portability
I usually work with Ubuntu LTS servers which from what I understand symlink /bin/sh to /bin/dash. A lot of other distros though symlink /bin/sh to /bin/bash.
From that I understand that if a script ...
2
votes
2
answers
3k
views
Unzip archive with one line of output?
I wonder if there is a way to unzip a file via "unzip" in the shell while having only the current file outputted instead of total silence "-q" or a ever growing list that slows down the process esp. ...
2
votes
1
answer
14k
views
sed: -e expression unknown option to `s'
I know this has been asked before, but im struggling to determine the root cause of the error with my script. Ive gone through the other questions and tried to convert this (switched the /\ for @) but ...
1
vote
1
answer
3k
views
Bash - Insert variables into string (command not found)
I try to write a script for get some software's version from many servers.
But I get this error message, when i try.
bash: Postfix verzio: MariaDB verzio: OS verzio: Java verzio: :
command not ...
0
votes
1
answer
248
views
nano/vi open write protected file as a unauthorized user- Can I escalate to save?
More times than I want to admit I will open a config as a non-super user and will go about making the changes I need. As soon as I save in nano, or vi I am met with permissions errors.
At this point ...
0
votes
0
answers
56
views
Update the content of one file to another in shell with pattern
I have a whose contents should be updated on another file. How do I do this using sed command?
A.txt
{
username:someuser,
password:somepass
}
B.txt
{
username:tempuser,
password:temppass
}
So I ...
3
votes
2
answers
1k
views
Azure Cloud Shell history persist across sessions
My Azure Cloud Shell history does not persist across sessions (which time out after 10 mins so this is annoying). The .bashrc has
# append to the history file, don't overwrite it
shopt -s histappend
...
8
votes
3
answers
4k
views
Shell script attack on Apache server, via an cron of unknown origin
While running a project war on Apache tomcat server I found that the server has been compromised.
While running the war on an unknown cron is running like this
[root@App2 tmp]# crontab -l -u tomcat
...
0
votes
1
answer
1k
views
Trying to do grep and sed from a file and push the output into a variable
Can we do grep and sed from a file and push the output into a variable
grep "^/dev/disk/by-id/scsi-*" /tmp/disks.txt | sed '{'s/=.*//'}'
Output would be like this:
/dev/disk/by-id/scsi-...
0
votes
1
answer
155
views
Is unsecure to have a common or easy username for a SSH server? [closed]
I'm aware that there are much more important things to a secure SSH server, as allowing only key based authentication, changing the port or using port knocking, implementing fail2ban, etc.
But, what ...
1
vote
2
answers
4k
views
Execute local alias through ssh on remote server
I know I can execute a function through SSH on a remote server like so:
$ ssh remote_server "$(declare -f cool_function); cool_function"
I also have some aliases that I would like to execute on ...
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 "...
0
votes
0
answers
2k
views
Subshell failing when run through cron
I have a file:
/etc/bind/dnsCron/dnsCron.sh
I run it via cron every 5 minutes:
*/5 * * * * sh /etc/bind/dnsCron/dnsCron.sh
Inside dnsCron.sh I have a line that succeeds when I run it command ...
0
votes
1
answer
3k
views
How to ssh from shell script and execute for loop using global parameters?
What I am trying to accomplish is something like this.
Servers = (11, 12, 13)
ssh -t [email protected] << EOF
sudo tar -zcf somefolders.tar.gz ~/somefolders
for i in "${Servers[@]}"
...
0
votes
0
answers
616
views
How to loop command multiple times passing output to next command
Is there a way to run multiple commands n times, where output of command is passed to next command.
For n=4 command | command | command | command
Example:
I want to generate all possible ...
0
votes
1
answer
3k
views
Logging the output of a long command to a file in Ubuntu
I am using Ubunutu. I simply want to create a postgre dump. So I am using the following command:
sudo -u wap PGPASSWORD="postgres" pg_dump -h localhost -U postgres -d n26n -n public -FC -f /tmp/...
-1
votes
1
answer
1k
views
Did someone just run intentionally db.dropDatabase() on my mongo shell? Can you access mongo remotely and bypass ssh password?
To my surprise, my database was empty after not looking at it for a week. There were collections and a few rows of data. It's running on a digital ocean 14.04 Ubuntu droplet. Mongod is running on the ...
4
votes
2
answers
2k
views
remote ZSH and moving to beginning of line gives ^A print
do remote ssh connection in my tmux terminal (zsh) and remote shell is also zSH.
[devops@postgres-prod]~% vi /var/lib/pgsql/9.6/etc/postgresql.conf^A0A^A^A^E^A
So it doesn't react on Ctrl+A, Ctrl+E
-1
votes
2
answers
380
views
How to monitor user reports through shell scripting
I want to monitor
I have 3 user in my linux machine let's say a,b,c .By Using last command I am able to identify list of last logged in user and by w command who is logged in and what they are doing ...
0
votes
1
answer
2k
views
MySQL query is NOT executed from bash, but works from MySQL client
Using UBUNTU 16.
MySQL query fails from bash, but works from MySQL client:
query=$(cat << EOF
CREATE DATABASE \`${mysql_local_database}\` /*!40100 COLLATE \'utf8_hungarian_ci\' */; use \`${...
-2
votes
1
answer
981
views
Sed replace path for directory from special file with delimirers slash
i should change on parameter to other from template file in linux.
sed -e "s/\${dir}/<in this place i should input path, like /home/username>/" /etc/nginx/site.conf
But it does not work. How ...