2020/06/28

Linux: [Draft] how files should be organizaded inside $home

as the title says, this is a draft made public.

what I intend to do here is to organize my thoughts on how scripts and files should be placed inside $HOME user directory, were $HOME refers to the proper /home/yourusername directory inside the Linux filesystem, so I will simply refer  to it as "~" . And by user I mean "normal non-root user", But some of these ideas can be used as root too, specially if you run scripts as root under cron and you don' t want other to take a look at them.

At first I came up with the idea of naming each script with a prefix, like convert.mp42mp3, which is not bad by itself since it makes you easier to remember what the command name should look like or even better, tab key can hint you which is the one you are looking for.

Having all scripts inside a director ~/bin is a good thing, but if if you end up with too many scripts like me, it could be annoying each time you do "ls" inside of it trying to find out what is the script you are looking for. Specially if you don't remember the name of it. PATH variable should also point to it, so each time you want to execute them from another directory you don't have to explicit mention the path of the script you want to invoke. To this end, ~/.bashrc_profile must contain a line like this:

export PATH=$PATH:~/bin:

So I guess ~/bin should contain mostly symbolic links to the proper scripts. Where to place the scripts then? inside directories under ~/bin. Each one of those directories names should represent a category under each script belongs.

Examples of names that comes to mind:

remotes (for SSH access to specific hosts, could be ssh too)
develop (if you are a developer)
cron for scripts that are run by cron. A good example could be one to update date and time using ntpdate, but you can do that inside cron as a one line.
os: scripts that does specific things on the operating system (???)

Some programs don' t need to be installed system-wide: if you plan to keep them updated, you can always decompress them under your home dir. Firefox is a glaring example of that.  What I do is to extract the x64 files under ~/usr/local then create a symlink to ~/usr/local/firefox/firefox. And to avoid any conflict with the system-wide Firefox install, what I do is to remove it.