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 examplecd ../..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 newmkdir example/new
mv
mv <one> <two>
- Used to move or rename files or directories
mv -rshould be used to move entire directories
Examples:
mv old.txt new.txtmv dir-old/ dir-new/mv hello.txt ~/Desktop/example/.mv hello.txt ~/Desktop/example/goodbye.txtmv -r full-dir ~/Desktop/stuff
cp
cp <one.txt> <two.txt>
- Used to copy files or directories
cp -rshould be used to copy entire directories
Examples:
cp one.txt two.txtcp -r dir-one/ dir-two/cp hello.txt ~/Desktop/example/.cp hello.txt ~/Desktop/example/goodbye.txtcp -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 -rshould be used to delete entire directories
Examples:
rm one.txtrm -r dir-one/