I've seen some people on the internet have emoji for their hostname which makes the terminal much more readable when you scroll up to see history.
I have tried Terminal -> Preferences -> Profile and looked at all the options, but there's no option for adding an emoji.
sudo scutil --set HostName pasteYourEmojiHere
For example:
sudo scutil --set HostName ๐
Related
"dhcp35:~ user$" has appeared in my mac terminal instead of the usual "My-MacBook-Pro:~ user$".
Is this an indication of anything malicious?
I've been messing around cliclick to automate key presses from terminal, so not sure if this has resulted from my messing or from something I might have downloaded.
dhcp is documented as part of the terminal server user guide, but I can't work out the significance.
I suspect you are connected to a DHCP server that sets the hostname along with giving an IP assignment:
https://www.rfc-editor.org/rfc/rfc2132#section-3.14
One way to stop the hostname from changing is to do the following from a Terminal window (assuming you want to name your computer donald). You may need to preface these commands with sudo:
scutil --set ComputerName donald
scutil --set HostName donald
scutil --set LocalHostName donald
I have not had a similar issue in Windows (10) and nothing I've searched on docs seems to indicate why, if this does not work, that that is the case
I open up terminal and edit /etc/hosts (which I've done many times on a PC and a few years back on an OSX too)
Just for grins if that doesn't work I type in sudo killall -HUP mDNSResponder
Then for more grins I reboot
This has absolutely no effect. Can anyone point me to why? Thanks.
UPDATE: The embarrassing fact of the matter is that the lines I entered in /etc/hosts were in reverse, i.e. domain first, as:
mydomain.com 192.168.33.10 #wrong
192.168.33.10 mydomain.com #what it should have been
The accepted answer, however, is well-written and appreciated.
I've seen two common problems with using /etc/hosts on macOS (/OS X):
Incorrect formatting: each entry in the /etc/hosts file must be an IP address followed by a space or tab, followed by the name, then a linefeed at the end of the line. Try printing the hosts file with cat -vet /etc/hosts to make normally invisible characters visible. Each line should look like one of these:
127.0.0.1^Iwww.example.com$
127.0.0.1 www.example.com$
(The "^I" is a tab, and the "$" is the linefeed at the end of the line.) It's also ok if the entry has multiple names listed (also separated by spaces or tabs).
If you see a "^M" (carriage return) just before the "$", you have DOS/Windows formatted text and you need to remove the carriage return(s).
Incorrect testing: Don't use the command-line tools dig, host, and nslookup, since they all test DNS directly and therefore bypass the /etc/hosts file. Browsers sometimes cache things, which can give misleading results. The "right" way to test the system's name resolution system is with the dscacheutil command:
dscacheutil -q host -a name www.example.com
...but since that's annoyingly verbose, I tend to just use ping, and see what address it says it's going to test.
I came across this thread to try and solve the same issue on macOS Catalina and was not successful. This is because macOS Catalina has another thing going; it will only make changes in the hosts file effective if you change them as the root user (this is not done with the sudo command) !!
By default there is not a root user on your system so here's a link with a step by step guide to do so:
https://support.apple.com/en-us/HT204012
then I was able to:
su
nano /etc/hosts
for more information:
https://discussions.apple.com/thread/250805304
Below steps worked for me
flushing DNS sudo killall -HUP mDNSResponder (or kill DNS in activity monitor and let it reload)
2.Changing read-write permissions of /etc/host file should be -rw-r--r-- .Use commands $ sudo chmod g+r /etc/hosts and $ sudo chmod o+r /etc/hosts
Adding entry u want to add in host file with ipxxx.xx.xx.com
moved these 2 lines in the end
255.255.255.255 broadcasthost
::1 localhost Administrators-MacBook-Pro.local
Step 1 again
I'm trying to use the bash shell to get a wifi profile for a certain network, and from that, the password
What I'm looking for is basically a mac equivalent to netsh wlan show profile name="name" key=clear, which gets exactly what I want with windows
I have looked into the airport and networksetup commands on mac, but still have yet to find something that will either show me the network profiles or, even better, what's inside.
Does anyone have any ideas or at least something to point me in the right direction?
If it's okay to use a Node.js script for this, you might have a look at wifi-password-cli which does exactly what you want:
$ wifi-password --help
Usage
$ wifi-password [network-name]
Example
$ wifi-password
unicorns
$ wifi-password foo-network
foosecretpassword
(Sample taken from the tool's documenation)
To use it, simply run (supposed that Node.js has already been installed on your system before):
$ npm install -g wifi-password-cli
The simple way is:
security find-generic-password -ga "ROUTERNAME" | grep "password:"
Add the WIFI name you are connected in the place of ROUTERNAME
Simply run the command from terminal app
security find-generic-password -wa <WIFI_NAME>
Replace <WIFI_NAME> with your Wifi Name.
A prompt will ask you for username and password.
I wanted to make a shell script that connects to a hidden wireless network on my macbook pro by creating a network. However, I only want to connect to that network when I want to and to prevent airport from connecting automatically I'll have to delete the network's password from keychain.
So far I have:
networksetup -setairportnetwork en1 $ssid $networkpassword
networksetup -removepreferredwirelessnetwork en1 $ssid
Im also aware that in OSX 10.7 the security command can modify the keychain.
Anyway I would appreciate any help someone can give me. I'm also willing to use applescript or something else if it works. Thank you.
I figured it out. The command I used is:
sudo security delete-generic-password -l $ssid "/Library/Keychains/System.keychain"
sudo was needed because this keychain is located in the systems library. security also contains a lot more delete and useful commands and you can specify how you want to indicate the location in this command.
edit: I was having some trouble using this command and went back and learned I could use another command to not remember the network at all which I would have used before if I had found it. With this option you can do a wealth of things with your adapter along with the networksetup option.
Here is my final script which first runs as root. then it changes the system preferences to not remember new networks. Then it disconnects from any current networks. Then it adds the new network. Lastly, it makes the system remember new wifi networks.
sudo -i
sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport prefs RememberRecentNetworks=NO
sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -Z
networksetup -setairportnetwork en1 $ssid $password
sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport prefs RememberRecentNetworks=YES
I've been trying to figure out how to use postfix on my Mac and something has gone horribly wrong and I can't seem to fix it.
I believe the problem is related to starting Postfix.
Basically, the Mac seems to refuse to change its hostname. In bash, the user appears as "admin#(null)", if I type 'hostname' I'm given "(null)" also.
Changing the hostname in Sharing from System Preferences causes the second example to change (where it says, for example, "Other users can access shared folders on this computer, and administrators all volumes, at afp://null/ or โlion2โ.") but the first stays as null.
I've even tried /etc/hostconfig manually setting hostname but nothing works.
Is there somewhere else the hostname is trying to be set but is perhaps corrupt? Or contains an invalid character or something?
This is causing Postfix not to work and report:
postfix: warning: valid_hostname: invalid character 40(decimal): (null)
postfix: fatal: unable to use my own hostname
Please, I really hope someone can help me fix this. I've been trying for hours now.
Cheers,
Scott
Have you tried scutil?
sudo scutil --get pref will show the current value and sudo scutil --set pref name will set the value to name. pref can be one of these:
ComputerName The user-friendly name for the system.
LocalHostName The local (Bonjour) host name.
HostName The name associated with hostname(1) and gethostname(3).
Here's what I get on my machine:
$ sudo scutil --get ComputerName
SteveBook2
$ sudo scutil --get LocalHostName
SteveBook2
$ sudo scutil --get HostName
HostName: not set
You should have tried running /bin/hostname directly to set the hostname on the unix/bsd layer, the values from scutil are SystemConfiguration settings which is a higher layer that unix is oblivious to.
It is perfectly normal for sudo scutil --get HostName to return not set even if running /bin/hostname shows you a hostname.
To set the hostname run sudo hostname Foo.bar (this is basically identical to sethostname() BSD call in the code given by another answer)
Optionally you could then run sudo scutil --set HostName Foo.bar to keep the SystemConfiguration settings in sync
NOTE:
The HostName in SystemConfiguration can be different from the LocalHostName and ComputerName , it can also be different from what /bin/hostname returns but it is best that they are all in sync, so you could also do :
sudo scutil --set LocalHostName Foo
sudo scutil --set ComputerName Foo
All other answers and help was much appreciated, however after much investigation, the problem appears to lie with my router and iMac: router not allowing the iMac to change its hostname client-side OR possibly sending a weird hostname to the iMac for it to use.
If you run this tiny program before starting postfix, does it work?
#include <unistd.h>
int main(int argc, char* argv[]) {
char host[] = "newhostname";
sethostname(host, sizeof(host));
return 0;
}
I don't presume to know what else might depend upon your old hostname -- do some testing on all your services after running this.
Details at: http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/gethostname.3.html
Update
To compile and run this little program, save its contents to a file (/tmp/newhostname.c will do) then run:
cd /tmp
make newhostname
sudo ./newhostname
At least I assume your make(1) knows how to compile from C sources to runnable binaries with default rules.
If the compiler isn't already installed maybe someone else will have a better idea.