Showing posts with label CI/CD. Show all posts
Showing posts with label CI/CD. Show all posts

Wednesday, June 17, 2026

What are dotfiles in Linux?

dotfiles are a hidden gem in Linux and allow you to customize and optimize your experience. Learn how...
Photo by Sung Jin Cho on Unsplash

Dotfiles are software/system files whose file name begins with a period (dot) character. The majority of settings for your computer and installed software can be configured from these files.

What are Dotfiles in Linux

Dotfiles are an essential aspect of the Linux and Unix-like operating systems that often go unnoticed by casual users.

What makes dotfiles special?

Dotfiles are hidden by default. This is because any file that starts with a period character (e.g., .zshrc) is considered to be a system file and should be hidden to protect general users from accidentally changing or deleting those files, which could cause preinstalled software to break.

When used correctly, dotfiles represent a powerful feature for personalizing and configuring the environment to meet individual needs. This is how the best developers, system administrators, and power users use them.

Identifying dotfiles

Dotfiles are configuration files that begin with a dot (.) at the beginning of their names.

$ ls -lah ~./
-rw-rw-r-- 1 ubuntu ubuntu 5.7K Feb 23 17:32 /home/ubuntu/.bash_aliases
-rw------- 1 ubuntu ubuntu 32K Feb 28 12:54 /home/ubuntu/.bash_history
-rw-r--r-- 1 ubuntu ubuntu 220 Mar 31 2024 /home/ubuntu/.bash_logout
-rw-r--r-- 1 ubuntu ubuntu 3.7K Jun 25 2024 /home/ubuntu/.bashrc

Using dotfiles

In Linux/UNIX-based systems, the dot prefix makes them hidden files in the Linux file system, meaning that they're not displayed by default when listing files in a directory with commands like `ls`.

Viewing dotfiles

To view these files, you typically use ls or similar commands.

$ ls -lah ~./
-rw-rw-r-- 1 ubuntu ubuntu 5.7K Feb 23 17:32 /home/ubuntu/.bash_aliases
-rw------- 1 ubuntu ubuntu 32K Feb 28 12:54 /home/ubuntu/.bash_history
-rw-r--r-- 1 ubuntu ubuntu 220 Mar 31 2024 /home/ubuntu/.bash_logout
-rw-r--r-- 1 ubuntu ubuntu 3.7K Jun 25 2024 /home/ubuntu/.bashrc

Locating dotfiles

dotfiles are primarily stored in a user's home directory (`/home/username`), and they serve various purposes, depending on the software they are associated with.

Editing dotfiles

dotfiles are simple text files, so use your preferred text editor (vim or nano) to edit them.

$ vim ~/.bash_aliases

Common Dotfiles and Their Purposes

Here are some of the most common dotfiles you might encounter.

.bashrc

Configures the behavior of the Bash shell, including aliases and functions.

.vimrc

Customizes the Vim text editor's settings and preferences

.gitconfig

Stores global Git configuration, such as username and email.

.profile

Used to execute commands upon login, setting environment variables.

.zshrc

Configures settings for the Zsh shell, similar to .bashrc.

.inputrc

Customizes input behavior in command-line interfaces.

Why Use Dotfiles?

Personalization

Dotfiles allow you to tailor your development environment by changing settings, shortcuts, and preferences to match your workflow.

Portability

By keeping your dotfiles in a version control system like Git, you can easily replicate your development environment on different machines or share it with others.

Efficiency

Dotfiles often include custom scripts and commands that can streamline repetitive tasks, saving you time and effort.

Collaboration

By sharing your dotfiles, you can help others configure their environments more quickly, fostering collaboration among team members.

Best practices

Managing your dotfiles effectively can further enhance your productivity. Here are some best practices.

Use Version Control

Use Git to track changes to your dotfiles. This will allow you to revert to previous versions if necessary and keep them synchronized across different machines.

Consider creating a dedicated repository for your dotfiles on platforms like GitHub or GitLab. This makes it easier to access them from anywhere and share them with others.

A lot of people host their dotfiles in GitHub. If you do this too, just make sure your files don't expose any secret

Backup

Regularly back up your dotfiles, especially before making significant changes. This can help prevent loss in case of system failures.

Installation

If you use multiple systems and depends on your customization, beyond version control, a it's also a good practice to write installation scripts to automate the setup process of your dotfiles on a new system to ensure you can quickly access your configuration wherever you're working on.

Conclusion

Dotfiles are more than just hidden files; they are an integral part of how users interact with their systems. By understanding and effectively managing your dotfiles, you can create a more efficient, personalized, and portable development environment. Whether you are a beginner or a seasoned Linux user, taking time to explore these configuration files can significantly enhance your overall experience. 

Wednesday, June 3, 2026

How Exports and Evironment Variables in Linux work

Environment variables play a crucial role in how Linux operates. Learn how to use them effectively.
Photo by Abolfazl Pahlavan on Unsplash

Environment variables play a crucial role in how Linux operates, influencing shell behavior, scripts, and applications.

Understanding these concepts can significantly enhance your usage and efficiency in a Linux environment. Let's see how.

What are Environment Variables?

Environment variables (env vars) are dynamic values that affect the processes running on a computer. They provide essential information to both the system and applications about the environment in which they are executing.

Common env vars

Frequent environment variables are listed below. These variables can be used by applications and scripts to behave differently based on the environment settings.

$PATH

This specifies the directories where executable programs are located. The system searches these directories to find commands.

$HOME

Represents the current user's home directory.

$SHELL

Represents the current user's shell.

Examples

# Print the current user's home directory
$ echo $HOME

# Print the name of the currently logged-in user
$ echo $USER

# Print the path to the current shell program
$ echo $SHELL

Setting variables

You can also set environment variables in the shell using the export command. Here's how it works.

To set a variable, simply type:

$ VARIABLE_NAME=value

For example, to set a variable named `MY_VAR`:

$ MY_VAR=123

However, this variable will only be available in the current shell session.

Exporting variables

To make a variable available to child processes, use the `export` command:

$ export VARIABLE_NAME

If we want `MY_VAR` to be available to all child processes, we would do:

$ export MY_VAR

Combining Setting and Exporting

You can also combine both actions: 

$ export MY_VAR=123

Viewing Environment Variables

To see all currently set environment variables, you can use the `env` command or simply type:

$ printenv

To display a single variable, use:

$ echo $VARIABLE_NAME

For example, the command below will show you the directories set in the `PATH` variable:

$ echo $PATH

Unsetting Environment Variables

If you need to remove an environment variable, the `unset` command can be used:

$ unset VARIABLE_NAME

For example, to unset `MY_VAR`:

$ unset MY_VAR

Practical Uses of Environment Variables

Environment variables are handy in various scenarios, let's discuss some of them.

Configuration

Many applications use environment variables for configuration settings. For instance, databases often utilize `DB_HOST`, `DB_USER`, and `DB_PASS` to connect.

Scripts

Writing scripts that depend on which user ran them can use the `USER` variable to customize behavior accordingly.

Software development, DevOps & CI/CD pipelines

When developing software, environment variables often store API keys, secrets, or other sensitive information to keep them outside the source code.

Conclusion

Understanding exports and environment variables in Linux is vital for maximizing system performance and efficiency.

Environment vars allow users to customize their working environment, improve automation in scripts, and ensure that applications can access the configuration settings they need to run correctly.

Mastering these concepts can help streamline your Linux experience and unlock new levels of productivity.

Featured Article

What are dotfiles in Linux?

dotfiles are a hidden gem in Linux and allow you to customize and optimize your experience. Learn how... ...