Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
11-28-2016, 12:45 PM
|
#1
|
Member
Registered: Aug 2012
Posts: 316
Rep:
|
how do I treat a special character in my password as not
hi guys,
i'll start by prefacing my question that it is specific to an OSX version of bash if that makes any difference or not I don't know.
from the command line in an OSX terminal i want to issue a command that requires a sudo password, and lets say my sudo password is "abc&123"
sudo options command
gets me back a line with a little key on the far right side prompting me to enter my password. when i do it doesn't read my full password as abc&123 it splits my password at the & and then it doesn't accept the sudo command.
if i change my password to "abcand123" the sudo command works just fine and the command is executed
question: how can i tell osx to ignore the & character as a "special character" when it's part of my password. i know the easy fix is to just use "abcand123" password, but to help prevent hacking, I'd like to keep my password as complicated as possible and use "special characters" in it.
btw, I have tried to google this but I can't seem to find an answer there.
thanks!
Todd
Last edited by atjurhs; 11-28-2016 at 12:46 PM.
|
|
|
11-28-2016, 12:47 PM
|
#2
|
Senior Member
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278
|
Well, it all depends on how you are feeding it/redirecting it,.. but a possibliity is to escape the & with a slash \:
Storing passwords in scripts and commands like this is a terrible and insecure idea though. Just FYI.
|
|
|
11-28-2016, 12:49 PM
|
#3
|
Senior Member
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039
Rep:
|
I think to OP is saying they type "sudo command" and get prompted for the password but it is not accepting the password
---------------------
Just tested on my Mac and it doesn't seem to have an issue with the & symbol for me
atjurhs if you can provide more information about what you are trying to do, I can perform a more specific test
Last edited by Disillusionist; 11-28-2016 at 01:00 PM.
|
|
|
11-28-2016, 01:09 PM
|
#4
|
Moderator
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,892
|
I think whichever the case may be, szboardstretcher at least has it correct in pointing out that some form of escape needs to be used. Either the backslash, putting the password within quotes, single or double. It depends what the OSX accepts for escape characters, likely the backslash or at least this is what a google search tells me.
|
|
|
11-28-2016, 03:45 PM
|
#6
|
Senior Member
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278
|
That's from 8 years ago. Is this really, honestly, still a bug/problem in Apple? Amazing!
They should take a page from Unix where this was figured out in the 1970s. Almost 45 years ago.
|
|
|
11-28-2016, 03:59 PM
|
#7
|
Senior Member
Registered: Dec 2004
Posts: 1,056
Rep:
|
I wonder if the command you are running might be a poorly-written shell script which tries to feed your sudo password to some other script without quoting or escaping the password, thereby creating a broken command somewhere in its guts.
For example, the mysql command lets you specify a password on the command line when calling a command. This is not recommended if you are typing commands in a terminal because the password might end up in your .bash_history file, which stores all the commands you enter. However, I recently wrote a script that prompts the user for their database password and then formulates mysql commands using that password. My script is "poorly written" in that it suffers from the very problem I'm trying to describe. I.e., assuming your password is abc&123 then my script constructs a mysql command that looks something like this:
Code:
mysql -u root -p abc&123 db_name < db_file.sql
If I enter a password that contains an ampersand, then that ampersand might actually get interpreted by the command line as a BASH operator that says "run this process in the background" or something like that. I'm not sure at all, but the command would be broken into these two commands
Code:
mysql -u root -p abc &
123 db_name < db_file.sql
The first command would be executed in the background and would be rejected by mysql as an improperly formulated command. The second would fail with a "123: command not found" or something.
I could be wrong.
|
|
|
11-28-2016, 04:22 PM
|
#8
|
Member
Registered: Aug 2012
Posts: 316
Original Poster
Rep:
|
Dillusionist, that is exactly what I'm saying
sneakyimp, as far as i can tell, that's exactly what is happening
|
|
|
11-28-2016, 04:31 PM
|
#9
|
Senior Member
Registered: Dec 2004
Posts: 1,056
Rep:
|
Quote:
Originally Posted by atjurhs
Dillusionist, that is exactly what I'm saying
sneakyimp, as far as i can tell, that's exactly what is happening
|
If you could edit the script you are executing, you could add quotes around the password any time it gets fed into some attempt to formulate a command. That might fix the ampersand problem but would not fix the problem if your password contains a quote in it. You could also change your password
|
|
|
11-28-2016, 04:32 PM
|
#10
|
Senior Member
Registered: Dec 2004
Posts: 1,056
Rep:
|
If you didn't write the script, you should give a but report to whoever did.
|
|
|
11-28-2016, 04:33 PM
|
#11
|
Member
Registered: Aug 2012
Posts: 316
Original Poster
Rep:
|
next problem...
how do i modify my .bash file in osx?
in linux i would simple enter the command texedit .bash from my home directory
if i try open -e .bash from my home directory it says that file does not exist, if i try the same command with .bashrc i get the same answer does not exist.
when i try to ls .* it also does not list a .bash or .bashrc file
where else could my .bash file be located, or what else am i doing wrong?
i want to set up some aliases like:
up = 'cd ..'
ll = 'ls -alhf'
and others.
Last edited by atjurhs; 11-28-2016 at 04:37 PM.
|
|
|
11-28-2016, 04:37 PM
|
#12
|
Senior Member
Registered: Dec 2004
Posts: 1,056
Rep:
|
My guess is that you are not actually running BASH on your OSX machine. Also curious why you are editing this file as it doesn't sound like that's where the problem lies.
Some searching yields:
Quote:
So turns out that on Mac OS X Snow Leopard as well as Mac OS X Lion, the file that's loaded is called .profile, not .bashrc.
What you want to do is create a file in ~/.profile and call it .profile (if it doesn't already exists).
Put whatever information you needed to load with each instance of bash there (Thanks, thepurplepixel).
A couple of side notes:
The period in front of the file marks it as invisible to Finder and the ls command by default. To list invisible files using the ls command from Terminal, use the -a as a parameter as such: ls -a
The ~ symbol stands for /Users/YourUserName where YourUserName is your username's shortname.
Edit: Chris Page notes (correctly) that whatever you place in a .profile file will apply to whatever shell you're using (i.e. zhs, bash, et cetera). If you want the contents to affect only the bash shell, place the contents in a .bash_profile file instead of a .profile file.
|
|
|
|
11-28-2016, 05:19 PM
|
#13
|
Member
Registered: Aug 2012
Posts: 316
Original Poster
Rep:
|
thanks sneakyimp!
i forgot to include the -a in my ls comand
actually that's one reason why (on my linux box at work) i have an alias ll = 'ls -alhf' and then i never type ls i just always type ll so i don't forget all the options...
well creating a .bash_profile or just a .profile in osx, osx does appear to apply the command when opening a new terminal, however i get lots of errors
note, it is a bash shell because the is a .bash_history file and a .bash_sessions directory
can someone reccommend an osx specific forum like linux questions, or is there a osx specific forum here, i haven't found one
|
|
|
11-28-2016, 06:41 PM
|
#15
|
Member
Registered: Aug 2012
Posts: 316
Original Poster
Rep:
|
thanks snaeky!
i found the answer on how to the modify your osx "bash shell"
|
|
|
All times are GMT -5. The time now is 07:37 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|