Dotfiles in Linux Explained

Written by: Linuxopsys   |   Last updated: June 10, 2022

There are various types of files available on computers. Usually, the file extension denotes the file type such as .docx, .odt, .json, .txt . Different file types are for different purposes. 

In this guide, we will be discussing the use-cases of dotfiles, different operations on dotfiles, and proper management of dotfiles in Linux. At the end of this reading, you’ll get to know the value of dotfiles as an application-specific configuration file type.

Understanding dotfiles

Have you ever thought of sharing application-specific preferences with another developer or a machine? In some situations, you might need to customize software programs according to your preferences. It can be your shell interface, code editor, or version control system. 

Imagine a situation where you have bought a brand new computer or work with a team of developers. Then you might need to set up preferences for all these software programs from the beginning or ask the team to set up their machines accordingly. It is going to be a lot of work and will take hours. 

Dotfiles become very handy in these scenarios. It is a configuration file (or files) that stores user application-specific configuration properties in plain text format. As the name suggests, dotfile names start with a period(.). Normally, those configuration files are located in the user’s home directory in Linux environments. These files are hidden by default in Linux-based environments.

Dotfiles are generally stored and tracked in a version control system such as Git. This helps to clone dotfiles to many systems. Additionally, it helps to place shared configuration in the master branch and host-specific configuration in a separate branch. Another method to manage dotfiles is by tracking inside your home directory or sub directory. You can use tools such as chezmoi to sync dotfiles between machines and locally.

Dotfiles Examples

Usually, dotfiles are located in the user home directory in UNIX-based operating systems. Several dotfiles can be seen in the home directory for different application configurations. 

  • Some computer programs store their configuration files inside the .config folder instead of the user home directory. You can locate a lot of configuration information for different general-purpose applications such as LibreOffice, slack, google chrome, etc.
  • Visual studio code stores its configuration files inside the .vscode folder. All your visual studio code workspace configurations will be stored there.
  • If you are working with a Linux environment, you should know about the Linux bash shell. The terminal properties such as shell coloring, command aliases, history, and command completion can be set up for a terminal session based on user preference. Those preferences are stored in the .bashrc file. This file loads whenever a new terminal session starts.
  • The .cache folder is another dot folder that can be located in the user’s home directory. It stores the web browser preferences, general IDE, and application configurations to load them faster.
  • Another popular dotfile is the gitconfig file. Whenever you install and set up git in your machine, it stores all the configurations and settings in the gitconfig file.

How to Find Dotfiles in Linux

The dotfiles are hidden by default in Linux operating systems. If you navigate to the user’s home folder, you can’t see the dotfiles. Because those are hidden. There are a couple of ways to find them. 

  1. Using Linux file explorer
  2. Using the terminal

View in the file explorer

Go to the user’s home directory. It only displays the general files and folders.

listing user home folder

 We can use the shortcut keys “Ctrl + H” to show all the hidden dotfiles. Also, it is possible to show the hidden files using the view options button on the toolbar as shown in the following.

show hidden files from Linux GUI

Upon performing one of the above operations, you'll be able to see dotfiles.

listing view dotfiles in the home folder

View in the terminal

Linux terminal is one of the powerful tools that we can use to view dotfiles in the home directory. First, open up your terminal and enter the following command. This will change your current directory to the home directory.

cd ~

Next, enter the ls command with the -a flag to see the directory listings. You can use the -l flag to show some additional details too.

ls -al
listing all hidden files from terminal

How to Create dotfiles in Linux

Dotfiles can be created on your own. The best way to store your custom dotfiles in a separate folder. Let’s create a new folder called “custom-dotfiles”. We can use the mkdir command to create a new folder.

mkdir custom-dotfiles

Then we’ll put our example dotfiles in this folder. Let’s create a .vimrc file. The touch command can be used.

touch ~/custom-dotfiles/.vimrc

How to move existing dotfiles

In some situations, those files might already exist in your computer home folder. Therefore, you can move those files to the custom-dotfiles directory easily. We can use the below command. Let’s move the bashrc dotfile to our custom-dotfiles directory. Currently, the bashrc file is located in the home folder.

mv ~/.bashrc ~/custom-dotfiles

The mv (move) command works like the following. It takes the file you want to move as the first argument and the second argument is where you want to move it. In this case, we are moving the existing bashrc file to the new directory custom-dotfiles.

How to edit dotfiles

Whenever you want to modify existing dotfiles, you can use the vim editor. The vim editor lets you edit files within the terminal itself. Let’s edit the file. 

First, we need to locate the home directory and then go inside the custom-dotfiles directory. We’ll be using the following command.

cd ~/custom-dotfiles

Then we need to issue the vim command with proper arguments. The vim command should be executed with one argument which is the file we are going to edit.

vim .vimrc

The vim editor will be started. Let’s add a configuration property to the .vimrc file which will show line numbers in the vim editor.

edit dotfiles using vim

Since we have modified the file content, it needs to be saved. We should press the Esc key to exit from the edit mode and then issue the below command to save and exit from the vim editor.


Then hit the Enter key.

Practical usage of Dotfiles

Dotfiles are very beneficial to the developers who are working with several software programs daily. Each of these applications might have its configuration properties set up as per the developer's preferences.

Commonly users create dotfiles to customize Shell (zsh, fish, and bash), DE (Desktop Environment), Editors ( vim, neovim, emacs), Terminal (kitty, terminator), Multiplexer, Audio and Monitor.

Hence, let’s have a look at some of these practical dotfile configurations. 

Customize vim

The vim editor is a text editor tool attached to the linux shell. If you have been working with shell script programming, you might use this editor to some extent. The default vim editor looks and feels might not be productive for you. The config files become handy for this type of requirement. Let’s use the .vimrc file to configure the vim editor a bit. 

We can edit the previously created .vimrc file. You can add the below configuration properties to this file and save it.

" Turn syntax highlighting on.
syntax on
" Add numbers to each line on the left-hand side.
set number

If you open the vim editor again, you will see line numbers, and the syntax highlighting feature has been enabled. In the same way, you can edit this file to add more configuration properties.

Some of the additional configuration features are listed below for you to try out.

" Highlight cursor line underneath the cursor horizontally.
set cursorline
" Show matching words during a search.
set showmatch
" Highlight cursor line underneath the cursor vertically.
set cursorcolumn

Personalize the Zsh Shell

The ZSH shell is built on top of the bash shell. It is the default shell for Mac-OS. This shell supports more advanced features than the usual bash shell which makes you more productive.

Whenever you run the ZSH shell it loads several configuration files. The .zshrc file is one of those config files which contains commands, and several shell configurations. It also takes care of key bindings, functions, and aliases. Usually, the zshrc file is located in the user's home-directory/.zshrc path.

The .zshrc dot file can be used to customize the ZSH shell. Let's add the auto-completion feature to the zsh shell. First, open the .zshrc file and add the below properties.

autoload -Uz compinit; compinit; compoptions+=(globdots;

This will load the autoload command and finally, it will enable ZSH to load hidden files. There are several configuration properties available to use within the .zshrc file to customize it further.

Creating Aliases

As a developer, you might be working with hundreds of command-line commands per day. Sometimes, you might feel like it is very inefficient to type lengthy commands one by one. Hence, it is good to create shortcuts for these commands. We call these shortcuts Aliases. Then you can easily add those aliases to respective config files.

You can even concatenate several commands together and use them efficiently. Let’s create an alias to simplify the git workflow. We will be creating aliases for two popular git commands as shown in the following.

First, you need to locate the .gitconfig file. Then open it on the vim editor and add the below lines.

st = status
ci = commit -m

The above st and ci aliases will perform the status and commit commands under the hood. Now you can call both the commands as shown in the following.

git st
git ci

The output of the above two commands is still the same outputs that we get from status and commit -m.

How to manage dotfiles

In a previous section, we have discussed how you can manage dotfiles within your local machine. You might be modifying those files frequently. Even new files might be added to your dotfiles list. Therefore, it is important to version control your dotfiles. We can use git as our version control management system here.

First, we need to convert the custom-dotfiles directory to a git repository. Let’s issue the git init command as shown in the following. Make Sure that you are inside the custom-dotfiles directory.

git init

Next, you need to add the .vimrc file to the staging area as shown in the following.

git add .

The above command will add all the files to the git staging area. You can check it by issuing the below command.

git status

Then we should commit the changes locally. The git commit command can be used.

git commit -m “initial dot files committed”
commit dotfiles

Host dotfiles on Github

It is a few steps away from hosting your dotfiles in a remote code hosting platform like Github. First, we need to create a new Github repository. You should sign in to your Github and then click on the new repository button as shown in the following.

create a GitHub repo for dotfiles

Then you’ll be prompted to specify a repository name. Let’s give the name custom-dotfiles. After that, click on the create repository button to create your dotfile repository.

Finally, you should add the newly created repo URL by executing the following command.

git remote add origin <url>

Then we can push our local changes to the remote host using the git push command. We are going to push all our changes to the main branch.

git push -u origin main

Now you will be able to share your dotfiles with anyone around the world. You just need to share the custom-dotfiles repository URL. Even you can have someone else’s dotfiles easily.

Symlink Dot files

Usually, the software programs store their config files in the user's home directory. Those are stored along with all the other hidden files. Whenever the program loads it looks into the home directory and locate the relevant config file. Therefore, the new dotfiles that we have created in the custom–dotfiles directory won’t be visible to these applications. So, we need a way to link the files inside the custom-dotfiles directory to the home directory. This is what we call symlink or symbolic link.

This means two copies of the same config file will be in two places. You can use the below command to create a symlink.

ln -s ~/dotfiles/.vimrc ~/.vimrc

dotfile User repositories

Listed some of the awesome dotfiles user repositories

webproA curated list of dotfiles resources
yakko_wakkoFor macOS/Linux
orhunArch Linux configuration files and scripts
jakehamiltonBeautiful configs
RMPRHOME git-managed
justinesmithiesFor Qtile setup running under Wayland


We have discussed several important aspects related to dotfiles. Dotfiles contain the application-specific configurations. Usually, these files are stored in the user's home directory. We can use dotfiles to customize generic software programs such as bash shell, vim editor, zsh shell, and git.

It is very important to version control your dotfiles and host them in a remote host like Github. It will allow you to share custom dotfiles with others. In some cases, your custom dotfiles may locate in another directory instead of the home directory. Then you have to create symlinks to make things work.

Thanks for reading, please leave your feedback and suggestions in the comment section.



Please add comments below to provide the author your ideas, appreciation and feedback.

Leave a Reply

Leave a Comment