Questions tagged [bash]

The Unix shell formerly used by Terminal in macOS until 10.15

Filter by
Sorted by
Tagged with
20 votes
9 answers
120k views

Terminal returns not found for most commands Mac OSX

I'm really new to Mac OSX and UNIX based systems. I wanted to run a few Windows games on my Mac Mini so I started installing Wine and MacPorts. I think the installs are correct, but when I type sudo ...
user avatar
369 votes
7 answers
268k views

How do I recompile Bash to avoid Shellshock (the remote exploit CVE-2014-6271 and CVE-2014-7169)?

Given that Bash 3.2 (the version shipped by OS X) is vulnerable to the remote execution exploit known as "Shell Shock" (CVE-2014-6271 and CVE-2014-7169) how do I rebuild Bash and secure my system ...
user avatar
  • 2,675
275 votes
4 answers
144k views

What are the practical differences between Bash and Zsh?

With the news that Catalina will default to Zsh instead of Bash, I'm finding lots of results telling me about the switch, and that it may cause problems with shell scripts, but I'm not familiar enough ...
user avatar
  • 4,892
104 votes
2 answers
175k views

Why doesn't Mac OS X source ~/.bashrc? [duplicate]

I found a lot of people figuring out why instruction similar to this : Put X to your ~/.bashrc and you can do Y don't work. It always turns out that Mac OS X's bash's startup files (or Mac's Bash ...
user avatar
32 votes
5 answers
28k views

My Automator Workflow fails because it fails to find the git command within the 'Run Shell Script' command? Need help

I have an Automator workflow and one of the actions is to clone a repository. Here's the code for the 'Run Shell Script' action. The command is run within the Bash shell /bin/bash if that matters: ...
user avatar
  • 433
18 votes
6 answers
58k views

I broke my PATH by editing my ~/.bash_profile and Bash will not recognize most commands

in .bash_profile I accidentally set the path to: PATH="~/Tools/apache-maven-3.3.3/bin" and now the default path is gone. Nothing in Terminal works anymore: Korays-MacBook-Pro:~ koraytugay$ ls -bash:...
user avatar
  • 1,234
262 votes
13 answers
500k views

Why doesn't .bashrc run automatically?

I put some alias commands in my .bashrc file, so that they might be loaded everytime I open a new Terminal window. Yet this doesn't happen. I have to select run script: in the Terminal>Preferences&...
user avatar
  • 3,993
38 votes
8 answers
32k views

SRM gone in macOS Sierra (10.12)

I've just updated to macOS 10.12 and when I try to execute srm in Terminal, it says -bash: srm: command not found. Is srm removed? How to fix this?
user avatar
122 votes
7 answers
85k views

Update bash to version 4.0 on OSX

Is it possible to actually update bash to version 4.0 in OSX Yosemite? echo $BASH_VERSION 3.2.57(1)-release This article and this thread refer to the same question, but they install a new shell side-...
user avatar
  • 1,333
69 votes
2 answers
83k views

Run AppleScript from bash script

If I wanted to run an AppleScript from within a bash script I could call a file with the list of commands that I require to execute. #!/bin/bash {some commands} osascript file.scpt {other commands} ...
user avatar
41 votes
7 answers
79k views

How to set system-wide environment variables

We used to use /etc/environment to set system-wide environment variables on Mountain Lion. However, it seems this file is no longer read. Ideally the solution should apply to all users, and we need it ...
user avatar
  • 788
23 votes
4 answers
17k views

Change file association in terminal?

Is there a method for associating file types with applications via terminal? I thought ~/Library/Preferences/com.apple.launchservices.plist might do it, and I also have seen: Why is a command line ...
user avatar
  • 375
1 vote
3 answers
3k views

How to add the PATH for mysql bin on Mac?

I want to add the PATH for mysql.exe on my Mac. I tried this via terminal, but $ vi.bash_profile vi.bash_profile command not found. does not work. I tried this for generating the bash_profile to ...
user avatar
91 votes
4 answers
29k views

Is it safe to upgrade Bash via Homebrew?

I'm new to OS X. I'm running OS X Lion on a MacBook Pro. Is it safe to upgrade the bash shell using Homebrew: $ brew install bash If safe, how do I make it the default instance of the shell I run ...
user avatar
  • 1,013
147 votes
4 answers
65k views

Suppressing "The default interactive shell is now zsh" message in macOS Catalina

I know Catalina uses zsh as the default login shell and interactive shell, but it is very annoying when I open iTerm.app or run command with /bin/bash, it shows verbose message like below: $ /bin/bash ...
user avatar
  • 3,609
28 votes
4 answers
203k views

How to create ~/.bash_profile and ~/.profile

So, I don't have .bash_profile neither .profile in my home folder. How do I create them? After that, what should I do so every time I open the terminal these files get read?
user avatar
  • 2,154
58 votes
5 answers
29k views

Are Macs vulnerable to the Bash shellshock bug?

Red Hat recently announced a major security-related bug in the Bash shell. Some are calling it the "shellshock" bug. Since OS X is built off of Unix, is it vulnerable to attacks that exploit this bug? ...
user avatar
  • 2,863
32 votes
2 answers
50k views

Using bash/terminal to get number of battery recharge cycles

I would like to get the number of recharge cycles using bash (terminal commands). I understand the following command will display all of the battery data, but I want the cycle count on its own ioreg -...
user avatar
  • 1,141
22 votes
5 answers
79k views

How to reset $PATH?

I was trying to add something to $PATH and it went totally wrong. I now can't run any commands such as ls. I've looked at this answer and used the following lines: PATH=/usr/bin:/bin:/usr/sbin:/...
user avatar
  • 451
20 votes
5 answers
42k views

Turn Wifi off/on with a single key?

Is there a way to assign the WiFi on/off function to one of the function keys like F4 that I otherwise never use? I assume Applescript would be required. However I may want to use a BASH script ...
user avatar
  • 303
13 votes
3 answers
22k views

How do I restart the cron service on OSX?

ProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G31 $ sudo cron restart cron: cron already running, pid: 257` None of the answers in here https://stackoverflow.com/questions/...
user avatar
  • 738
6 votes
1 answer
12k views

Why is a command line change to ~/Library/Preferences/com.apple.LaunchServices.plist not effective immediately?

When the Info window of Finder is used to associate files of a particular type with an application: the preference is effective immediately. When Terminal is used to make a comparable addition to ~...
user avatar
14 votes
1 answer
7k views

Unable to set DYLD_FALLBACK_LIBRARY_PATH in shell on OSX 10.11.1

In shell scripts used for unit testing with dynamic libraries in a directory other than the typical @rpath, I have previously been able to set DYLD_FALLBACK_LIBRARY_PATH to set the directory ...
user avatar
  • 141
9 votes
2 answers
11k views

Terminal not displaying colors for directory listings

I don't know why my bash session doesn't show colors. I have tried Terminal as well as iTerm. I have tried: ls -G Setting export CLICOLOR=1 and export LSCOLORS=GxFxCxDxBxegedabagaced Using different ...
user avatar
  • 211
5 votes
2 answers
873 views

Is there a macOS equivalent of the Windows assoc command?

I am looking to change a file association on the Mac using some sort of script. I know that I can do something like that in Windows using the assoc command. Is there something scriptable on macOS ...
user avatar
  • 2,927
4 votes
1 answer
4k views

ffmpeg working from command line in Terminal but not in an Automator shell script!

I have just compiled my own copy of ffmpeg on my system and it's located in the following path: /opt/local/bin/ffmpeg When I run the following command in Terminal.app, it runs smooth: ffmpeg -i /...
user avatar
2 votes
1 answer
1k views

Bash Script which calls osascript stops working when run by launchd

I am trying to troubleshoot a problem with a bash script that gets called by launchd. Here's a quick summary Calling the script manually by itself works fine with no errors. Within the bash ...
user avatar
  • 82.2k
459 votes
15 answers
271k views

git auto-complete for *branches* at the command line?

On my Linux machine I have autocomplete for branches with Git. [Note we are talking about git branch completion, not bash completion (e.g. commands, files, etc). Thus NOT Lane's answer at all] For ...
user avatar
387 votes
5 answers
307k views

What is the difference between .bash_profile and .bashrc?

To make an alias for the Terminal in OS X, you can either put the aliases in .bash_profile or .bashrc. What is the difference between the two and why would I choose to put aliases in one and not the ...
user avatar
30 votes
6 answers
12k views

Auto-updating Homebrew

i'm currently using the Homebrew package manager and my question is: is possibile to write a bash's script in order to execute brew update and eventually brew upgrade whenever opening a shell for the ...
user avatar
  • 463
44 votes
7 answers
145k views

Using terminal to get current fan speed? [duplicate]

I would like to view the current fan speeds of my MacBook and iMac using terminal. I've found that running spindump then cat /tmp/spindump.txt | grep "Fan speed" will show it, but that's very slow and ...
user avatar
  • 1,141
40 votes
7 answers
149k views

How to add MySQL to $PATH variable to resolve "mysql: command not found"?

I installed MySQL on my Mac, and now I would like to add it to my $PATH variable. I want to be able to type mysql anywhere. I tried adding the following to my .profile file: export PATH=${PATH}/usr/...
user avatar
  • 579
11 votes
1 answer
10k views

Locating an app by its bundle identifier from the command line

I am looking for a way to find an app's location on the system from the command line using its bundle identifier. I can open it like this: open -b 'com.zerotier.ZeroTierOne' ... where com.zerotier....
user avatar
16 votes
7 answers
6k views

Is there a bash command to check to see if Time Machine has finished backing up?

I'm writing a script that will rsycnc my Time Machine directory to a remote server using ssh. I've switched from a shell script to an AppleScript and then back to an Apple script and I don't really ...
user avatar
  • 173
15 votes
5 answers
33k views

How do I edit bash shell terminal history?

I entered a password in a command line pro or in a terminal window by mistake and do not want to remove my whole history. My shell is bash. How do I edit my bash history in Mac OS X?
user avatar
8 votes
3 answers
4k views

Can man pages be converted to html and/or pdf format?

The command man bash produces a lot of output. What I desire would be to either search the results or print the results to paper. So, is there a way to convert a man page to a html and/or pdf document....
user avatar
7 votes
2 answers
6k views

How to stop InternetSharing overwriting /etc/bootpd.plist

I set up a /etc/bootpd.plist so as to protect my wireless network, and to manage statically attributed IP addresses. Unfortunatly, when I start InternetSharing, this file is overwritten by a plist ...
user avatar
  • 11.3k
19 votes
2 answers
7k views

Why is there a left bracket before my bash prompt?

I've notice that after I execute commands, a left bracket character will appear before the previous line. It seems to be partially dependent on what's in $PS1. I've tried unsetting $PROMPT_COMMAND and ...
user avatar
4 votes
3 answers
1k views

Log file that `sudo last` accesses?

The bash command last (needs sudo) prints out logs, which contain information on when different users log in/out of the shell. I have been looking for the file that stores this information, that last ...
user avatar
7 votes
2 answers
2k views

Are Bash, Bourne, and Korn shells compiled into one binary in OSX?

On OSX 10.8, if you compare the binaries for bash, sh, and ksh, a few different shell options, they are the same size. If you take it further and cmp the binaries, there seems to be only a single-...
user avatar
  • 193
6 votes
3 answers
2k views

How can I rebind keyboard keys in OS X?

I need a custom keyboard shortcut for back slash \. I have created ~/Library/KeyBindings/DefaultKeyBinding.dict and put this in it: { "@ö" = ("insertText:", "\\"); } It is supposed to trigger ...
user avatar
  • 8,246
5 votes
3 answers
5k views

Is it possible to identify what the parent program/app is from a running process?

I'm able to find processes using top or ps. That's no problem. Sometimes I find that some processes are taking up a lot of memory or cpu and I'm trying to identify what the root program is. For ...
user avatar
  • 407
1 vote
1 answer
758 views

How can I set Last Modified Date of file after using HandbrakeCLI to convert a file?

Running this on OS X Lion. I'm batch converting several hundred home movies using Handbrake CLI. I'd like to set the last modified date and created date to that original file. I'm using the ...
user avatar
  • 11
1 vote
2 answers
7k views

Setting a firmware password

Currently trying to use a script (preferably shell) to setup the firmware password on a fresh OSX install. I obviously found this: http://osxdaily.com/2014/01/06/set-firmware-password-mac/ which ...
user avatar
118 votes
5 answers
305k views

Getting all files from a web page using curl

I would like to get all files from the web page below using curl: http://www.ime.usp.br/~coelho/mac0122-2013/ep2/esqueleto/ I tried: curl http://www.ime.usp.br/~coelho/mac0122-2013/ep2/esqueleto/ It ...
user avatar
  • 2,154
137 votes
10 answers
654k views

How do I set environment variables on OS X?

I have always difficulties setting the Environment variables in OS X like JAVA_HOME, M2_HOME or PATH. How to set these on OS X Mavericks? I did some research but the answers I've found didn't really ...
user avatar
  • 1,599
87 votes
17 answers
64k views

How to get a notification when my commands are done

I'm running a series of commands on the command line that takes approximately twenty minutes to complete. I'd like to see some sort of notification on my Mac when these are finished so I don't need ...
user avatar
61 votes
4 answers
45k views

How do I reset the scrollback in the terminal via a shell command?

When using Terminal.app, you can clear the screen by using the shell builtin clear or by pressing ^+L (Control-L). However, all this does is push the current screen content back one screen height ...
user avatar
  • 23.3k
28 votes
2 answers
14k views

How to use bash as default shell

I am running El Capitan 10.11.3 with bash version 3.x so I decided to update bash via: brew install bash Brew places the new bash under /usr/local/Cellar/bash: brew info bash bash: stable 4.3.42 (...
user avatar
  • 383
19 votes
4 answers
7k views

Updating modifier key mappings through defaults command tool

I am trying to automate the inital setup of my macbook, that includes installing software and changing OS X configuration to my needs. I have tried to update the modifier keys with defaults, the ...
user avatar
  • 191