Linux Know-How provides a collection of introductory texts on often needed Linux skills.


Exercises - Bash Scripts

These are some exercises to warm you up for the next chapter:

  1. Where is the bash program located on your system?

  2. Use the --version option to find out which version you are running.

  3. Which shell configuration files are read when you login to your system using the graphical user interface and then opening a terminal window?

  4. Are the following shells interactive shells? Are they login shells?

    • A shell opened by clicking on the background of your graphical desktop, selecting "Terminal" or such from a menu.

    • A shell that you get after issuing the command ssh localhost.

    • A shell that you get when logging in to the console in text mode.

    • A shell obtained by the command xterm &.

    • A shell opened by the mysystem.sh script.

    • A shell that you get on a remote host, for which you didn't have to give the login and/or password because you use SSH and maybe SSH keys.

  5. Can you explain why bash does not exit when you type Ctrl+C on the command line?

  6. Display directory stack content.

  7. If it is not yet the case, set your prompt so that it displays your location in the file system hierarchy, for instance add this line to ~/.bashrc:

    export PS1="\u@\h \w> "

  8. Display hashed commands for your current shell session.

  9. How many processes are currently running on your system? Use ps and wc, the first line of output of ps is not a process!

  10. How to display the system hostname? Only the name, nothing more!


Last Update: 2010-12-16