How do you name directories?

Recently, I decided to create a directory for my patches and for some reason I was thinking about its name longer than I would usually do. How would I call it: patch or patches? Usually I don't care about that much and I guess I name directories 50-50 singular-plural. But now I think it would be nice to keep things consistent.

Well, I looked at hier(7) and how directories named in FreeBSD in general and I found that this is not very much consisten. For instance, we have:
- plural: /etc/defaults, /etc/ssl/certs, /usr/ports, /var/games, /var/msgs, /var/backups, /boot/fonts, /usr/shared/examples.
- singular: /var/crash, /var/db, /var/log, /dev, /bin, /lib.
- .d suffix: /etc/rc.d, /etc/newsyslog.d, /etc/profile.d, /boot/loader.conf.d.

I understand that there is no strict policy for that and some names are just used historically from ancient times. But now I'm curious: how do you guys name your directories? And do you care about it at all?
 
The flaws about unix's directory names, and hier are way bigger than just 'singular' or 'plural.' 😅
Dude, imagine a very old, and very large building complex. It once all started a very long time ago with just a simple barn. Since then this barn has been extended, and adapted to more tasks, and current needs. Over the time flats, stables, workshops, garages and complete wings were added. Some were teared down again, others changed its usage: What once was the pigsty is now the sheriff's flat. Roof, plumbing, heating, and electricity added, adapted, changed, and exchanged many times,...
...and now one says: "The doorbell sounds odd." 😂
Yes. It does. There is no dorbell like ours! ☺️
(sorry, couldn't resist. 😁)
Find the history of Unix and see for example how /usr or /etc got into the system, their names, what they originally were meant for, and compare that with their today's duty.
'singular', 'plural' - Dude, you must be kidding! 🤣

But to become serious:
0. I keep my system apart from "the rest". / is on a 256 G pool, while /home is on a 256 G pool of it's own. Plus I have a 1 T pool mounted as /store (VirtualBox, Wine, Downloads...all the rubbish which needs space, I'm doing something with, but don't want it to trash up my /home, lives there.) Additionally a 12 T NAS containing a raidz2 pool for all the stuff I don't currently, or rarely need: pictures, books, disc images, audio, video, my old Windows directories,.. whathaveyou etc. This keeps my /home and so its backup footprint small (~15 G at the moment.)

I try to name my directories like this:
  1. The names of the more frequently used ones start with small letters.
  2. The rarer used ones name's start with capital letters.
  3. At least in my main, and core directories every name's first letter is only used once. Example: In a directory I may have one subdir named 'production', and another one named 'Programming', but then no other's name will start with neither a 'p' nor a 'P' in this dir.
  4. Names have to be as short as possible, but I try to avoid abbrevations, if they are not clearly distinct.
  5. Names must be comprehandable. (Most important point at all, even if I named it under 5.)
  6. No special signs. a...z, A...Z, 1...0, no ' ' but _ and - or . only
For example: /production/programming/c/ was OK, /prd/prg/c/ was not. 'c' is okay, too, while it's a subdirectory of 'programming' which makes it clear what it contains.
If I stumble over a name I cannot remember instantly what it stands for, e.g. 'mvhpc' it's a sure sign for a bad name. (One cannot give always a good name every time instantly. But one need to try.) Then I rename it instantly.
 
I really wanted to say " I just use a random number, roughly tied to Unix epoch and then I put a README in each one describing the contents/purpose of the directory" but that's not what I do.
Directories I try to keep as short as possible but try to make them intuitive/descriptive. Things like /datastuff or /repomgmt
 
d as in drop directory - directory you drop your config files in.

It depends. Some personal ones - it's just how I feel about it during its creation. If it's work related and requires other teams to adhere to it I create a naming convention document.
Example: docs rather than doc but pdf rather than pdfs. I guess also most likely how I feel that day but documented. :)
 
Absolutely chaotic. My home directory is pure chaos. I don't use Cyrillic—it's less of a hassle when transferring files to other media. To avoid chaos now and carry it into the future, I archive and compress my folders, then encrypt them and upload them to an external hard drive.
 
I guess that if I haven't learned how to name stuff in thirty years that's not going to happen anytime soon.
I still have a bunch of test, test1, test.old, test.prev and various iterations of the word 'temp' hidden away in several directories. I suck at naming things.

Find the history of Unix and see for example how /usr or /etc got into the system, their names, what they originally were meant for, and compare that with their today's duty.
What about options for commands? That's a big bloody mess too. Not even remotely consistent. But impossible to correct, as that would break just about everything.
 
Like SirDice, I have a bunch of test, tmp and so on. Every so often I go to look at what's in them and usually wind up deleting them as they're something I only used once. For example, on a slack chat with a user. "I'm going to give you a temporary password" Then I make a file tempusername with the password which is something silly, as it's going t be used for a login, then immediately changed. Now, I've got that tmpusername file sitting around and forgotten.
 
Consistency is the sign of a weak mind. Balance that with the fact that I don't suffer from OCD, I enjoy it, and like my computer to be very organized.

Just like Sir Dice, there are lots of directories called test, temp, TEMP, Temp, foo, bar, blatz, and so on. In particular, if I need an intermediate (throwaway) file for a shell pipeline, it's always called /tmp/foo. In general, any files/directories with these names should be deleted right away. In practice, I always check whether they contain something useful when doing cleanup, and (sadly) often find half-done projects that have good parts that need to be saved.

In my home directory, for most of my computer-related projects, I use relatively short and descriptive names, such as "bar" for Backup-Archive-Restore, and "eqmon" for water-and-house-EQuipment-Monitoring-and-control", and "lightcontrol" to turn Christmas lights on at the correct time. Note that bar is also a throwaway name ... consistency, as I said above. And then within source code directories, the usual standards for lib, obj, src, and so in. For text files containing notes, snapshots downloaded from my cell phone, I have a universal convention that file names must look like 20251201_lawyer_phonecall.txt, or 20251201_1305_driveway_asphalt_damage.jpg. So even if these files are in a random directory, they are easily identified as this morning's phone call with my lawyer, or the state of my attempts to fix the hole in the driveway.

Do you see that for some things I use really short names (bar and such), versus really long ones for others? That's actually for a reason: things that are used all the time and I'm guaranteed to remember (like the source code directory for my backup program) are short; things where the file name is important (meta-)data get long names.

In general, file and directory names have no spaces or punctuation characters (other than - _ .), and are 7-bit US ASCII. And in general they start with lowercase characters, numbers only for dates. Having said that, let's get to the exceptions ...

I have a directory /home/docs which contains several hundred thousand documents (I'm mostly paperless at home, and have been converting 40 years of file cabinets into PDF files), and in there directory names are nearly always capitalized. For example: Receipts/Propane/Suburban, or Neighborhood/2023_Lawsuit/Depositions, or Music/Orchestra_Parts/201709_HP_Symphony/Saint-Saëns_Bacchanale_timpani.pdf. Did you notice that in this particular case I allow a Unicode character in the file name? As I said, consistency is overrated, and proper names have to be spelled properly, even Dvořák. That means that I actually now allow Unicode in UFT-8 form for names. The only rule that is 100% enforced (automatically, by the backup program): directory/file names never contain space or control characters (ASCII codes 0x00...0x1F and 0x7F), and never a # sign.
 
I like vhosts.d (RHEL) more than sites-available/enabled (Debian) with nginx; something about the name being less-friendly looks better for that, and .d seems like a standard.

For Git projects I pull to folders similar to the repo name ( LostCity-225-EngineTS is LostCity's EngineTS repo from 225 branch); external extra stuff related to those projects I put in a ext folder.

Wine prefixes are in a hidden ~/.wine folder, and file backups get moved in the same folder like Game.exe -> Game.exe~ (auto GUI-hidden). Game saves get backed-up with tar like $(date +%Y-%m-%d-%s)-2004Scape-localhost-Saves.tar.gz (looks like 2025-12-01-1764638457-filename.tar.gz).

Random stuff is kept in ~/Downloads or /tmp, and quick text notes like ~/todo.txt :p
 
Back
Top