How do I find .bash_profile and add to my shell's initialization file? [closed] - rvm

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 11 years ago.
Improve this question
I am trying to upgrade ruby using rvm.
On the pragmatic site, it says:
The important part is to add the following line to the end of your shell's initialization file (.bash_profile):
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
How do I do this? Where is this initialization file?
Please help

It would be /home/$USER/.bash_profile, but would only be present if you're actually using bash as your shell. Other shells will use a 'dot file' with their name in them instead. You can view them with ls -ad $HOME/.*

There are two initialization files .bash_profile & .bashrc, both present in user home directory.
.bash_profile is initialized when you login with userid. .bashrc is initialized when you are already logged in and want to open one more terminal.
If you want to add some settings in both the file then you can do following
if [ -f ~/.bashrc ];
then
source ~/.bashrc
fi

Related

xfce4-session "cannot connect display" error [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 11 months ago.
Improve this question
I'm trying to run xubuntu-desktop on WSL as per the tutorial given by many sites. But I can't seem to connect to the display of VcXsrv and it always shows:
xfce4-session: Cannot open display: .
Type 'xfce4-session --help' for usage.
If I run startxfce4, it says:
/usr/bin/startxfce4: X server already running on display muhammadsalmanafzal:0.0
xrdb: Connection refused
xrdb: Can't open display 'muhammadsalmanafzal:0.0'
xfce4-session: Cannot open display: .
Type 'xfce4-session --help' for usage.
Although, the VcXsrv window of Xlaunch is closed.
Can anybody help me look for the error? What am I doing wrong?
Also, when I first installed xubuntu-desktop, at the very end it said:
Errors were encountered while processing:
blueman
E: Sub-process /usr/bin/dpkg returned an error code (1)
And then I read somewhere to remove it, so I did and reinstalled xubuntu-desktop and no error was given.
If you are running WSL 1 then then, you need to add following line to .bashrc in home:
export DISPLAY=:0.0
and run bash again.
However, if you are running WSL 2 then you need get the IPv4 of you WSL network (since by converting to WSL 2, it becomes a network) by checking the ipconfig in Powershell and then export the relative to .bashrc
[EDIT]
I think after the windows update to 20H2, the above solution stopped working. So, as per the official recommendation of Ubuntu from their site, you can add the following lines in your ~/.bashrc and restart it.
export DISPLAY=:0 # in WSL 1
export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0 # in WSL 2
export LIBGL_ALWAYS_INDIRECT=1
a better solution is run:
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0
wsl2 changed when restarted and can't be fixed currently.
https://qiita.com/baibai25/items/5841b0592727893d960f
The following two approaches worked for me. I use WSL2.
Approach -1:
The title bar of VcXsrv says something like VcXsrv Server Display MACHINENAME:0.0.
Start xfce4 with this command: xfce4-session --display=MACHINENAME:0.0
Replace MACHINENAME with the name of your PC.
Reference: https://github.com/Microsoft/WSL/issues/1800#issuecomment-455791220
Approach-2:
Add the following line to .bashrc file.
export DISPLAY=MACHINENAME:0.0
Again MACHINENAME should be the name of your PC
Save the file and restart WSL2.
Now you can just use the command xfce4-session.

Use tar to compress file tar.gz with password [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 8 years ago.
Improve this question
I use tar -czf test.tar.gz test/ to compress test forlder to test.tar.gz . Now, I want compress to test.tar.gz with password "mypass" How can I do?
Neither the tar format nor the gz format has built-in support for password-protecting files.
Use crypt or gpg on the
Refer this encrypt-and-decrypt-files-with-a-password for more info.
tar cvvjf - /path/to/files | ccrypt > backup.tar.bz2.cpt
or
ccrypt backup.tar.bz2
And then to decrypt:
cat ../backup.tar.bz2 | ccrypt -d | tar -xjf -
You can also use zip
zip -e file.zip file
Will ask you on a prompt for a password. It is more secure then passing the password via the command line via zip -P password.

How do I list manually installed packages in Debian over SSH non-interactively? [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
Directly on my Debian box, I can run the following command to show manually installed packages:
aptitude search '!~M ~i'
This works great. If I SSH in from a remote box, and run the command, I also get the same result.
However, when I run the command as a batch, it does not produce the same result.
ssh user#server aptitude search '!~M ~i'
Since the process takes a bit of time to run, I execute ps aux | grep aptitude while running both variants, and the result appears to be the same.
What am I doing wrong?
PS. I am aware that dpkg -L can produce this information, but this is just the smallest example of what is broken, I intend to use !~pstandard !~pimportant !~prequired to filter out base packages as well, which I don't believe dpkg can do (but if it can, a solution with dpkg is welcome.)
Using information from Bash - Escaping SSH commands, I was able to create a command that worked:
ssh user#server $(printf '%q ' aptitude search '!~M ~i')
If target is a more recent debian/ubuntu you can use:
ssh user#server apt-mark showmanual

How to deal with the garbled characters about PDF file on Ubuntu? [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 searched this method:
sudo apt-get install poppler-data
But also,when I download a PDF file from my Ubuntu server,it's character is garbled:(
I haven't restart my server.Is it necessary?
Run the command
sudo mv /etc/fonts/conf.d/49-sansserif.conf /etc/fonts/conf.d/49-sansserif.conf.backup
to try.
Or this method:
sudo gedit /etc/fonts/conf.d/49-sansserif.conf
Change the sans-serif(At the below of the file line -4) to others and restart your X.

Execute command for all windows in the screen [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 use screen and sometimes I change my .bashrc profile. Therefore, I want to apply .bashrc changes for all screen windows. Unfortunately, screen reads profile only for creating new window and doesn't reload .bashrc for existing windows.
My screen session has one or more windows. Before attaching screen I want to execute command for each window. The command is simple "source ~/.bashrc".
I try:
screen -X stuff "source ~/.bashrc"`echo -ne '\015'`
It's worked perfectly only for one window. So I can't iterate through screen windows using "prev" or "next" command.
I already have read screen man, docs, and I event try to search solution of my problem :)
Can you direct me to right direction? Or maybe somebody already solved similar problem?
If you're using a recent version of screen you can use the -Q option, see original thread and this answer. This works here:
screen -Q windows | sed 's/[^0-9]*/\n/g; s/^\n//g' \
| while read; do
screen -S test -p $REPLY -X stuff "source ~/.bashrc"$'\n'
done
With:
$ screen --version
Screen version 4.01.00devel (GNU) 2-May-06
Note, if you have multiple session, name them with -S. In this case I'm working with a session called test. -p tells screen which window to send the command to.
Note also the use of ANSI-C quoting ($'\n').
When the -Q command executes, screen waits msgwait seconds before running the commands, work around this by setting msgwait to zero and reset it after execution i.e.
screen -S test -X msgwait 0
...
screen -S test -X msgwait 5
5 is the default value.