Linux Yak First (Part 4): There’s no place like /home
First things first — make a
bin/ directory in your home directory.
It’s not setup by default, but everyone should create themselves their own
bin/ directory within their home directory and add it to their path by adding a line like this to their .bashrc:
Why “bin”? I believe it’s short for binaries, but frankly, every /bin, /sbin, or /usr/bin includes scripts and other non-binary files. It’s really just a naming convention for a directory of executables or commands.
Creating your own bin directory gives you a place to put your own scripts and commands. Bash aliases can also serve this same purpose for one-liners, but setting up the directory frees you up to make more sophisticated things. I have scripts to adjust my monitors, scripts to setup port forwarding, even one that I use to upload files and folders. Plus, bin directory scripts can be called from vim or dmenu without any issues, whereas you can’t call bash aliases.
Your bin directory is your first step to going past just configuration and extending your system to do what you want. It might seem fruitless, but I can say with certainty that I run the commands in my bin directory at least twice as much as any other command.
Configuration in $HOME
As you learn more about linux configuration files, I find it helps to remember that linux’s roots come from systems designed around having multiple, concurrent users. Windows and OS X can do this as well these days, but this has been a normal part of linux for a long time now, and it shaped some of how things work.
For example, for the most part, normal user accounts can only write to files within their home directory. That means that all application configuration, caching, and profiles have to be stored within the home directory too. The reason you don’t notice all these files off the bat is because all files and directories whose name begin with “.” are hidden by default; you can use
ls -a to see them. Here’s some examples:
- bash uses
.bashrcfor configuration and
.bash_historyfor your history. There’s an old convention that configuration files kept in the home directory should end with “rc”.
- Firefox’s configuration, cache, and profiles all live in
- Your SSH key and SSH configuration files live in
- vim uses
.vimrcfor configuration, and a
.vimdirectory for even more configuration.
However, newer configuration is moving away from rc files and application specific directories directly in the home directory (like
.ssh/). There’s a new convention:
Turns out that hidden files were an unintentional consequence from Unix, the predecessor of linux. They are handy, but home directories on modern linux desktops are a mess. Right now, I have over eighty hidden files and directories in my home directory, which are mostly configuration and caches. Rather than everything going into the home directory,
.cache/for caches, and
.local/for data (like profiles, history, and potentially private data.)
For example, lilyterm, the terminal I’ve come to use, doesn’t have a
.lilytermrc file — instead it uses
.config/lilyterm/. Similarly, while vim uses
.vim/, neovim uses
.config/nvim/. In Part 3, we even poked around in
.config/ directory is more organized, and makes it easier for me to backup configuration files regularly, without backing up
.cache/, which I never want to back up.
If an application gives you a choice, I’d try to follow the new convention as much as you can.
Here’s some other, hidden things lurking in my home directory:
.face : this is a 256x256 png that is used by some apps as my account’s icon. It reminds me of .plan files — files you’d create as a sort of local system level user profile, that would show up when someone used the
.gitconfig and .gitignore : a global .gitconfig is pretty typical, but I also setup my own personal .gitignore for ignoring files no one else would like leave lying around.
.bash_aliases, .bash_logout, .bash_prompt : for better or worse, I split out my .bashrc into more files, keeping aliases and prompt-related configuration in their own files. .bash_logout runs on logout and just does a little clean up.
.fonts/ : this is a directory that can be used to install more fonts with the fc-cache command.
Here’s a short list of the dot files and directories everyone should know about:
.gitconfig— if you’re using git, then you should configure git.
.profile— this is similar to
.bashrc, but it’s only read once (on login) instead of every time a terminal is opened.
.vimrc— everyone should learn at least some vim, including how to configure it.
.xinitrc— this file is read when you log in and lets you control which applications get launched when you login.