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

8
votes
2answers
147 views

Why is the ability to definine functions in an enviromental variable not a security risk in itself?

As I understand it, generally it is considered safe to let anyone provide information that will be stored in an environmental variable. The shellshock vulnerability is an issue here because it means ...
15
votes
4answers
1k views

Do we have more history for cd?

cd - can move to the last visited directory. Can we visit more history other than the last one?
1
vote
1answer
58 views

www server restart after upgrading bash regarding the shell shock bug?

If a webserver uses CGI with bash, does it calls bash every time when there is a request regarding CGI or does it caches (bash and related libraries) it when starting the webserver? Q: So is a ...
2
votes
4answers
83 views

Bash - How do I loop through subdirectories and extract the files

I have a directory called 10K_TIF (main directory). Within this main directory are multiple sub-directories each containing tif images. I want to read each TIF image and extract its path using a bash ...
5
votes
3answers
1k views

Shellshock: Why this error when testing for vulnerability

I am using Fedora 20 on two machines. Having read about the Shellshock vulnerability, just now at 1100ish UTC on September 26th 2014, in UK, after a yum update bash to protect against it, I tried ...
4
votes
2answers
94 views

How to capture ordered STDOUT/STDERR and add timestamp/prefixes?

I have explored almost all available similar questions, to no avail. Let me describe the problem in detail: I run some unattended scripts and these can produce standard output and standard error ...
2
votes
2answers
168 views

Correct way to find this (shellshock patch) package?

I was out to patch some squeeze servers for the shellshock bug. A few googles later I found that I could updated my apt sources list. This did however not work for some reason. I tried to search for ...
0
votes
1answer
43 views

Bash crashes when running common commands [closed]

Open Bash, run Top, and about 1/3 times, bash just closes. The other 2/3 times, it runs properly. The same thing occurs with other commands like "clear" or "/sbin/ifconfig" Any ideas what may be ...
4
votes
3answers
75 views

How to convert an unsigned decimal (less than 1<<32) to 4 bytes (binary) in bash?

Example: $ decimal=$(( RANDOM << 17 | RANDOM << 2 | RANDOM >> 13 )) $ echo $decimal $ printf "%08x" $decimal | xxd -r -p >bytes The result is in bytes file. Can it be done in ...
2
votes
2answers
46 views

Interacting with a running interactive console program from a different process

I have a console program with an interactive shell, similar to say, the Python interactive shell. Is there an easy way to start this interactive program A and then use another program B to run A? I ...
-1
votes
0answers
31 views

Latest Bash shell hack [duplicate]

What is all this recent fuss about Bash being vulnerable? I read that it is somehow related to environment variables but could not get a hold of it. Can someone explain this vulnerability to me?
1
vote
3answers
55 views

Modify some files to add the file name

I have a bunch of text (hundreds of txt) inside a directory. Each of them has a unique filename. I want to insert filename of each file into the first line of respective files. How can I do that using ...
2
votes
2answers
83 views

Interactive multiple choice in a bash script

Is there a simple way to let the user interactively choose one of the lines of the output of lsblk -f? NAME FSTYPE LABEL MOUNTPOINT sda ├─sda1 ntfs WINRE_DRV ...
0
votes
0answers
22 views

Can't set PATH with a script [duplicate]

I have written a script which was supposed to add some value to environmental variable PATH, but script doesn't do that if I start it with ./script.sh. #! /bin/bash INSTALLDIR="/opt/ARM" ...
0
votes
3answers
62 views

Bash Combine Replacement and Sub String Extraction in One Step

For a string in this format: ./my-site.sub.domain.com I would like to remove the .,-, and /, and trim the remainder to 16 characters: mysitesubdomainc I've done this ...
1
vote
1answer
30 views

help organizing ssh aliases

My .ssh/config is starting to grow with aliases, and remembering them all is getting harder. Do you have any tips for better manage this growing collection? For example an autocomplete when I type ...
1
vote
1answer
192 views

/bin/sh: error importing function definition for `some-function'

I encountered this error when updating bash for the CVE-2014-6271 security issue: # yum update bash Running transaction (shutdown inhibited) Updating : bash-4.2.47-4.fc20.x86_64 /bin/sh: error ...
2
votes
0answers
1k views

How to test shellshock against remote machine using a simple script [closed]

I am interested in testing for shellshock vulnerable machines that I don't have shell access to on my LAN's and WAN's such as IPMI cards and Internet of things devices. What is the best way to ...
3
votes
2answers
41 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
40 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
34 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
85 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
192 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 ...
7
votes
2answers
7k 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. ...
50
votes
3answers
29k 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
5k 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
1k 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
17k 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
4k 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" ...
90
votes
2answers
16k 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 ...
176
votes
5answers
67k 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
143 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
77 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
54 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
714 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
538 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
85 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
65 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
29 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
37 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
76 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 ...
1
vote
1answer
77 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
68 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
47 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
146 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
53 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
35 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
50 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
49 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
111 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 ...