Location in the file system and lookin' around ================================================ You need to know your location in the file structure and how to move around in it. Your current location is found by issuing the "print working directory" command (ignore the % sign below, it is just supposed to indicate the cursor on the monitor screen) :: % pwd and the response to this "print working directory" command shows you what directory you reside in. To *change* the directory you are in, issue the "change directory command" and indicate the name of the directory you would like to go to. Change to my so-called *home* directory, by issuing :: % cd /lustre/users/coan Verify that you are there by issuing an appropriate command. Were you successful? This action is often referred to as "cd'ing" to somebody's "home area." The home area of a user's account is the top or root of a user's individual file system. It is where you land when you login to a particular linux machine. Efficiently going there is so useful, there are various ways to do it. For example, you can just cd without any arguments: :: % cd You should now be in your home area. Are you? Since typing is tedious, you can get to someone's home area if you know their user name. For example, to get to my home area, include the tilde (~) with the ``cd`` command :: % cd ~coan That's it. You don't need to remember the "absolute path name" (/lustre/users/coan) of my home directory. Often, it is the case you need to alternate back and forth between two directories. Suppose you want to alternate between my home area and yours. Linux remembers the last directory you visited. to get back there from the current directory you are in, the "working directory," just issue the ``cd`` command with a negative sign. Make sure there is a space between cd and the negative sign :: % cd - If your current directory was your home-sweet-home area, then you should now be in my home area. Are you? Alternatively, if you were in my home area you should now be in your home area. Linux also provides a shorthand to refer to your current working directory **and** the directory above that looks a bit like Morse code. If you wish to move to the directory above the one you are currently in, just issue: :: % cd .. The double dots ``..`` are a stand in for the directory "above" you. You can stack the double dots as well. Try this set of commands: :: % cd ~ % cd ../../.. % pwd Where did you land? Now try this. Go to the root directory and try to cd above it: :: % cd / % cd .. What happens? A single dot ``.`` stands for the name of the directory you are currently in, whatever that might be. You typically use the single dot notation if you want to be super specific about moving to a directory directly beneath your current one. This is helpful if, for example, you happen to have more than one directory with the same name. From my own home directory (**not** yours) I would issue the command: :: % cd ./wkshop to reach the directory "wkshop" immediately beneath my home area. We now know how to scamper around the directory structure of our linux machine. How do we see what file(s) each directory contains? We issue the "list" command: :: % ls Go to your home area and see what files it contains. What do you see? The ``ls`` command takes many *switches*. Try the "long format listing" switch ``l``: :: % ls -l Keep a space between the minus sign and ``ls``. What is all that info? By the way, switches (or options) are always separated from the main command by a space. So don't forget! Now, let's get back to all that information. Here is a partial listing of ``ls -l`` applied to the home area of my office linux machine back in June 2013: :: total 3494820 drwxr-xr-x 2 coan prof 4096 Apr 12 12:40 001/ -rw-r--r-- 1 coan prof 136086 Jun 6 1996 004dr.eps -rw-r--r-- 1 coan prof 7510 May 12 2011 00988815.pdf -rwxr--r-- 1 coan prof 13241856 Jul 31 2004 072904.ppt* -rw-r--r-- 1 coan prof 32054 Sep 15 2010 101908_fedex.pdf -rw-r--r-- 1 coan prof 150002 Feb 18 2008 10.1.pdf Oh my, what *is* all that stuff? The first line with the word "total" tells you the total disk space (in 1KB blocks) of all the files contained in that directory. Next, reading left to right, you first see a bunch of letters (maybe r,w,x) and dashes. This is information about what *permissions* apply to this file. (More on that later.) Then there is an integer which lists the number of "hard" links to this file. (I cannot recall ever using this information in my life.) Next comes the *owner* of the file and the membership group this user belongs to. (This could be grads, staff, pond scum, politician, profs, etc.) The owner is important because only the owner, and the system administrator, can change the read,write, execute permissions of a file. Next is the group that the user belongs to, in my case, "prof". This is followed by the size of the file in bytes and the date and time of the last modification to the file. Finally, the name of the file is listed. If you closely, you will see that the 2nd line from the top has a "d" all the way to the left. This signifies that the file in question is a directory, i.e., a file that contains other files. You may be asking how you find out what a command does. Ah, you are an inquisitive penguin! You need to issue the "manual" command. Let's try it for the ``ls`` command to see all the switches available to you for this command: :: % man ls The switches ``a``, ``h`` are handy. Try them out in your home directory. What do you notice? :: % ls -a % ls -lah What did you notice that was different from the plain old ``ls -l`` command? Notice that can group together switches. This is a general feature of linux command. You do **not** need to separate them by individual minus signs and their order is not significant. (Ok, there is one exception i can think of. You can always assume my rule is true and when the command does not behave the way you want, "read the man page on the command," i.e., use the ``man`` command to investigate.) By the way, for details of the manual command ``man`` you can use the ``man`` command itself: :: % man man While we are at it, linux has a command to use if you are not quite sure of the exact name of a specific command. You just guess the name of the putative command (I am not making this up) and issue the ``apropos`` command along with your guess. The result is a short description of various system commands that linux thinks are related. Typically, you get a truckload of information. Try it with one of the commands you have just learned: :: % apropos cd Summary ------- ======================== ========== Command Meaning ======================== ========== pwd display the name of the current directory cd /lustre/users/emily change working directory to /lustre/users/emily cd go to your home directory cd ~paul go to the home directory of the user named *paul* cd - return to previous working directory cd .. go to directory just above current working directory cd / go to the root directory man *command* display help manual for *command* apropos *command* display commands related to *command* ======================== ==========