...
mkdir: Create the DIRECTORY(ies), if they do not already exist
Info |
---|
Navigating to you |
Code Block |
---|
$ cd
[~]$ ls
Desktop Documents Downloads
[~]$ mkdir folder01
[~]$ ls
Desktop Documents Downloads folder01
|
Info |
---|
Try creating that folder again. What happens? |
Code Block |
---|
[~]$ mkdir folder01
mkdir: cannot create directory ‘folder01’: File exists
|
Note |
---|
If a folder already exists, you can not make it again. |
Info |
---|
Navigate into this folder and print the current working directory. |
Code Block |
---|
[~]$ cd folder01/ [folder01]$ pwd /home/<username>/folder01 |
Info |
---|
If a folder already exists, you can not make it again. |
...
mkdir: Create the DIRECTORY(mkdir: Create the DIRECTORY(ies), if they do not already exist
Info |
---|
Within Navigate into |
Code Block |
---|
[folder01]$ mkdir folder02 folder03
[folder01]$ ls
folder02 folder03
[folder01]$ cd folder02/
[folder02]$ pwd
/home/<username>/folder01/folder02
[folder02]$ cd ../..
[~]$ pwd
/home/<username> |
Info |
---|
Notice: You can create multiple folders at the same time. |
...
mv: Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY
Info |
---|
Renaming a file is the same as moving it to a new name. Navigate to your home and create a file called |
Code Block |
---|
[]$ cd # Create an empty file. $ cd [~]$ touch myfil.txt [~]$ ls Desktop Documents Downloads folder01 myfil.txt # Rename the file ‘myfil.txt’ to ‘myfile.txt’: |
Info |
---|
Move this file from |
Code Block |
---|
[~]$ mv myfil.txt myfile.txt [~]$ ls Desktop Documents Downloads folder01 myfile.txt |
...
mv: Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY
Code Blockinfo |
---|
# Move the file ‘myfile.txt’ into the directory ‘folder01’ |
Code Block |
---|
[~]$ mv myfile.txt folder01/ [~]$ ls Desktop Documents Downloads folder01 # Demonstrate how to ‘ls’ what is in a relative folder. [~]$ ls folder01/ folder02 myfile.txt myfile.txt |
Info |
---|
Notice how we used |
...
cp: Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY
Code Blockinfo |
---|
# Navigate back to home:home and create a file called |
Code Block |
---|
[]$ cd # Use the touch command to create an empty file. [~]$ touch myfile02.txt [~]$ ls Desktop Documents Downloads folder01 myfile02.txt # Copy |
Info |
---|
Copy (duplicate) this file to a new file .called |
Code Block |
---|
[~]$ cp myfile02.txt myfile02b.txt
[~]$ ls
Desktop Documents Downloads folder01 myfile02b.txt myfile02.txt
# Copy a file into an existing folder.
|
Info |
---|
Copy file |
Code Block |
---|
[~]$ cp myfile02b.txt folder01/
[~]$ ls folder01/
folder02 folder03 myfile02b.txt myfile.txt |
...
cp: folders
Code Block |
---|
[~]$ cp folder01 cp: missing destination file operand after 'folder01' Try 'cp --help' for more information. [~]$ ls folder01 folder02 myfile02b.txt myfile.txt [~]$ cp folder01 folder03folder04 cp: -r not specified; omitting directory 'folder01’ |
...
Code Block |
---|
[~]$ cp –r folder01 folder03folder04 [~]$ ls Desktop Documents Downloads folder01 folder03folder04 myfile02b.txt myfile02.txt [~]$ ls folder03folder04 folder02 myfile02b.txt myfile.txt |
...
Code Block |
---|
[~]$ ls Desktop Documents Downloads folder01 folder03folder04 myfile02b.txt myfile02.txt [~]$ mkdir folder04folder05 [~]$ ls Desktop Documents Downloads folder01 folder03folder04 folder04folder05 myfile02b.txt myfile02.txt # Can remove folder04folder05 since it is empty. [~]$ rmdir folder04folder05 [~]$ ls Desktop Documents Downloads folder01 folder03 myfile02b.txt myfile02.txt [~]$ rmdir folder03folder04/ rmdir: failed to remove 'folder03folder04/': Directory not empty |
Info |
---|
You can not use |
...
Code Block |
---|
[~]$ cd [~]$ cd folder03folder04 [folder03folder04]$ ls folder02 myfile02b.txt myfile.txt [folder03folder04]$ ls folder02/ [folder03folder04]$ # ‘folder02’ is empty. [folder03folder04]$ rmdir folder02/ [folder03folder04]$ ls myfile02b.txt myfile.txt [folder03folder04]$ rm myfile.txt [folder03folder04]$ ls myfile02b.txt [folder03folder04]$ rm myfile02b.txt |
...
rm: Remove (unlink) the FILE(s)
Code Block |
---|
[folder03folder04]$ ls [folder03folder04]$ # ‘folder03’‘folder04’ is now empty. [folder03folder04]$ cd .. [~]$ rmdir folder03folder04/ [~]$ ls Desktop Documents Downloads folder01 myfile02b.txt myfile02.txt # This has taken a lot of individual steps. # Can we do this quicker? |
...