I feel stupid asking, but I can’t seem to find the answer to this anywhere. I’m trying to follow these instructions to edit my bash prompt, but there is no .bashrc
in either my user directory (~/.bashrc
), or in my home directory, or in the main file system directory.
There is no .bashrc
in /etc/
(there is a bash.bashrc
, however).
Do I create a .bashrc
file in my user or home directory? Is there a better, more recent set of instructions for modifying the bash prompt?
Charo
3,5812 gold badges20 silver badges36 bronze badges
asked Apr 28, 2012 at 15:13
JeanSibeliusJeanSibelius
3,5127 gold badges23 silver badges27 bronze badges
6
Don’t forget it is a hidden file inside your home directory (you would not be the first to do a ls -l
and thinking it is not there).
Do a:
ls -la ~/ | more
There should be a .bashrc
on the first page.
If not just create it with:
vi ~/.bashrc
and add in the lines you need to add into it.
Permissions of my .bashrc
are:
-rw-r--r-- 1 discworld discworld 3330 Mar 10 16:03 .bashrc
(chmod 644 .bashrc
to make it rw r r
).
Radu Rădeanu
165k47 gold badges326 silver badges398 bronze badges
answered Apr 28, 2012 at 15:18
10
User specific, hidden by default.
~/.bashrc
If not there simply create one.
System wide:
/etc/bash.bashrc
answered Feb 19, 2013 at 5:53
AlenAlen
5864 silver badges4 bronze badges
There is a .bashrc in every user’s home folder (99.99% of the time) as well as one system-wide (which I don’t know the location of in Ubuntu).
The quickest way to access it is nano ~/.bashrc
from a terminal (replace nano
with whatever you like to use).
If this is not present in a user’s home folder the system-wide .bashrc
is used as a fallback as it is loaded before the user’s file. You could simply copy and paste it (with root permissions of course), but a .bashrc
is not entirely essential (it may be required to make things work. I haven’t found out) at a user level as it mostly overrides the system-wide one with user-specific tweaks. You could write your own though.
The main components for that users may tweak are PS1
(the Bash prompt defaults to display user@localhost:pwd $
) and aliases as well as setting a color prompt and maybe PS2
(busy state message).
answered Apr 28, 2012 at 15:40
Use gedit ~/.bashrc
, it will allow you to modify ~/.bashrc
using gedit.
kos
35.3k13 gold badges100 silver badges150 bronze badges
answered Feb 4, 2016 at 7:40
adoneseadonese
1411 silver badge4 bronze badges
1
It is hidden because of the ‘.’ it starts with.
list it with
ls -al
or enable «show hidden files» under the view menu in nautilus (Ctrl-H will also do the trick).
You can edit it with your favorite text editor from your home directory e.g.
cd
to go to your home directory then:
emacs .bashrc
answered Apr 28, 2012 at 22:10
hazizhaziz
2,8798 gold badges36 silver badges48 bronze badges
1
If .bashrc
is not in your home folder, even after you list the hidden files, you can copy it from:
/etc/skel/.bashrc
heemayl
89.7k20 gold badges198 silver badges264 bronze badges
answered Aug 4, 2014 at 8:52
eaykineaykin
1511 silver badge2 bronze badges
if not in home directory, you can just copy from /etc/bash.bashrc
, and make it source for your terminal, by typing in your terminal source .bashrc
from your home directory after copying.
Mudit Kapil
1,9717 gold badges29 silver badges45 bronze badges
answered Jun 26, 2015 at 14:47
Use nano ~/.bashrc
to open and edit the .bashrc file. (This will create the file if it does not yet exist)
answered Mar 13, 2017 at 11:50
1
If you use encryption and work from the command line you might not see it as one need to mount the real home-dir first (in contrast to in the graphical UI where this is done automaticallu) by the command:
ecryptfs-mount-private
(I had the same question and stumbled upon this question; but found my answer in the readme instead)
answered May 21, 2014 at 14:04
Bashrc file is a hidden file inside the home directory. It is actually, give the path directions.
And those are wanted to edit .bashrc
file, try this command gedit ~/.bashrc
instead of this ~/.bashrc
.
This command gedit ~/.bashrc
directly take you to the text editor, where you can edit it easily, as you know.
answered Nov 2, 2021 at 16:58
Just one note: after you made your alias in bashrc, you need in your terminal to write following command in order that your aliases work:
source .bashrc
Personally, whenever I install Linux anew, I add some aliases finding an appropriate place in .bashrc
E.g.
#My aliases
alias shut='shutdown now'
alias x='exit'
alias update='sudo apt-get update'
Etc. You get the idea.
answered Dec 29, 2022 at 18:36
According to man bash
:
When bash is invoked as an interactive login shell, or as a non-interactive shell with the —login option,
it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for
~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.
~/.bash_profile
The personal initialization file, executed for login shells
~/.bashrc
The individual per-interactive-shell startup file
There is also /etc/bashrc
(/etc/bash.bashrc
in Debian-based Linux) which contains System wide functions and aliases
. By default, this is set, even for non-interactive, non-login shells.
EDIT:
The tilde
in the paths indicates the home directory
of the currently logged in user. Bash is only able to use one of ~/.bash_profile, ~/.bash_login, or ~/.profile
(per currently logged in user), in that order, for reading and executing commands. (Debian-based operating systems typically do not have ~/.bash_profile or ~/.bash_login.
They use the file ~/.profile
. This file explains that it will be read and used unless ~/.bash_profile or ~/.bash_login
are created.
#~/.profile: executed by the command interpreter for login shells.
#This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
exists.
Microsoft just introduced a Linux subsystem in its Windows 10 Anniversary Edition. The installation is pretty straight forward, but I could not locate bash files on Windows.
How does it work? What does ~
refer to in Windows? Where to find .bashrc
?
Cyrus
83.1k14 gold badges87 silver badges149 bronze badges
asked Nov 26, 2016 at 17:06
1
Since the Windows 10 Fall Creators Update, the location changed to:
C:UsersUSERNAMEAppDataLocalPackages{DIST}LocalStaterootfshome{LINUXUSER}
Where:
{DIST}
is equal toCanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc
{LINUXUSER}
is the user for which you are looking for the .bashrc file
Just for anyone wondering that came here from Google.
answered Mar 9, 2018 at 15:16
ncwncw
1,6251 gold badge17 silver badges24 bronze badges
3
Sorry for the misunderstanding, I check on google and it will be at C:UsersUSERNAMEAppDataLocalLxsshomeUSERNAME
.
I tried and it works, in the cmd just type cd && dir *bashrc* /s
it will locate the file, and in my case i see the line C:UsersUSERNAMEAppDataLocalLxsshomeUSERNAME
but when I want to navigate it with the window browser it doesn’t work, but if you copy paste it, it works
I found it here.
Considering that you need to know where a file is located you can use the find
command.
The syntax of the command is find {search-path} {file-names-to-search} {action-to-take}
by default the action to take is printing the file name.
So if you are finding .bashrc file you can use find / -name .bashrc
the bash will return you /home/yourusername/.bashrc
Also, if you want to access to your home directory you can use cd ~
Hope my answer will be helpful
answered Nov 29, 2016 at 19:45
BinaryDumpBinaryDump
4774 silver badges7 bronze badges
6
just type
vi ~/.bashrc
and that should put you into the file where ever it is.
You can navigate there simply by doing cd ~
List all files with ls -a
and you should be able to see it.
answered Aug 29, 2020 at 16:10
JhirschibarJhirschibar
2071 gold badge3 silver badges16 bronze badges
1
~ means that is user home folder, way like /home/%username%/
you can list files like ls -al
and see .bashrc file.
answered Nov 28, 2016 at 21:03
James MJames M
5286 silver badges15 bronze badges
1
Right now on WSL 2 you can find it under /home/{user_name}
and the file is hidden.
You can access it from Ubuntu console by {text_editor} .bashrc
If you want to edit that in Windows just type in ubuntu console explorer.exe .
and it opens the current folder and shows all hidden files.
It’s weird but works fine.
answered Oct 13, 2020 at 12:17
Other answers doesn’t work for me using WSL 2.
The LocalState
folder contains a virtual disk so rootfs
does not exist,
and AppDataLocal
folder does not have the Lxss
folder.
The solution for me is surprisingly simple:
wsl -u root
This will allow you to get into wsl
as root
.
From here, you have access to the whole linux.
Fix the .bashrc
or anything you want.
Don’t screw up the root
user.
answered May 22, 2022 at 21:40
unionalunional
14.4k5 gold badges30 silver badges56 bronze badges
I find my .bashrc
file in:
/home/your_user_name
you can run cd /home/your_user_name
or cd ~
should work as well
If you previously installed git bash for window, you may also find .bashrc
file in your window user profile folder. In Linux subsystem, you may local the file under /mnt/c/Users/your_window_user_name/.bashrc
However, modifying that file only works for git bash in window but not for the shell terminal of the Linux subsystem.
Note: my installation of the Ubuntu is 20.04 LTS straight from window store.
answered Jul 9, 2020 at 5:10
Я чувствую глупость, но я не могу найти ответ на это где угодно. Я пытаюсь выполнить эти инструкции, чтобы отредактировать мое приглашение bash, но нет .bashrc ни в моем каталоге пользователя (~/.bashrc), ни в моем домашнем каталоге, ни в главном каталоге файловой системы.
В /etc/ нет .bashrc (однако есть bash.bashrc).
Создать файл .bashrc в моем пользовательском или домашнем каталоге? Есть ли лучший, более свежий набор инструкций для изменения подсказки bash?
задан
9 July 2014 в 20:35
поделиться
13 ответов
Пользовательский, скрытый по умолчанию.
~/.bashrc
Если нет, просто создайте его.
Пользовательский характер :
ответ дан Alen
25 May 2018 в 12:14
поделиться
В домашней папке каждого пользователя (99.99% времени) есть .bashrc, а также одна системная (я не знаю, где находится Ubuntu).
Самый быстрый способ доступа к ней — nano ~/.bashrc с терминала (замените nano на то, что вы хотите использовать).
Если этого нет в домашней папке пользователя, используется общесистемная .bashrc как резерв, когда он загружается перед файлом пользователя. Вы можете просто скопировать и вставить его (конечно, с правами root), но .bashrc не является абсолютно необходимым (может потребоваться, чтобы все работало, я не обнаружил) на уровне пользователя, поскольку он в основном переопределяет общесистемный с пользовательскими настройками. Вы можете написать свой собственный, хотя.
Основными компонентами для этих пользователей могут быть PS1 (приглашение Bash по умолчанию отображает user@localhost:pwd $) и псевдонимы, а также установку цветового приглашения и, возможно, (сообщение состояния занятости).
ответ дан Peter Mortensen
25 May 2018 в 12:14
поделиться
Он скрыт из-за . начинается с имени файла. Перечислите его с помощью
ls -al
или включите «Показать скрытые файлы» в меню просмотра в nautilus (Ctrl-H также выполнит трюк).
Вы можете редактировать его с помощью любимый текстовый редактор из вашего домашнего каталога, например cd, чтобы перейти в ваш домашний каталог:
emacs .bashrc
ответ дан Sathya
25 May 2018 в 12:14
поделиться
Если .bashrc не находится в вашей домашней папке, даже после того, как вы перечислите скрытые файлы, вы можете скопировать его из:
/etc/skel/.bashrc
ответ дан heemayl
25 May 2018 в 12:14
поделиться
Используйте gedit ~/.bashrc, это позволит вам изменить ~/.bashrc с помощью gedit.
ответ дан kos
25 May 2018 в 12:14
поделиться
, если нет в домашнем каталоге, вы можете просто скопировать из /etc/bash.bashrc и сделать его источником для своего терминала, введя свой терминал source .bashrc из своего домашнего каталога после копирования.
ответ дан Mudit Kapil
25 May 2018 в 12:14
поделиться
Используйте nano ~/.bashrc для открытия и редактирования файла .bashrc. (Это создаст файл, если он еще не существует)
ответ дан Nick Weinberg
25 May 2018 в 12:14
поделиться
Если вы используете шифрование и работаете из командной строки, вы можете не видеть его, поскольку сначала необходимо установить реальный домашний каталог (в отличие от графического интерфейса, где это делается automaticallu) командой: [!d0 ]
ecryptfs-mount-private
(у меня был тот же вопрос и наткнулся на этот вопрос, но вместо этого нашел мой ответ в readme)
ответ дан user
25 May 2018 в 12:14
поделиться
Если вы используете шифрование и работаете из командной строки, вы можете не видеть его, поскольку сначала необходимо установить реальный домашний каталог (в отличие от графического интерфейса, где это делается automaticallu) командой: [!d0 ]
ecryptfs-mount-private
(у меня был тот же вопрос и наткнулся на этот вопрос, но вместо этого нашел мой ответ в readme)
ответ дан user
25 May 2018 в 12:14
поделиться
Если вы используете шифрование и работаете из командной строки, вы можете не видеть его, поскольку сначала необходимо установить реальный домашний каталог (в отличие от графического интерфейса, где это делается automaticallu) командой: [!d0 ]
ecryptfs-mount-private
(у меня был тот же вопрос и наткнулся на этот вопрос, но вместо этого нашел мой ответ в readme)
ответ дан user
25 May 2018 в 12:14
поделиться
Если вы используете шифрование и работаете из командной строки, вы можете не видеть его, поскольку сначала необходимо установить реальный домашний каталог (в отличие от графического интерфейса, где это делается automaticallu) командой: [!d0 ]
ecryptfs-mount-private
(у меня был тот же вопрос и наткнулся на этот вопрос, но вместо этого нашел мой ответ в readme)
ответ дан user
25 May 2018 в 12:14
поделиться
Если вы используете шифрование и работаете из командной строки, вы можете не видеть его, поскольку сначала необходимо установить реальный домашний каталог (в отличие от графического интерфейса, где это делается automaticallu) командой: [!d0 ]
ecryptfs-mount-private
(у меня был тот же вопрос и наткнулся на этот вопрос, но вместо этого нашел мой ответ в readme)
ответ дан user
25 May 2018 в 12:14
поделиться
Если вы используете шифрование и работаете из командной строки, вы можете не видеть его, поскольку сначала необходимо установить реальный домашний каталог (в отличие от графического интерфейса, где это делается automaticallu) командой: [!d0 ]
ecryptfs-mount-private
(у меня был тот же вопрос и наткнулся на этот вопрос, но вместо этого нашел мой ответ в readme)
ответ дан user
25 May 2018 в 12:14
поделиться
Другие вопросы по тегам:
Похожие вопросы:
Create Your Own Startup File for Interactive Shells
About Bash Startup Files
From the INVOCATION section of man 1 bash
says:
When an interactive shell that is not a login shell is started, bash
reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if
these files exist.
Note that these startup files are optional; Bash doesn’t require them. Bash also differentiates between login shells and interactive shells. An interactive shell is defined thus:
An interactive shell is one started without non-option arguments and
without the -c option whose standard input and error are both connected
to terminals (as determined by isatty(3)), or one started with the -i
option.
Many distributions source one type of startup file from the other, but some don’t, so this issue can be difficult to address canonically. You need to examine all your startup files to see how and when your ~/.bashrc
will be invoked on your system.
Creating Your Per-User Interactive Shell Startup File
If you’re simply missing a user-specific ~/.bashrc
file, just create one. This will be invoked by Bash for non-login shells (e.g. shells started without the --login
flag), or whenever you force the shell to be interactive by invoking it with the -i
flag.