Cannot edit bash_profile on Mac OsX [closed] - macos

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am using MacOSX Snow Leopard 10.6.8.... I am the only user on this machine and I should be admin.
I trying to edit my bash_profile to give it this simple alias:
alias server=' open http://localhost:8000 && python -m SimpleHTTPServer'
however when I use the terminal and type: vim ~/. bash_profile and paste in this alias I get message saying I cant save due to permissions.
So then I show all hidden files and go to fix the permissions on this file but the file is all grayed out.... I cant change anything. What can I do??

You need to open it with sudo.
sudo vim ~/.bash_profile
The file appears greyed-out when you show hidden files because Mac OS X displays hidden files as greyed out so you can differentiate them from non-hidden files. You should still be able to edit the permissions on the file (you don't need to, though).
If you want to be able to edit without being root, you can change the owner of the file.
sudo chown your_user_name ~/.bash_profile

Related

tcpdump not setting paths correctly [duplicate]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
How to edit PATH variable on mac (Lion). I cannot find any file where I can add paths. can someone guide me about it?
Whats the file name? .profile or .bash_profile???
and where I can find it?
I have tried
echo 'export PATH=/android-sdk/tools:$PATH' >> ~/.profile
Open and edit /etc/paths using any text editor.
$ sudo vi /etc/paths
(editing text files with vi)
Note: each entry is separated by a new line
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
Save and close the file. Then restart your terminal.
Based on my own experiences and internet search, I find these places work:
/etc/paths.d
~/.bash_profile
Note that you should open a new terminal window to see the changes.
You may also refer to this this question
environment.plst file loads first on MAC so put the path on it.
For 1st time use, use the following command
export PATH=$PATH: /path/to/set
You could try this:
Open the Terminal application. It can be found in the Utilities directory inside the Applications directory.
Type the following: echo 'export PATH=YOURPATHHERE:$PATH' >> ~/.profile, replacing "YOURPATHHERE" with the name of the directory
you want to add. Make certain that you use ">>" instead of one ">".
Hit Enter.
Close the Terminal and reopen. Your new Terminal session should now use the new PATH.
Quoted from ketio.me tutorial (archived copy).
use
~/.bash_profile
or
~/.MacOSX/environment.plist
(see Runtime Configuration Guidelines)

How to change default directory in Bash for Windows 10? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
How can I change the default directory of windows bash to a folder of my choosing?
EDIT: I guess I should have been more clear. When I startup Bash I want it the directory to be in a location of my choosing like Desktop or something. How do I go about setting a default directory?
If you want change the directory your bash prompt is starting in, you can edit your .bashrc file. At the bottom, add:
cd ~
This will go into your home directory. (you can actually do just cd, but I it's clearer to add the ~ IMO)
To edit, you can use vim. If you don't know how to use it, you can always use nano for the time being, but you really should have a look at it, it's really powerful.
$ nano ~/.bashrc
This will open nano in "full console". At the bottom, you have the few commands you can use (^ means control) Do your changes, hit ctrl+o to save the file (write the file). It'll ask you where to write, by default, it's the right location, just hit enter and the .bashrc file will be saved. Then, you can press ctrl+x to exit.
Steps to set default directory for Bash on Ubuntu on Windows to a folder -
Open Bash on Ubuntu on Windows.
cd ~ to go to home directory of Ubuntu
Type edit .bashrc and enter at the Bash. This will open the file in vim.
Use Down Arrow or Page Down key on keyboard to go to the end of the file (there's a helpful progress bar at the bottom right corner of the Bash). At the end of this file, you will find cd ~, replace cd ~ with your desired location.
Save the .bashrc file. To save the file, click esc and then type :wq and click enter.
Note:
To access your hard disk location make sure you include the mount directory first.
So if want your Bash to open at C:\dev whenever you open the Bash. You need to replace the cd ~ with cd /mnt/c/dev at .bashrc file at Ubuntu home directory.
Just enter echo "cd ~" >> ~/.bashrc. This will append "cd ~" to your .bashrc.
.bashrc is executed everytime you start a(n interactive) bash instance.

Setting an environment variable in Mac OSX 10.8 [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I feel quit stupid asking this, but I am completely unable to set an environment variable in Mac OSX 10.8.
I'd greatly appreciate some specific instructions on which files to edit, what is the syntax to place in the file, etc.
I am trying to do some web development using Arc, which requires racket. I am getting an error from arc that 'racket' isn't a recognized command. I am only able to run racket commands when I am in Racket's bin directory (here is the location of my racket directory - /Applications/Racket v5.3.3/), which suggests to me that an environment variable has not yet been created for racket (but I could be wrong).
Thanks in advance.
Have you tried editing your profile? If you are using bash, edit the .bash_profile file in your home dir. You will have to insert a line like this:
export PATH="$PATH:/Applications/Racket\ v5.3.3"
You have to add the path to Racket's bin/ directory to the PATH environment variable. Open the file ~/.bash_profile using your text editor of choice, look for a line that looks similar to this (the <paths> part is just a placeholder for the real paths) , if it doesn't exist, just add it:
PATH=$PATH:<paths>
At the end, add a : and the path to Racket's bin/ directory, something like this:
PATH=$PATH:<paths>:/Applications/Racket\ v5.3.3/bin
Replace the v5.3.3 version number with the appropriate version of your installation. Finally, make sure that this line appears somewhere in the file:
export PATH
Save it, and you're ready to go!

mkdir -p cannot create directory `/DirName': Permission denied [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm trying to create a directory in a shell script:
mkdir -p DirName
but I always get the same error:
cannot create directory `/DirName': Permission denied
If I run the same command directly from the shell instead of using the scripts, that works perfectly.
any idea?
Thank you! :)
If you're going to use the -p option, you need to specify the full path
mkdir -p /some/path/here/DirName
I suggest listing the full path (If you plan on your shell script to change locations).
If your shell script isn't going to change locations (you're not going to move it somewhere else later), I'd use:
mkdir ./DirName
These should all behave similarly to you creating the directory in the shell.
You are trying to create a directory in the root of the filesystem (/DirName) instead of in the current directory (Dirname or ./Dirname). You don't have access to write to the root.

Copy shell script and preserve permissions [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a small shell script that starts a program when I double-click it. (I have set the permissions to allow executing the script).
I want to be able to copy that script to another computer so that the new user can double-click it without needing to know anything about chmod or permissions. But I can't find out how to preserve the execute permission when I copy the file.
I can usually find answers with Google but this has me defeated - I guess I am not expressing my question properly.
Thanks
Use rsync or tar.
rsync -p file user#host:destdir
plus other options you might need.
Or
tar cvzf file.tar file
then copy (or email, etc.) file.tar to the other machine and extract the file:
tar xpvzf file.tar

Resources