Questions about bash only, as opposed to other Bourne/POSIX shells. For all Bourne/POSIX-style shells, use the /shell tag instead.

learn more… | top users | synonyms

3
votes
2answers
32 views

Parenthesis works in bash shell itself, but not in bash script

As the title says, I can run this command from my command line prompt: cp -r folder/!(exclude-me) ./ To recursively copy all contents of folder except for the subdirectory named exclude-me into the ...
1
vote
0answers
18 views

Maintain screen session when executing shell script on boot

On Ubuntu 14.04, I have a crontab entry set to run on reboot: @reboot /root/start_server.sh And here's start_server.sh: screen -dmS server bash -c "cd server ; ./run.sh" When the system starts ...
0
votes
0answers
17 views

Ubuntu 14.04 HDMI UDev Script

I have tried multiple variations to this script but I cannot get it to work. The UDEV Rule fires the script and the script exectutes but simply does not change the audio profile. If I run the script ...
3
votes
5answers
78 views

How can I cd from parent1/suba/subb to parent2/suba/subb without listing subdirectories?

I have multiple parent directories with the same file structure beneath them. Example: parent1/suba/subb/ parent2/suba/subb/ When I am in parent1/suba/subb, I would like to change to ...
1
vote
2answers
167 views

How does the latest “Bash Bug” or exploit affect systems that require authentication?

I'm curious to know how the latest Bash Bug affects systems that require a user login to access the shell. Isn't UNIX/Linux usually configured in a way that you have to be an authenticated user to ...
6
votes
1answer
4k views

How to apply the fix for CVE-2014-6271 bash vulnerability on cygwin?

I would like to find out how do I apply the fix for this vulnerability on cygwin. I am running the CYGWIN_NT-6.1 MYHOSTNAME 1.7.30(0.272/5/3) 2014-05-23 10:36 x86_64 Cygwin of cygwin on Windows 7. ...
44
votes
3answers
23k views

how can shellshock be exploited over SSH?

Apparently, the shellshock Bash exploit CVE-2014-6271 can be exploited over the network via SSH. I can imagine how the exploit would work via Apache/CGI, but I cannot imagine how that would work over ...
7
votes
1answer
4k views

What is the severity of the new bash exploit (shellshock)? [duplicate]

Alternate title: Should I be worried? I've been reading up about the remote bash exploit and was wondering how severe it is and if I should be worried, especially since a new exploit has been found ...
7
votes
1answer
863 views

How does `env X='() { (a)=>\' sh -c “echo date”` work?

After reading about the latest bash vulnerability, I was wondering how Tavis Ormandy's exploit works. How does (a)=>\ work? He posted: The bash patch seems incomplete to me, function parsing ...
7
votes
4answers
13k views

How to only install security updates on debian

Because of the Shell Shock bug I need to make updates on some of our machines. But I am not sure if all of the packages suggested in apt-get upgrade are OK for my system. In other words I am not sure ...
4
votes
3answers
3k views

CVE-2014-6271 Bash Vulnerability example [duplicate]

I am trying to understand what could be the security concern of CVE-2014-6271 and all the links I see just gives me the below command. env x='() { :;}; echo vulnerable' bash -c "echo this is a test" ...
79
votes
2answers
14k views

When was the shellshock (CVE-2014-6271/7169) bug introduced, and what is the patch that fully fixes it?

Some context about the bug: CVE-2014-6271 Bash supports exporting not just shell variables, but also shell functions to other bash instances, via the process environment to (indirect) child ...
158
votes
5answers
56k views

What does env x='() { :;}; command' bash do and why is it insecure?

There is apparently a vulnerability (CVE-2014-6271) in bash: https://securityblog.redhat.com/2014/09/24/bash-specially-crafted-environment-variables-code-injection-attack/ I am trying to figure out ...
2
votes
4answers
125 views

Remove all comments from a file?

I have a file with a few lines commented out: foo bar stuff #Do not show this... morestuff evenmorestuff#Or this I just want to print all the uncommented code: foo bar stuff morestuff ...
0
votes
1answer
63 views

Copying files with multiple extensions

I would like to copy files with multiple extensions to a single destination directory. For example, I can use the following command to copy all .txt files in the working directory to a directory ...
4
votes
2answers
47 views

How much data can a bash variable hold?

Let's say I want to parse the same log portion several times. I want to do data=$(grep "initial filter" file.log) and do the next filters on $data. Will $data grow until all memory is used up?
16
votes
7answers
616 views

How to efficiently generate large, uniformly distributed, random integers in bash?

I have been wondering what would be the best way to get good randomness in bash, i.e., what would be a procedure to get a random positive integer between MIN and MAX such that The range can be ...
2
votes
2answers
472 views

Assign Subshell background process pid to variable

I am currently starting a background process within a subshell and was wondering how can I assign its pid number to a variable outside the subshell scope? I have tried many different ways but MYPID ...
1
vote
1answer
59 views

chroot for sftp user

I followed multiple guides on the internet on how to restrict a user so that he cannot change/see files outside of his home directory. So I created a user, let's call him john and I also created a ...
3
votes
1answer
54 views

Control-p freezes SSH session

I have encountered a strange situation on one of my SSH ARM machines I use on a daily basis. Every time I connect to the server and press Ctrl+P to invoke previous-history BASH function SSH connection ...
1
vote
2answers
28 views

How can I prefer another bin file?

I have installed both Wine via Homebrew and via WineBottler. I have multiple bin files named wine. When I run for example wine morrowind It starts it with the one in ...
0
votes
2answers
17 views

7z from bash script won't exclude directories

I've encountered with kinda strange behaviour of 7z (or bash, I don't know yet.). With the following script: #!/bin/bash find /home/user -type f -name "*.pdf" | cut -c 10- > ...
1
vote
3answers
56 views

How to get the pid of a process and invoke kill -9 on it in the shell script? [duplicate]

I have an application server which we start by running this below command and as soon as we run the below commnad, it will start my application server /opt/data/bin/test_start_stop.sh start And to ...
-2
votes
0answers
14 views

UNIX .vimrc settings not preserved after running Screen command

After the terminal window first appears, I run Screen to split the screen horizontally. I notice however that my settings for VIM in .vimrc are not "preserved". Is there a way to fix this? I am ...
1
vote
1answer
74 views

Why are UNIX shells like this and how can I work around it?

One of the things I've noticed about BASH and other UNIX shells is that, by default and when used in typical ways, they spawn subshells for almost everything. e.g. foo=$(grep "someword" ...
0
votes
2answers
61 views

Permanent header in bash terminal [closed]

I'm working on a small server I want to put together (nothing big, an Android HDMI dongle, running Debian armhf, no desktop, just remote), and I want a small little feature I've seen at a few places ...
2
votes
2answers
38 views

List of subdirectories that contains a particular file name

I am wondering if i can do this in a single shell command. I am in home directory and want to find a list of subdirectories that contains a particular file. The file name and the depth is always ...
3
votes
2answers
141 views

using modified file content as arguments

In a script I'd like to purge a mercurial repository but be able to retain a number of (configurable) file patterns which I read from $FILENAME. The syntax for the hg command is hg purge --all ...
2
votes
1answer
37 views

Why can't I use tab expansion/auto-complete of shell variables with cd?

I have setup a variable in .bashrc: export SOME_DIR=/path/to/some/dir Now, with ls I can type ls $SOME_DIR[tab] and the variable will be expanded, and I can then use tab for auto-completion when ...
0
votes
1answer
24 views

Disabling a keyboard key in console

I wrote a script that dialog command is vulnerable to Esc key, now I want to disable Esc key in console. NOTE: X11 has been not installed in server and xev or xmodmap doesn't work.
0
votes
1answer
35 views

How do I switch from bash to zsh? [duplicate]

I can start zsh with zsh. How can I make it be the default for new terminal windows? Will it be ok to copy my .bashrc to .zshrc to get things like my customized PS1 prompt.
1
vote
2answers
45 views

How does bash pass user groups to a child?

It is well-known that if I add myself to a new group, that change will not be reflected until I log out and back in: $ sudo adduser me newgroup $ groups me sudo $ groups me me sudo newgroup $ This ...
1
vote
3answers
87 views

How to find md5sum of files on remote machines by doing ssh?

I am running my below shell script on machineC which gets the md5sum of my files in my PRIMARY directory in machineC itself. #!/bin/bash export PRIMARY=/data01/primary for entry in "$PRIMARY"/* do ...
0
votes
1answer
30 views

Permission denied while getting the md5sum of a file using shell script?

I am running my below shell script which gets the md5sum of a files in my PRIMARY directory #!/bin/bash export PRIMARY=/data01/primary for entry in "$PRIMARY"/* do local_md5sum=/usr/bin/md5sum ...
0
votes
2answers
36 views

When executing a script via ssh, how can I transfer variables back to the PC issuing the cmd?

I'm writing a pretty simple script that will SSH into the machine of my choice, run a script to obtain things like the number of users logged in, CPU averages, etc, and write it to a file on the PC ...
0
votes
2answers
40 views

Bash script: test command -o option

I have a piece of code like this: count=0 until [ -f $filename -o $count -ge 60 ] do count=$((count+1)) sleep 1 done I know [ -f $filename -o $count -ge 60 ] is a test command, "-f $filename" ...
2
votes
1answer
44 views

Bash - how to make explicit operator precedence without creating a subshell

I'm sure this is posted somewhere, but I haven't been able to find it. In Bash, how does one specify operator precedence (aka command grouping) without creating a subshell? In most other languages ...
1
vote
0answers
65 views

HISTSIZE HISTFILESIZE not working [closed]

I have set these global variables in my .bashrc file Running echo $HISTSIZE echo $HISTFILESIZE both return 10000 My History contents are overding, currently from 254 - 432 If I type another two ...
2
votes
1answer
28 views

Is there a way to express fixed size loops as loop-less expansion statement in bash?

I was wondering whether expansion of {} in bash shell, e.g. of command /path/to/file{1,2,3} works "horizontally", i.e. command /path/to/file1 /path/to/file2 /path/to/file3 or "vertically", i.e. ...
0
votes
3answers
162 views

How to add a password to a specific command

I've been searching google on how to add additional security to a specific command without using sudo. Is it possible to add on a security feature without actually using sudo? For example: Whenever ...
2
votes
1answer
31 views

Single or double brackets and portability

I have found some very good answers here on the differences between [ and [[ in 'if' statements. For specific named shells, it seems to be a good idea to use [[ over [ (and it is faster, too). I'm ...
0
votes
3answers
115 views

How do I substract 5 minutes from a Unix timestamp?

I have a date in milliseconds since Unix epoch format, how do I substract 5 minutes from it?
1
vote
1answer
50 views

How do I convert a date to milliseconds since Unix epoch in bash?

I've got a date in format: 22-Sep-2014 10:32:35 I need a 13-digit timestamp, but when I convert this way time=$(date -d "$DATE" '+%s') I get a 10-digit number When I try tt=$(date -d ...
0
votes
1answer
43 views

How to invoke shell function in string? (bash)

I want to invoke shell function in string. Here is my use case: function envfoo() { env ENV_FOO=foo $@ } function envbar() { env ENV_BAR=bar $@ } $ envfoo env |egrep ENV_ ENV_FOO=foo $ ...
2
votes
2answers
43 views

How to run the dialog command with proccess?

NOTE: Please look at my code, it's a Bash script. I want to display both dialogs on the screen at the same time, one dialog displays this: tail –f from - /var/log/proccess1.log and the second ...
-1
votes
1answer
47 views

Match and combine records in Bash [duplicate]

Consider two csv files: $ cat given.csv 123,John 246,Paul 369,George 987,Ringo $ cat family.csv 246,McCartney 123,Lennon 987,Starr 369,Harrison Note that the lines are not ordered! How might I use ...
6
votes
1answer
57 views

Format cputime for ps

I'm trying to write a script that can monitor a process's CPU usage over an interval (to create a graph). So far, this is the command I'm using ps -p $PROCID -o cputime,etimes My only concern is ...
5
votes
3answers
106 views

Bash script error with strings with paths that have spaces and wildcards

I am having trouble getting the basics of Bash scripting down. Here's what I have so far: #!/bin/bash FILES="/home/john/my directory/*.txt" for f in "${FILES}" do echo "${f}" done All I want to ...
0
votes
1answer
40 views

How to take screenshot of /dev/pts?

I am connecting to another server using ssh service. I want to execute some commands (like creating users) on some servers and take the screenshot of the pseudo-terminal, which is to be stored on my ...
2
votes
2answers
27 views

Gather job usage information on cluster

I am running simulations on a linux cluster shared by hundreds of other users. There is a job scheduler installed on the cluster that determines who runs where, and one of the scheduler commands ...