Naming conventions and best practice
Questions tagged [conventions]
66 questions
212
votes
4 answers
Why do we use su - and not just su?
I don't understand why su - is preferred over su to login as root.
Dharmit
- 4,220
- 7
- 28
- 37
66
votes
8 answers
Why does Bash's source not need the execution bit?
With Bash's source it is possible to execute a script without an execution bit set. This is documented and expected behaviour, but isn't this against the use of an execution bit?
I know, that source doesn't create a subshell.
Motte001
- 1,210
- 3
- 10
- 20
65
votes
2 answers
Why are shared libraries executable?
Why have almost all the shared libraries in /usr/lib/ have the executable permission bit set? I don't see any use case for executing them. Some do manage to hook-up some form of main function to print a short copyright and version note, but many…
Tadeusz A. Kadłubowski
- 761
- 1
- 5
- 7
61
votes
17 answers
Why do Unix-heads say "minus"?
A couple of weeks ago I attended a talk on Git by someone who seemed to be from a Windows background. I say "seemed to be" because he kept saying "dash" when referring to command-line options. I then recalled something that I found curious in my…
Eric Smith
- 1,274
- 1
- 9
- 16
57
votes
7 answers
File extensions for unix shell scripts
On wikipedia, the article for .sh says:
For the .sh file extension type, see Bourne shell.
How about other unix shells?
I know that the shebang is used inside the file to indicate an interpreter for execution, but I wonder:
What are the pros…
Amelio Vazquez-Reina
- 40,169
- 77
- 197
- 294
30
votes
10 answers
one-liner vs script
I've noticed a lot of questions and answers and comments expressing disdain for (and sometimes even fear of) writing scripts instead of one-liners. So, I'd like to know:
When and why should I write a stand-alone script rather than a "one-liner"? …
cas
- 1
- 7
- 119
- 185
28
votes
3 answers
File and directory naming conventions
I want to refactor the files and directories on my system. However I am not sure what is best practice.
After reading this question and its answers I assume the most important part is to be consistent. However, this is where I'm stuck. E.g. in root,…
whirlwin
- 551
- 1
- 5
- 12
26
votes
3 answers
Origin of the word cron?
Trying to settle a friendly argument. Is "cron" an acronym for something?
Additionally, did it's current canonical name "cron" originate from something shortened for something like chronos or chronological?
A quick google search didn't find what i…
chrisjlee
- 8,283
- 16
- 49
- 54
26
votes
1 answer
What is the number prefix in config files from .d directory
A lot of unix config files in xx.d folders are prefixed by a number, like :
$ ls /etc/grub.d/
00_header 10_linux 30_os-prober 40_custom
05_debian_theme 20_linux_xen 30_uefi-firmware 41_custom
Is there any convention on this…
Rémi Benoit
- 364
- 3
- 8
21
votes
2 answers
An official standard / convention for a file extension for shell scripts to source
I was wondering if there is a convention for file type extensions for shell scripts you want to source instead of run. For example:
If I want to run this script in a subshell.
./script.sh
If I want to remember to run this script from the…
Mateusz Piotrowski
- 4,623
- 5
- 36
- 70
13
votes
2 answers
When to use standard error stream in command-line application?
Is there a guideline when to use the error when writing a command-line application? To my surprise, I didn't find anything when googling it.
In particular, the question I'm concerned with right now is whether to use stdout or stderr when the user…
UTF-8
- 3,175
- 5
- 23
- 50
12
votes
2 answers
Convention/standard on using curly braces around options
The man page for tar in Arch Linux SYNOPSIS section starts with:
tar {A|c|d|r|t|u|x}[GnSkUWOmpsMBiajJzZhPlRvwo] [ARG...]
I perfectly understand that in this situation it means that exactly one of the options in the curly braces must be given…
umbasa
- 129
- 1
- 3
10
votes
2 answers
Anyone know the meaning of yy?
Since history questions are considered on topic, I figured I'd ask one that's been bugging me for quite some time and no one I know seems to know the answer. Does anyone know what the historical significance is of the prefix yy? Most of the…
Timothy
- 223
- 3
- 9
10
votes
1 answer
When should you use subshells vs `xargs`?
Many simple commands using xargs could be rewritten as commands using subshells. For instance, here is something I was using earlier today, to concatenate the ten largest binaries in /usr/bin, written using a subshell vs xargs:
subshell:
$ cat $(du…
haneefmubarak
- 395
- 1
- 3
- 10
9
votes
2 answers
Where should I mount my external harddrive?
I've got an external harddrive that I'd like to auto-mount. It will be present most times when my laptop boots. Where is the "correct" place to mount it?
/media/my-hd: Will litter /media with an empty folder when the hard-drive was not…
Anna
- 1,119
- 1
- 11
- 23