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
-11
votes
0answers
30 views

I need write a shell script perform [closed]

Prompt the user for an account name Search /etc/passwd for the user account If the account exists return the following information UID and Home Directory (You'll have to use some commands from earlier ...
0
votes
2answers
100 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 # ...
0
votes
0answers
11 views

tcsh history behaves different on SLES and RHEL/CentOS - unintended commands appears in history on SLES

I have multiline alias in my tcsh environment, like the following: alias my_alias 'set flag="\!*" \ if ( $flag == 1 ) then \ ...
0
votes
1answer
21 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 ...
0
votes
0answers
28 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 ...
0
votes
0answers
18 views

Output to log file from Script not working

I have an interactive script example.sh for updates, part of which is something like this: echo "Performing Backup of Old software" zip -r backup/backup-$now.zip /var/www/html/...
1
vote
1answer
35 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 ...
1
vote
0answers
39 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 ...
0
votes
0answers
14 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" ...
0
votes
1answer
316 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 ...
0
votes
1answer
68 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 ...
0
votes
1answer
34 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 ...
0
votes
0answers
36 views

Monit -failed to start (exit status 1) — no output

I need to start pm2 apps using monit. Im not able to restart it or exec a script which sends messages to slack channel. Can some one help. On monit logs it says trying to restart, but it gives [UTC ...
0
votes
1answer
54 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 ...
1
vote
0answers
104 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 ...
0
votes
0answers
28 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 ...
0
votes
1answer
114 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 ...
0
votes
0answers
25 views

Terraforming Windows - Can't Add to PATH

I got a Terraform to deploy a Windows 10 Server, It does fine to do so, but I can't seem to get it to finish this <script> part: Here is the code: <script> @echo off echo Deployment ...
0
votes
0answers
102 views

Accidental chsh command leads to broken PAM authentication

I accidentally ran the command: chsh -s bash as root and now no password authentication works for root or any users. I have a single SSH session from which to fix it. I can't even open a second root ...
0
votes
1answer
43 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 ...
0
votes
0answers
70 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 ...
0
votes
0answers
24 views

Asterisk dialplan pattern generator

I was wondering if anyone knows about a shell script or Pyhton script, or whatever language, some kind of command line script that given a set of phone numbers, the script will then generate the ...
1
vote
3answers
897 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 ...
0
votes
1answer
148 views

How to owerwrite directory with tar?

I want to extract files with tar so that the whole directory will be owerwritten. I added --overwrite-dir but still old files in test dir remains. For the test, I have /home/ubuntu/f1/test/first.log ...
0
votes
1answer
168 views

looking for an alternative to echo to write data to a file so it can be invoked via sudo

Background: when run on a unix box Tenable.io (nessus) will try to create a tag file in /etc/ with a unique string. Presumably so it can identify the machine if the hostname or IP changes. It does ...
0
votes
0answers
53 views

How to force ansible to limit stdout width?

Is there a simple way to force ansible to think that the shell where it writes is shorter than the actual shell? How does it determine the shell width? I'm using ansible-playbook command in a python ...
0
votes
1answer
23 views

php shell_exec returns different results compared to terminal

I try to run shell_exec("ls -l /dev"); to list all entries in /dev and I get this list: total 0 drwxr-xr-x 2 root root 180 Oct 10 11:19 char lrwxrwxrwx 1 root root 11 Oct 10 11:19 core -&...
0
votes
0answers
24 views

How to store usage and memory percentage that are shown after login in AWS EC2?

When we ssh into our instance we can see these stats displaying. Is there any way to get the same percentage stats with a terminal command?
0
votes
0answers
19 views

Netcat listner is automatically terminating the session

I'm in a virtual environment set up by the school, in which I'm supposed to change a user to root. I have a program that runs each 5 minutes and added this code to the program. The code is provided ...
0
votes
1answer
52 views

Script executes perfectly in command line but failing in cron

I have created a script to know the successful attempts and failed attempts of users,usually everyday the /var/log/secure file goes to syslog and zipped like "secure-20200910.gz" but without ...
1
vote
1answer
65 views

Running clamscan with the file list function

I am trying to schedule some tasks using ClamAV but it cannot find the find the file that contains the directories I want it to scan.   *Using sudo doesn't work.   *The files are set with permissions ...
0
votes
1answer
110 views

left outer join 2 shell output on a common key column using bash

Is there a way I can do a "left outer join" for bash output from 2 different commands based on a common key column (ip address)? For various reasons, I would like to avoid saving the output ...
0
votes
1answer
115 views

Crontab - Sending StdErr to email and stdOut to log file

In my crontab, I'm trying to send stdout to log file and stderr to email account using a custom subject title. I've tried many solutions without achieving my initial goal, let me explain: First method:...
0
votes
0answers
35 views

Using curl to move the files within different directories of the SFTP server

There is a requirement in my project in which i need to move the .csv files present in a particular directory of the SFTP server to the Archived one in the same SFTP server. We dont have SSH done for ...
1
vote
0answers
67 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 ...
0
votes
2answers
60 views

saving sql dump error in a file

I want to save error if error comes, into a file. But error not redirecting into file. I get below error and its not redirecting into file. mysqldump: Couldn't execute 'SHOW FIELDS FROM `v_comloc`': ...
0
votes
1answer
297 views

/etc/profile[278]: ulimit: 1048576: limit exceeded [Operation not permitted] [closed]

[root@bteir airwide]# su - ins Last login: Wed Aug 12 22:31:40 CDT 2020 on pts/0 /etc/profile[278]: ulimit: 1048576: limit exceeded [Operation not permitted] ins ins> This log is kept on writing ...
0
votes
0answers
44 views

Restricted shell and resource for users in CentOS-7

I've deployed CentOS-7 login nodes for users, I want restrict them in resources and command level to prevent nasty activities, so far my search only ended up to rbash and lshell(not active at the ...
0
votes
0answers
25 views

Kerberos cpw ignoring password policies

I'm trying to integrate an implementation of an LDAP user interface with the ability to change Kerberos user password. I'm using a non-interactive command for this task: kadmin -k -t $KEYTABLOCATION -...
-3
votes
2answers
85 views

How do I paste a list of files to a command? [closed]

Let's say I have a newline-separated list of file paths from a previous command that I can copy to clipboard. What's the easiest way to paste this list to feed it into another command in a shell? ...
0
votes
1answer
98 views

Linux does STDOUT | STDIN piping write data to disk?

I was planning on passing encryption keys to zfs load-key pool/set through stdin. The keys passed are generated by another program in HEX format and dataset is configured to have keylocation=prompt, ...
1
vote
1answer
216 views

How to assign array_name dynamically to with_items in Ansible

I have a json file (server.json) with the content like this: servers_groupA: [{server_name: server1abc.net, start_file: w.bat, stop_file: d.bat}, {server_name: server2.abc.net,...
0
votes
0answers
40 views

GNU Rush not expanding variables

With the death of rssh I am trying to use GNU rush as a restricted shell. In theory it is much more capable than rssh, but I am unable to make it work even with a simplest of configurations. I wonder ...
0
votes
1answer
259 views

Assign multiple home directories to same user during useradd

I am working on a project in which a junior developer needs to FTP files onto the server and work in two separate directories that are at the same level on the server. Is is possible to assign BOTH ...
0
votes
0answers
16 views

How to untangle progress output of two mbuffer processes?

If I look at the progress output of head -c 100G < /dev/zero | mbuffer | mbuffer > /dev/null both mbuffer processes print their output in the very same line, overwriting the output of the other....
0
votes
1answer
78 views

How to execute echo cmd on remote ssh command

I have the following line which does not work: ssh -o StrictHostKeyChecking=no -o BatchMode=yes -o ConnectTimeout=5 root@$serverip "echo 'nameserver 1.1.1.1' > /etc/resolv.conf && sudo ...
0
votes
2answers
77 views

Change linux shell

On my Centos7 Server I have different shells for my users. For example the terminal as root looks like: [root@hostname www]#. The terminal as a different user looks like bash-4.2$. If I type echo $0 ...
0
votes
1answer
68 views

How to stop a running shell script if it executes some dangerous operations?

I mean, how to dynamically stop a running shell script based on what operation it's doing. Because some dangerous commands such as rm, if using regex before running, some edge situations may escape, ...
0
votes
0answers
13 views

puppet master configurartion with automatically capture vm IP in puppet configuration

i am trying to install puppet master with automation on vm, I am using shell scripting for this but i am entering IP address of puppet master vm in puppet configuration. but i need to update the IP ...
0
votes
2answers
273 views

Grep messages like trash - No such file or directory

my server was hacked, and I am now trying to locate all the "strange" files. I am running: find . -type f -name '*' | xargs grep -l "Mini Shell" This command is helping me a lot ...

1
2 3 4 5
26