Can a Linux command have capital letter(s)?
Yes it can, and there are a few already. Such as /usr/bin/X
:)
dennis@lightning:~$ ls {/usr{/local,},}/{s,}bin | grep '[A-Z]'
MAKEDEV
amuFormat.sh
GET
HEAD
Mail
POST
X
X11
Xephyr
Xnest
Xorg
NetworkManager
dennis@lightning:~$ zcat ~/.cache/apt-file /archive.ubuntu.com_ubuntu_dists_precise_Contents-i386.gz | tail -n +33 | cut -f1 | grep -P '^(usr/)?s?bin/.*[A-Z]' | wc -l
758
So that's 758 in all of Ubuntu 12.04. Full list: https://gist.github.com/5264777
There's no restriction on command names on Unix. Any file can be a command. And a filename can be any sequence of one or more (up to a limit though) of characters other than ASCII NUL or ASCII /
. zsh
even lifts that limitation for functions where you can have any string as the function name.
A few notes though:
- you'll have a hard time creating a command file called
.
or..
;-). - avoid names that are already taken by standard commands or shell builtins or keywords (at least of the most common shells like
bash
,zsh
,tcsh
orksh
). In that regard upper case characters can help as they are generally not used by standard commands. - It's better to restrict to ASCII characters. Non ASCII characters are not expressed the same in the various character sets that are out there
- while you're at it, restrict yourself to letters, digits, dash, dot and underscore. Anything else, while legal, may cause one problem or another with this or that tool (for instance,
|
,=
,&
and many others would need to be escaped in shells, if you use:
, your command cannot be used as one's login shell...). You may even want to exclude.
and-
which are not allowed in function names in many shells, in case you want to allow users to wrap your command in a shell function. - Make the first character a letter. Again, not a strict requirement. But underscore is sometimes used for special things (like in
zsh
the functions from the completion systems start with_
), and all-digit commands can be a problem in things likecmd>output.log
. Files whose name starts with a dot will be hidden by things likels
or shell globbings and many file managers.
The most famous command is stty
, which was also available as STTY
. It was very handy to set the terminal back to normal behaviour with STTY SANE
.