Directories or Folders
- When working on projects we need to organize our files.
- So far, you probably have one or two files per assignment
- The source code file (whatever.cpp)
- The executable (whatever, whatever.exe, ...)
- Will will at least be adding a Makefile, which you will hopefully learn about soon.
- And later we will be adding multiple header and source code files.
- If you keep these all in the same place, things are going to become very disorganized.
- The primary tool for organizing files in the directory or folder.
- Microsoft calls these folders
- Unix based systems call these directories.
- Generally we used directories to store common items.
- I suggest you use a directory for each homework assignment.
- I strongly suggest you use a directory for each project.
- How to see directories
- FileZilla and WinSCP show them to you graphically
- In puTTY, ls will show you directories.
- In linux, ls is a program to show files.
- In most configurations directories have a / following the name.
- Visualizing directories
- Think of directories as a tree.
- At the "bottom" of the tree on a unix/linux system is root
- At EUP all users have are in a directory called home
- There are other top level directories (usr, bin, ...)
- Each of these have directories and files contained in hem.
-
- You can tell where you are on linux by typing
pwd
- Moving between directories.
- The command is
cd
- cd with no arguments will take you to your home directory.
- cd followed by a path will take you to that directory.
- There are two and a half ways to specify a path.
- Absolute paths are where you specify the full path from root.
- /home/CS/dbennett is the absolute path to my home directory.
- On mirkwood, your class notes are in /home/bennett/public_html/class/csci230/spring2021/notes/Tools
- Absolute paths start with a /
- You don't use this very often.
- Relative paths are where you specify the path relative to the current directory.
- If I am in a directory that holds the directory HW1
-
cd HW1
will change to that directory.
- I can specify as many levels as I wish.
- If I am in my home directory, your class notes on Mirkwood are public_html/class/csci230/spring2020/notes/Tools
- Note, the url is also part of the path. (But the public_html is missing)
- Most shells also support tilde (~) notation.
- By it's self ~ means My home directory.
- ~username means that user's home directory.
- You will use ~dbennett this semester.
- ~dbennett/csci230 is my 230 directory.
- Two special path elements
- . means this directory.
- .. means one directory above this one (if it exists)
-
ls .
is silly but will list this directory.
-
ls ..
will list the contents of a directory one level up.
- Creating directories
-
mkdir path
creates a directory.
-
mkdir foo
makes a directory in the current directory.
-
mkdir /foo
would make a directory at root if you had permission, you don't.
- You should
- Create a directory for csci230
- Inside of that create homework and project directories
- Inside each of these, create a directory for each assignment.
- Other commands you might investigate
-
rmdir
- will remove a directory.
-
mv
is the move command, but is really a rename and move
- mv source destination
-
mv hello.cpp world.cpp
will rename hello.cpp to be world.cpp
-
mv ~/hello.cpp .
will move hello.cpp from my home directory to the current directory.
-
cp
is the copy command
- cp source destination
- This will make a copy of the source at the destination.
- Note for both mv and cp, if the destination is a directory, the file will be placed inside the directory.
-
rm
will remove both files and directories.