Command line prompt changed in local network - bash

I was sitting in my university and working with terminal (mac os, bash). So far i connected to the local wi-fi and after certain amount of time i found out that my cli prompt line changed from default to h55
I printed:echo "$PS1"
it showed, what it should: \h:\W \u\$
Also, my friend told me, that it happen to him too.
I googled that connecting to local network can cause this behaviour
So i wonder, how it works, that connecting to local network can change my prompt line?
Thanks in advance.

\h means your current hostname. When you connect to a network via dhcp, it will often try to set your hostname for you, and I'm guessing that's what happened here. You could run hostname to confirm what your current hostname is.
Also, I'm assuming that only that hostname part of the prompt changed to h55, not the entire thing. If that is wrong, please update your question with "before" and "after" examples of your prompt.

On Mac
I prefer to shorten this to a simple dollar sign ($) in order to free up space.
To change your default command line prompt, follow these instructions:
Navigate to your home directory: cd ~
Create a file called .bash_profile: vi .bash_profile
Add the following line (press i) export PS1="$ "

Related

Stata is not seeing environment variables needed for ODBC connection

I use the Simba ODBC driver (2.3.2) to connect Stata to BigQuery from my macOS laptop. I recently upgraded to Big Sur (11.2.1) and lost the ability to do this.
I am using iODBC and I am able to test the DSN successfully. I was also able to get everything to work in macOS 10.15.7 just fine (on a different machine).
The problem appears to be that Stata is not seeing the DYLD_LIBRARY_PATH environment variable that I have defined in my .bash_profile profile according to the driver configuration instructions.
In Stata, I get this error:
. odbc list
The ODBC file libiodbc.dylib could not be found on this system.
Setting the unix LD_LIBRARY_PATH environment variable may correct this error.
r(680);
I am able to set this in bash:
$ echo $DYLD_LIBRARY_PATH
:/usr/lib/:/usr/local/
But that does not seem to work since:
$ printenv | grep 'DYLD'
is empty. I suspect something in Big Sur is preventing this environment variable from being set.
Happy to try anything to fix this.
To fix this, you need to disable SIP, which keeps the $DYLD_LIBRARY_PATH environment variable from being defined without issuing a warning.
To disable SIP:
Restart your computer in Recovery mode by holding down Command(⌘)-R once it powers off. Press that until you see the Apple icon and a progress bar.
From the Utilities menu, select Terminal.
At the prompt, type the following command and then press return: csrutil disable
Terminal should display a message that SIP was disabled.
From the Apple menu, select Restart.
Now you need to define an environment variable that points to the folder with libiodbc.dylib. To figure out where that folder is, type this in Terminal:
find / -name libiodbc.dylib 2>&1 | grep -v "find: "
Using your favorite text editor (like pico, emacs, or vi), you need to edit your .zshenv file. Open this file (or create it if it does not exist) with
pico ~/.zshenv
Using the first folder from above, define an environment variable by typing this in the file:
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:<FOLDER-PATH-HERE>
Save and exit the text editor.
To apply the changes to the current shell, type source .zshenv.
This should make Stata and BQ play nice again.
zsh is the default shell starting with Catalina, so if you use another shell, you should modify things accordingly. I use bash myself, but I hope my translation for zsh works.
You may need to start Stata from the command line for this to fully work.
Here's the output of the command after the fix above:
I got this to work on Apple Silicon/ Monterey. At some point Apple rolled out SIP (https://support.apple.com/en-us/HT204899) and the env variable LD_LIBRARY_PATH is no longer accessible, so STATA is unable to find the .dylib file.
Instead of disabling SIP, which is strongly discouraged by Apple, load STATA from the command line and set LD_LIBRARY_PATH in the same command.
Something like this (your paths and STATA version may vary)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/homebrew/lib/ && \
/Applications/Stata/StataIC.app/Contents/MacOS/StataIC &

How do I fix a .bashrc that makes it impossible to log into a remote server?

I have just got an account to access a remote server(not root), and I was trying to replace the default bash with zsh.
Then awkward thing happened, I wrote something like exec zsh in bashrc, hoping that it can replace bash with zsh everytime I log in. However, I mistakenly misspelled the path of zsh, now every time I want to ssh my server, it will say .bashrc: line 28: exec: zsh: not found and end the session, I cannot log in my account anymore...
Is there a way to fix it without bothering the administrator? Because it's weekend and I need to use the remote server...
Thanks everyone!
Use sftp to rename the file. This will work so long as sshd is configured to use its internal sftp server implementation, as opposed to an external subsystem.
Marked community wiki as this is a known-off-topic question (not being "unique to software development"; in the future, questions about interacting with a UNIX system as an end-user, as opposed to writing software for same, should be asked at Unix & Linux StackExchange or SuperUser, not StackOverflow.

Unix bash alias not working after start screen

Hi I am having a problem with setting alias in mac after I start the screen command, I have alias for working with git, like
commit=git commit
they work as I expect when I start my terminal (iTerm2), but then sometimes I use screen to have simultaneous instances in remotes servers and virtual machines I work with. After this the alias disappear(command not found).
Does anyone know why or how solve it?
To make the alias work, you must use the alias command. For example, to create an alias in Bash you do:
$ alias commit="git commit"
This works temporarily ie.: in your current shell. In order to make it "stick", you must put it in your ~/.bashrc. That will make it be sourced to all instances of Bash you'll invoke during your terminal session.
When you start screen, it starts a separate Bash too, so you'll be covered.
You write something about VMs. If you need this alias to work there, you must make ~/.bashrc on these VMs to have the same aliases. But that's the other story. You should already know how to achieve what you want.
You need to make sure your aliases are defined in ~/.bashrc to ensure they get included in all logins. You can test this out: edit your ~/.bashrc to include this line:
echo "bashrc"
And then edit your ~/.bash_profile to include this line:
echo "bash_profile"
You'll see when you start screen that only "bashrc" is displayed.
See this question for much more detail on the subject.

gitbash (cache passphrase key): Can't get the ssh-agent to run on windows, modified the .bashrc & .profile

can anyone help, i am on windows and git is working with my origin set to github.
Of course everytime i wish to pull / push or anything i need to supply the passphrase of the key for github.
According to what i have read i need to edit either a ~/.profile or ~/.bashrc and enter some text
see https://help.github.com/articles/working-with-ssh-key-passphrases
I have done this many times, i actually entered it in both files but when i open up a new GitBash windows nothing seems to run (i assume something is suppose to run and ask my for my passphrase according to the link above).
So of course every Push or Pull again asks me for the passphrase every single time.
I am obviosly missing something here can anyone help?
Remembering that i am on windows :-) and using gitbash that ships with git for windows.
Thanks in advance
Well after a lot of investigation, i found this Remember Password, Git bash under windows
which explains exactly what is needed, its different from linux it appears.
This might happen in case You've cloned the repository through the "https" method and now trying to do push/pull the "ssh" way or other way round.
See if this would work out for you :
git remote set-url origin git#github.com:your_account/your_repo.git
On Windows 10 this worked for me
run git bash
touch ~/.profile
start ~/.profile to open .profile
add the following to .profile
#! /bin/bash
eval `ssh-agent -s`
ssh-add ~/.ssh/*_rsa
This is based on this answer. The only difference is that .bashrc did not work, instead .profile worked.

In Mac OSX 10.5, it can't find my Terminal commands sudo, find, etc

I don't know what has happened, but in my Terminal on Mac OSX 10.5 it can no longer find my sudo command, or find command, etc. They are there because if I put /usr/bin/sudo or /usr/bin/find it works fine...
My .bash_login file looks like this:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin$PATH"
My .bash_profile file looks like this:
export PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Python/2.5/site-packages/django_trunk/django/bin:/usr/local/mysql/bin:/usr/bin/sudo$PATH"
I'll say now, I don't really know what I'm doing with the Terminal. I'm just a beginner to it all, and I must of done something for the environment variables (is that what they're called?) to be lost. I presumed I'd just have to make sure the /usr/bin/ path is in my bash files, but they are, and it doesn't seem to work. Please help!
Also, when I do use the /usr/bin/find command, it says "Permission denied" to me, even though I am logged into Mac OSX as the System Administrator account. I don't understand.
Any help would be grand. Thank you - James
It looks like both of your PATH exports are malformed:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin$PATH"
The end bit there won't work. It should be:
export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:$PATH
Notice the colon before '$PATH'? It's important ;)
Also, the double quotes are not necessary.
If this doesn't work, we will need more information. It is possible that something else is modifying your path even after your shell configurations are loaded.
Can you post the results of:
$ echo $PATH
Configuration files are not always a good indication of the current environment variables, since they are modified by many programs and files, all across your system. To see all of your environment variables, you can run:
$ env
This should fix the problem completely and permanently.
first, export environment paths by using below command in the terminal.
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b‌​in
now you have the commands you want. (eg. try ls. You'll see the command is working). But this is only for the current session. If you close the terminal and open a new one, you will have the previous issue. To make this change permanent, use below command,
go to home directory
cd ~
open .bash_profile file in nano / vim (I'm using nano here)
nano .bash_profile
This will open up nano editor. In a new line, paste the following;
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:$PATH
press 'control'+'o' to save (WriteOut) and 'control'+'x' to exit nano.
All done ! Now try the commands.
Check out --- http://www.sweeting.org/mark/blog/2008/05/26/mac-os-x-tip-setting-path-environment-variables
I went trough the same issue and here is how I solved it.
First of all I reverted the file to its original doing this way
/usr/bin/nano ~/.bash_profile
In my case I was not able to make work any command alias. Even vi or vim didnt work without specifying the full path of that command.
If nano is not installed just replace nano in the command by the editor installed
After that just restart the computer. In my case as I said bellow I could not use any command. When trying to do /usr/bin/source ~/.bash_profile
that command failed. So I had to restart the OS and it worked

Resources