Filesystem
- Directories -- analogous to folders in Windows or OS X
- Subdirectories -- analogous to subfolders Windows or OS X
- Highest directory is "/"
Filesystem Commands
- ls: lists the contents of a directory
- cd [directory_path]: goes into a directory
- mkdir [dir_name]: makes a new directory
- rmdir [dir_name]: removes a directory
- touch [file_name]: creates an empty file
It's Your Turn 1
Goal: to set up a directory with two files
-
Make a directory called "cs21"
- Go into "cs21"
- Create a new dir called "hw01"
- Create a new dir called "hw02"
- List the contents of "cs21"
Time Savers
cd takes you back to your home directory (back to /home/username)
cd .. takes you one directory up
cd - takes you back to the directory you were just at
pwd prints the working directory; tells you where you are
Tilda: ~ is a shorthand for home directories
cd ~ is equivalent to cd /home/your_home_dir
cd ~jk is equivalent to cd /home/jk
Tab completion:
hitting the TAB key will complete the name of the file or directory for you; tabbing
twice will produce a list of possible filenames if more than one exists.
It's Your Turn 2
Goal: to explore the cd command; to go into a specific folder
In "cs21"
- Print the working directory
- In "cs21", make a new directory called "usingunix"
- Go into "usingunix"
- Type cd
- Where do you end up? (Print the working directory)
- Get to "usingunix" again
- Type cd ..
- Where do you end up? (Print the working directory)
- List the contents of the /scratch/usingunix directory in the long format.
Filesystem Commands
mv [file1] [file2] : renames a file
cp [file1] [file2] : copy the contents of one file to another file (copy)
rm [file] : remove a file
It's Your Turn 3
Goal: to manipulate files using mv, cp and rm.
- In your "cs21" dir, rename "usingunix" to be "UsingUnix"
- copy the files from /scratch/usingunix into your UsingUnix dir
- List the contents of the directory
- view the contents of a file with less filename
Smart Programming: make backup versions of your work with cp
|