Running Multiple Linux Commands at the Command Line Prompt – Linux Training Quick Tips For Commands


You can save a lot of time by running multiple Linux commands at once, by typing them in on the same line and separating them with “spacebar, semicolon, spacebar” as you will see in the commands examples below.

The output of each command will show on a separate line.

Keep in mind that some commands don’t have output.

For example, when you run the cd command, the prompt will likely change appearance and show the new current directory or the new full directory path, but there is no other output for this command.

Examples of Running Multiple Linux Commands on a Single Line

Change into the home directory of the Linux user you are currently logged in as with the first command below and then run the pwd command to see the “path to working directory” for your current directory.

    $ cd ~ ; pwd

In most Linux distributions, your home directory path will be /home/username, where username is the name of the user you are currently logged in as.

However, if you are logged in as the root user, which is the name of the Linux administrative user, your home directory will be /root.

If you are working at the command line from a Linux desktop as the root user, run the following commands to “log out” and work as a “regular” (non-root) user and see your current full directory path.

    $ exit ; pwd

If you are using Red Hat, Fedora, SUSE, Debain and many other Linux distributions, but not Ubuntu or variations of Ubuntu, such as Kubuntu or Edubuntu, then run the following su command (with the dash option) to start working at the command line prompt as the root user.

Run “su -” (without quotes) and then you will need to type in the password of the root user and press Enter. This command must be run without other commands on the same line.

The far right character in of your command line prompt likely changed from $ to # to indicate you are working as the root user – or changed from > to # if you are using SUSE, openSUSE or some other Linux distributions.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.