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.

  • 1
    This is a hard-to-find-on-internet question, just like any beginner-level questions, asked with some misunderstanding about general level system structure/layers. It's like no community welcome such questions, causing too much pain for beginners. – 炸鱼薯条德里克 Sep 28 '18 at 14:17

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 zsh and 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".

  • So, to put it in a nutshell, there may be some basic standard command lines which works in all of the linux system whereas extra/extended ones do not. – Kaung Sett Sep 28 '18 at 7:45
  • 1
    @KaungSett If the command uses only standard tools and no extended features, then there is a higher probability that it is portable. Between homogenous types of Unices, such as various Linuxes (that are using the same implementation of the tools), it is more probable that the command is portable, depending on what it actually is it's doing. – Kusalananda Sep 28 '18 at 7:49
  • @KaungSett An example of what you're thinking of would be nice. It's all very generic otherwise. – Kusalananda Sep 28 '18 at 7:50
  • @ Kusalananda Thanks for your answer. TBH, I've just started learning the basic of Linux and this question got pop up in my head. I've tried to google it though but none of them seems to answer my question so here I am. – Kaung Sett Sep 28 '18 at 7:54
  • There are no basic/extended commands concept. But built-in functions/user-defined functions/external programs in PATH. You need to know what a shell is, it's not commands provider, but more like a user interface for you to use commands provided by other things.@Kaung Sett – 炸鱼薯条德里克 Sep 28 '18 at 14:09

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

  • Could you please explain a little bit more on "That's why in shell scripts you usually put the needed shell in the first line" ? I didn't get it. – Kaung Sett Sep 29 '18 at 15:16
  • The first line in an executable script supposed to run on a unix based system should look like #!/usr/bin/env <interpreter name>. This is called an interpreter shebang and informs the system which interpreter should be used to translate the rest of the script. The interpreter can be bash, dash, csh, perl or any number of other scripting languages. For example, a python script's first line should look like '#!/usr/bin/env python3'. Granted, you can invoke the script with the interpreter, when the shebang is just a regular comment. But still it is considered a good practice to include it. – Della Dec 3 '18 at 1:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.