Do all different Linux distributions have the same command lines? What I want to know is the same command line works for all kinds of Linux distributions (CentOS, Fedora, Ubuntu, etc.) or whether they all have different command lines?
closed as too broad by αғsнιη, muru, RalfFriedl, Ipor Sircer, user88036 Sep 28 '18 at 8:52
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
I'm choosing to interpret this question as a question about the portability of commands and shells across various Linux distributions. A "command line" could mean both "a command written at the shell prompt" and "the shell itself". Hopefully this answer addresses both these interpretations of "command line".
Most Unix systems provide the same basic utilities for working at the shell prompt. These utilities are working largely in the same way since they are standardised. Also, the syntax used for writing shell commands is standardised (loops, redirections, pipes, background processes, variable assignments, quoting etc.) The standard is called POSIX and may be found here (see the "Shell & Utilities" section).
On most Unices (especially on Linux for some reason), the standard utilities have been extended with extra functionality, but the functionality described by the POSIX standard should be implemented. If a standard utility does not conform to the POSIX standard, you should probably file a bug report about this.
In particular, the shell itself is often extended to give a more convenient interactive experience, or to be able to provide more advanced shell programming facilities. The shell, being an application like any other, comes in various flavours (implementations) and
bash is the most popular on Linux systems (but it's also available as the default shell on e.g. macOS and may be installed on any Unix). The
ksh shells are also popular and provide different sets of extensions, but all should at least be able to do largely what the POSIX standard says using a common syntax (except when using extensions such as special types of arrays and fancier forms of filename pattern matching etc. although some of this happens to be fairly similar between shells too).
As for non-standard tools, such as tools for doing some specific task that is not covered by the POSIX standard (such as talking to a database or adjusting the brightness level of a monitor), or that are specific to a particular Linux distribution (maybe for doing package management), to a version of a particular Linux distribution, or to a particular hardware architecture etc., the portability of the command would depend on the correct variant and version of the tool being installed on a system that supports using that tool.
Across various Linux distributions, the assortment of available tools and utilities is fairly homogenous, and portability is generally good (with the caveat that distribution and architecture specific tools may be different or missing). When looking at using and writing scripts that should work on other types of Unix systems, it becomes more important to know about what extensions are particular to the GNU/Linux variation of tools and utilities, and what can be expected to work on "a generic POSIX/Unix system".
Linux is just a kernel, not OS, things you use directly like commands or GUI programs or beautiful desktops are not provided by the kernel, but by userland components, which are distributed with OSes.
Commands you used in the shell comes from shell builtin functions or external software package. Depending on the softwares you installed, they can be same or different. Although you always use commands in your shell, but they actually have nearly nothing to do with your shell(This even apply to Windows/OS X/*BSD), just learn about how your shell work.
It's just some distros will default-ly install some common software for you, so you get some common commands available. Like you can use
ls on almost all distros just 'cause almost all distros install the
linux-utils software for you.
In some distros, you have more freedom to choose the packages you want, in that case, you may not get
ls available if you refuse to install
linux-utils or any software that can provide this command. Also notice that different software packages MAY conflict with each other if they provide commands with the same name.
How a command line is interpreted depends on the shell that is running and how the called program interprets its arguments.
There's a number of different shells, and a command line using a particular feature of one shell may not work on another shell.
That said, in general, the various Linux distros all include at least the same basic shells, so if you can make sure you are executing the same shell, you can use the same command line. (That's why in shell scripts you usually put the needed shell in the first line).
Look at the shell scripts e.g. in old-style
/etc/init.d, and each of those starts with
So these expect some sort of standard shell, which e.g. on Debian is provided by
dash. To compare, the shell scripts I write for myself start with
because I sometimes use
bash extensions. There's a ton of other shells, see e.g. here