
Bash, really quick start
Linux bash is going way beyond the scope of this book, but I will cover basic commands, which you may need in your daily work with SQL Server on Linux, such as creating folders, copying files, navigating through a tree of folders, deleting files and folders, listing content of folders and current position in the folder tree.
- pwd
- ls
- cd
- mkdir
- cp
- rm
- rmdir
You can run the command line bash tool in many ways. Here, you can find two of the most common ways. Assuming that you have a KDE environment, click on K menu | System | Konsole.
Alternately, press Alt+Space and start typing Konsole. You will see at the top of the screen a menu with a list of tools, programs, files, and everything else that has the word Konsole in the name. Just choose Konsole Terminal as shown in the following screenshot and press Enter:

After you run the Konsole Terminal bash application, depending on the version of Linux, username, and host name, you should see something like this:

The current location is your Home directory, which is your username.
How do you check what your current position on the directory tree is? The Linux command for this kind of a job is pwd. If you type pwd and press Enter, bash will show your current position on the filesystem, as you can see in the following screenshot:

My current position is /home/dba. The first forward slash is the root directory. It means that home is subdirectory of root.
I believe many of you are familiar with the old DOS command (Windows as well): dir. The Linux equivalent is ls. Take a look at the next screenshot:

When you type just ls without any argument and parameters, it gives you a list of files and folders. The output is not descriptive. But, if you type ls -l, the output is much better. In this case, if you have many files and folders, you will need to scroll a lot; so the first option is better:

The scenario from figure 2-5 can be summarized as follows:
- Check your current position with the pwd command.
dba@openSUSE:~> pwd
- Change the path from home/dba to: /opt/mssql/bin/ with the cd command.
dba@openSUSE:~> cd /opt/mssql/bin/
- Again, check the current position.
dba@openSUSE:~> pwd
- List the content /opt/mssql/bin/ folder with the ls -l command.
dba@openSUSE:~> ls -l
- Go back to home/dba with a single cd command and check your new position with pwd.
dba@openSUSE:~> cd
The next scenario will combine all commands from previous cases with the addition of: creating new folders, copying, and removing files. First, take a look at the following screenshot:

The scenario from figure 2-6 can be summarized as follows:
- Check your current position with the pwd command.
dba@openSUSE:~> pwd
- With the cp command, you will copy the Readme file from the Documents folder to the sql folder. Both folders are on same level, as sub-folders of home/dba (in my case).
dba@openSUSE:~> cp Documents/Readme sql/
- Change the path from home to sql/ with the cd command.
dba@openSUSE:~> cd sql/
- Delete the Readme file from the sql/ folder with the rm command:
dba@openSUSE:~> rm Readme
- List the content sql/ folder with the ls -l command. As you see, the total number of files is 0 because we just deleted Readme.
dba@openSUSE:~> ls -l
- This takes you back to home/dba with the cd command (only one level in the tree, from sql to dba).
dba@openSUSE:~> cd..
- You can't delete folders with the rm command.
dba@openSUSE:~> rm sql/
- You can delete folders with the rmdir command.
dba@openSUSE:~> rmdir sql/
- List the content home/dba folder with the ls -l command. As you see, the sql subfolder is gone from the the list files.
dba@openSUSE:~> ls -l
This quick bash introduction will be enough to start interacting with Linux through the command line interface. You will need some of these commands later in the book to finish some tasks, such as creating backup folders, copying database backups, modifying SQL scripts, and so on. If you would like to learn more about command line on Linux, I would recommend additional reading The Linux Command Line, a book by William Shotts.