Linux for Windows Developers - Linux Basics - pwd and ll

The Windows Subsystem for Linux (WSL) runs an Ubuntu user mode image and dropping into bash from your cmd or Powershell puts you in an Ubuntu based terminal. This is obviously aimed at developers, as Microsoft points out:

it’s important to note that this is a developer toolset

Since the WSL is firmly grounded in the command line, you’ll need to get comfortable working there. If you’ve mostly used the Windows GUI to get your work done, you’ll need to spend a little time getting used to navigating and executing code from the command line. As you progress, you’ll find that the Linux command line interface is very powerful and includes a host of tools and an extremely fully featured text editor. Don’t worry, it’s really not that daunting and once your eyes and fingers get a feel for it, you’ll find yourself enjoying the efficiency of the experience.

The first two things you need to know in your explorations are where you are and what files you have. To do this, you need two commands which we will explore in this post: pwd and ls.

First a note about the prompt

I’ll be referring to the prompt - this is what is printed on the command line before your cursor, prompting you to enter your command. Often it is the full path for the directory you are in, but Linux is fully customisable and you can set your prompt up to display pretty much anything. Because a full path can be a fair mouthful, I’ll represent the prompt with a $ symbol throughout. You should not type the first $ you see in any commands that you try out. Your prompt will probably not be a $ by default. That’s fine. In fact, on my system, by default, I open bash from a Powershell console which starts in C:\Users\b\Documents\dev and this causes my default bash prompt to be root@localhost:/mnt/c/Users/b/Documents/dev.

Find out where you are - pwd

The first command you should try out will let you know where in the file system you are. In other words, it will list the full directory that you are current in. This is handy because as mentioned above, your command prompt (literally the text sitting before your cursor) might not show you the full directory structure. Pwd stands for “Present Working Directory” or “Print Working Directory” depending on whom you ask.

Enter the WLS from either your cmd shell or Powershell by typing bash and follow along:

$ pwd

You should see something like the following:


The actual directory listed will depend on what directory you were in when you started bash. It’s important to note that in Linux the forward slash (/) is used as the directory separator (instead of the backslash that Windows uses).

The root of the filesystem is represented by a single forward slash (/), so my present working directory above is two directories away from the root of the filesystem. Don’t be confused by the fact that one of the directories is called root this is not the root of the filesystem.

Get a directory listing - ls

Now that you can find out where you are, you also need to know how to find out what files are sitting in your directory. In Linux, to get a directory listing you use the ls command. Old school Windows users will remember DOS and the dir command. In newer versions of Windows, ls also works for directory listings, so this might feel familiar.

Again, follow along. Remember, you don’t type the initial $, and don’t worry if your directory listing is different to mine - you obviously have different files on your system and you might be in a different folder to me, the output I get is simply representative of the files on my system:

$ ls

The ls command issued without any arguments gives you a listing of the files in the current directory with the files and directories listed in alphabetical order left to right. If I ask for a directory listing of the /etc folder, I get the following output:


An important concept in Linux is that everything is considered a file. A directory is actually just a file whose contents include other files and directories. Configuration settings are all just files, there’s no database of registry settings. No MMC snapin. Jut files. Even I/O devices are exposed in the file system as, you guessed it, files.

Enhance your listing with some arguments

The default file listing shows files from left to right, top to bottom and space separated. It can be an eyeful to look at and you might find it easier to format your directory listing a little. To do this, you pass arguments to the ls command by appending a dash and an argument.

The first useful argument for ls is l.

$ ls -l

This will garner you a long listing format of your directory. In other words your files will be listed one per line preceded by the file permissions and owners.


I find this a little easier to sift through visually. Though, of course, if you have a lot of files in a directory, it can scroll past you pretty quickly.

The second useful argument is a

$ ls -a

This will bring back a list of all files - i.e. it includes files that are preceded with a . - these are often configuration files.


Combine your arguments

Why settle for one argument when you can have two? You can combine your arguments simply by typing them next to each other so if you want a directory listing in long listing format with dotfiles included, you can do this:

$ ls -la


The order of your arguments is not important.

The ll Alias

If typing out ls -la is just too many keystrokes for you, ll will come in very handy. This command is what’s called an alias and it is equivalent to typing ls -laF. We haven’t covered the F argument, but it appends a symbol onto files to help you recognise what type of file they are (for example an appended slash mean directory, a * indicates an executable). So ll will bring back the long list of all files with a file type indicator.

Location and Listing

You learned two very important commands that you’ll find invaluable as you work with the command line. First you learned how to find out what directory you are currently in using pwd and subsequently, you learned how to list the files in the current directory using ls. You also learned how to pass arguments to ls along with a couple of useful arguments to bring back the directory listing in long list format as well as showing all files. Lastly, you learned the ll command which is an alias to ls -laF which produces a long directory listing of all files with file type indicators.