The home directory path will look different on different operating systems.\n",
"On Linux it may look like /home/nelle, and on Windows it will be similar to C:\\Documents and Settings\\nelle or C:\\Users\\nelle.
\n",
"(Note that it may look slightly different for different versions of Windows.) In future examples, we've used Mac output as the default - Linux and Windows output may differ slightly, but should be generally similar.
Notice that there are two meanings for the / character.\n",
"When it appears at the front of a file or directory name,\n",
"it refers to the root directory. When it appears inside a name,\n",
"it's just a separator.
If you try to use an option (flag) that is not supported, ls and other programs\n",
"will usually print an error message similar to:
$ ls -j\n",
"ls: invalid option -- 'j'\n", "Try 'ls --help' for more information.\n", "
The other way to learn about ls is to type
In addition to the hidden directories .. and ., you may also see a file\n",
"called .bash_profile. This file usually contains shell configuration\n",
"settings. You may also see other files and directories beginning\n",
"with .. These are usually files and directories that are used to configure\n",
"different programs on your computer. The prefix . is used to prevent these\n",
"configuration files from cluttering the terminal when a standard ls command\n",
"is used.
The special names . and .. don't belong to cd;\n",
"they are interpreted the same way by every program.\n",
"For example,\n",
"if we are in /Users/nelle/data,\n",
"the command ls .. will give us a listing of /Users/nelle.\n",
"When the meanings of the parts are the same no matter how they're combined,\n",
"programmers say they are orthogonal:\n",
"Orthogonal systems tend to be easier for people to learn\n",
"because there are fewer special cases and exceptions to keep track of.
The shell interprets the character ~ (tilde) at the start of a path to\n",
"mean \"the current user's home directory\". For example, if Nelle's home\n",
"directory is /Users/nelle, then ~/data is equivalent to\n",
"/Users/nelle/data. This only works if it is the first character in the\n",
"path: here/there/~/elsewhere is not here/there/Users/nelle/elsewhere.
Another shortcut is the - (dash) character. cd will translate - into\n",
"the previous directory I was in, which is faster than having to remember,\n",
"then type, the full path. This is a very efficient way of moving back\n",
"and forth between directories. The difference between cd .. and cd - is\n",
"that the former brings you up, while the latter brings you back. You can\n",
"think of it as the Last Channel button on a TV remote.
Starting from /Users/amanda/data/,\n",
"which of the following commands could Amanda use to navigate to her home directory,\n",
"which is /Users/amanda?
cd .cd /cd /home/amandacd ../..cd ~cd homecd ~/data/..cdcd ... stands for the current directory./ stands for the root directory./Users/amanda./Users.~ stands for the user's home directory, in this case /Users/amanda.home in the current directory if it exists.Using the filesystem diagram below, if pwd displays /Users/thing,\n",
"what will ls -F ../backup display?
../backup: No such file or directory2012-12-01 2013-01-08 2013-01-272012-12-01/ 2013-01-08/ 2013-01-27/original/ pnas_final/ pnas_sub/backup in /Users.Users/thing/backup,\n",
" but with .. we asked for one level further up.../backup/ refers to /Users/backup/.Assuming a directory structure as in the above Figure\n",
"(File System for Challenge Questions), if pwd displays /Users/backup,\n",
"and -r tells ls to display things in reverse order,\n",
"what command will display:
pnas_sub/ pnas_final/ original/\n",
"ls pwdls -r -Fls -r -F /Users/backuppwd is not the name of a directory.ls without directory argument lists files and directories\n",
" in the current directory.Nelle names her directories \"year-month-day\",\n", "with leading zeroes for months and days,\n", "because the shell displays file and directory names in alphabetical order.\n", "If she used month names,\n", "December would come before July;\n", "if she didn't use leading zeroes,\n", "November ('11') would come before July ('7'). Similarly, putting the year first\n", "means that June 2012 will come before June 2013.
\n", "\n", "Keypoints:
\n", "cd path changes the current working directory.\"ls path prints a listing of a specific file or directory; ls on its own lists the current working directory.\"pwd prints the user's current working directory.\"/ on its own is the root directory of the whole file system.\"/ on Unix, but \\\\ on Windows.\".. means 'the directory above the current one'; . on its own means 'the current directory'.\"something.extension. The extension isn't required, and doesn't guarantee anything, but is normally used to indicate the type of data in the file.\"