The pwd command: Find out where you are
Before we begin, here are a few important things:
1.I use bash(bourne-again shell) to demonstrate the functionality of these commands. So, if you use a different shell, check the documentation of that respective shell.
2.Also, I use ubuntu. So some commands may not necessarily be available across all distros. For example, apt-get is used to install applications in Ubuntu but Fedora uses yum I believe. So, this may not necessarily universal to all shells across all distros.
So let’s start this journey into the command line. First up open up your shell. If you use GNOME, then I think it’s called gnome-terminal(in ubuntu anyway it is so) and if you use KDE, I believe it’s called konsole(a vague memory this is the command in KDE someone confirm this). Just check the Applications -> Accessories you should find it there.
Once you run it, you’ll get something like
The and should be pretty obvious. What comes after the ‘:’ denotes the present working directory. And $ indicates shell I believe(someone please confirm this).
So the first command that we are going to look at is pwd. It stands for Present Working Directory. As the name suggests, it tells you which directory you are currently working on. Type in at the prompt “pwd” and press enter. The output should be something like
If you did get a similar output, there you go: you just executed your first Linux command! Congratulations!
A brief description of Linux directory structure
Unlike in windows, Linux does not have concept of drives. There are only directories(equivalent to folders in windows and sometimes alternatively referred to as folders in linux too) an files. Everything in linux falls under the directory root(denoted by /).
Few common folders in Linux(common to all Linux distros)
/usr – This is where all applications that are to be shared by all users of the system. It is similar to the public shared folder in windows.
/boot – This contains the boot-loader of Ubuntu GRUB(GRand Unified Boot-loader)
/home – This is the folder where each user gets his space to store necessary documents, files etc(similar to My Documents in windows). Also in addition, configuration files of the user is stored in this folder.
/media – This is where all drives(hard drives, USB disks, disk drives etc) will be displayed.(Note: You need to “mount” them in order that they be displayed in this folder).
/tmp – This is where all temporary files are stored. (Similar to TEMP folder in Windows)
A note on the various symbols in Linux shell
Various symbols are used in the linux to denote something so as to allow ease of command line usage.I’ll add more when we deal with more commands. Right now we are going to look at 3 symbols.
1. ‘.’ (Fullstop): This denotes the present working directory(that’s right what pwd returns). But the difference is that while pwd is like a function that returns the present working directory, ‘.’ is an alias can be used to refer to the present working directory in expressions. I’ll clear this soon once we deal with “ls” command.
2. “..”(2 fullstops): This is an alias that’s used to refer to the parent of the present working directory.
3. ‘~’: This is used to refer to the home directory(/home/ for ). That is why you see a ‘~’ when you start the shell; the present working directory is /home/user denoted in shell as ‘~’.