eg-253:unix1
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
eg-253:unix1 [2007/09/19 23:58] – eechris | eg-253:unix1 [2011/01/14 12:45] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== UNIX Tutorial One ====== | ||
+ | |||
+ | ===== 1.1 Listing files and directories ===== | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ==== ls (list) ==== | ||
+ | |||
+ | When you first login, your current working directory is your home directory. Your home directory has the same name as your user-name, for example, **ubuntu**, and it is where your personal files and subdirectories are saved. | ||
+ | To find out what is in your home directory, type | ||
+ | < | ||
+ | |||
+ | The '' | ||
+ | There may be no files visible in your home directory, in which case, the UNIX prompt will be returned. Alternatively, | ||
+ | |||
+ | '' | ||
+ | |||
+ | To list all files in your home directory including those whose names begin with a dot, type | ||
+ | < | ||
+ | |||
+ | '' | ||
+ | |||
+ | ===== 1.2 Making Directories ===== | ||
+ | |||
+ | |||
+ | |||
+ | ==== mkdir (make directory) ==== | ||
+ | |||
+ | We will now make a subdirectory in your home directory to hold the files you will be creating and using in the course of this tutorial. To make a subdirectory called **unixstuff** in your current working directory type | ||
+ | < | ||
+ | |||
+ | To see the directory you have just created, type | ||
+ | < | ||
+ | |||
+ | ===== 1.3 Changing to a different directory ===== | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ==== cd (change directory) ==== | ||
+ | |||
+ | The command '' | ||
+ | |||
+ | To change to the directory you have just made, type | ||
+ | < | ||
+ | ubuntu@ubuntu: | ||
+ | |||
+ | Note how, in Ubuntu, the prompt changes to show you that you have changed directory. Type '' | ||
+ | |||
+ | ==== Exercise 1a ==== | ||
+ | |||
+ | Make another directory inside the **unixstuff** directory called **backups** | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== 1.4 The directories . and .. ===== | ||
+ | |||
+ | Still in the **unixstuff** directory, type | ||
+ | < | ||
+ | |||
+ | As you can see, in the **unixstuff** directory (and in all other directories), | ||
+ | |||
+ | In UNIX, (.) means the current directory, so typing((there is a space between cd and the dot)) | ||
+ | < | ||
+ | means stay where you are (the unixstuff directory). | ||
+ | |||
+ | |||
+ | This may not seem very useful at first, but using (.) as the name of the current directory will save a lot of typing, as we shall see later in the tutorial. | ||
+ | |||
+ | (..) means the parent of the current directory, so typing | ||
+ | < | ||
+ | will take you one directory up the hierarchy (back to your home directory). Try it now. | ||
+ | |||
+ | Note: typing '' | ||
+ | |||
+ | ===== 1.5 Pathnames ===== | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ==== pwd (print working directory) ==== | ||
+ | |||
+ | Pathnames enable you to work out where you are in relation to the whole file-system. For example, to find out the absolute pathname of your home-directory, | ||
+ | < | ||
+ | |||
+ | The full pathname will look something like this -- | ||
+ | |||
+ | **/ | ||
+ | |||
+ | which means that ubuntu (your home directory) is in the directory / | ||
+ | |||
+ | |||
+ | |||
+ | ==== Exercise 1b ==== | ||
+ | |||
+ | Use the commands '' | ||
+ | |||
+ | (Remember, if you get lost, type '' | ||
+ | |||
+ | ===== 1.6 More about home directories and pathnames ===== | ||
+ | |||
+ | |||
+ | ==== Understanding pathnames ==== | ||
+ | |||
+ | First type '' | ||
+ | < | ||
+ | to list the conents of your **unixstuff** directory. | ||
+ | |||
+ | Now type | ||
+ | < | ||
+ | |||
+ | You will get a message like this -- | ||
+ | |||
+ | '' | ||
+ | |||
+ | The reason is, **backups** is not in your current working directory. To use a command on a file (or directory) not in the current working directory (the directory you are currently in), you must either '' | ||
+ | < | ||
+ | |||
+ | |||
+ | ==== ~ (your home directory) ==== | ||
+ | Home directories can also be referred to by the tilde **~** character. It can be used to specify paths starting at your home directory. So typing | ||
+ | < | ||
+ | will list the contents of your **unixstuff** directory, no matter where you currently are in the file system. | ||
+ | |||
+ | What do you think | ||
+ | < | ||
+ | would list? | ||
+ | |||
+ | What do you think | ||
+ | < | ||
+ | would list? | ||
+ | |||
+ | |||
+ | ===== Summary ===== | ||
+ | |||
+ | ^ **Command** | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | |||
+ | ---- | ||
+ | |||
+ | [[eg-253: | ||
+ | |||
+ | --- // | ||
eg-253/unix1.txt · Last modified: 2011/01/14 12:45 by 127.0.0.1