Command Line
A reference
cd
cd <directory-name>
- Changes directory to "directory-name" within current directory
- Changing directories is always relative to your current directory
- Use tab to autocomplete directory names
.
refers to the current directory..
refers to the parent of the current directory~
refers to the user's home directory- Use
/
to string multipe commands together
Examples:
cd example
cd ../..
cd ~/Desktop
ls
ls
- Lists all items within the current directory
Examples:
ls
mkdir
mkdir <dir-name>
- Creates a new directory named "dir-name"
- Can be used to create new directory within a different directory
Examples:
mkdir new
mkdir example/new
mv
mv <one> <two>
- Used to move or rename files or directories
mv -r
should be used to move entire directories
Examples:
mv old.txt new.txt
mv dir-old/ dir-new/
mv hello.txt ~/Desktop/example/.
mv hello.txt ~/Desktop/example/goodbye.txt
mv -r full-dir ~/Desktop/stuff
cp
cp <one.txt> <two.txt>
- Used to copy files or directories
cp -r
should be used to copy entire directories
Examples:
cp one.txt two.txt
cp -r dir-one/ dir-two/
cp hello.txt ~/Desktop/example/.
cp hello.txt ~/Desktop/example/goodbye.txt
cp -r full-dir ~/Desktop/stuff
rm
rm <one.txt>
- Used to delete files or directories
- Be careful with
rm
. Once deleted, it's gone! rm -r
should be used to delete entire directories
Examples:
rm one.txt
rm -r dir-one/