...
because that is the absolute path to the homework directory.
The latter is more precise because it tells the computer exactly where to look.
The former, on the other hand, implies that since you are currently within the home directory, a ~/ should be appended to the beginning of the relative path (homework).
Keep in mind that the former will, therefore, only work when run in the home directory.
...
Code Block | ||||
---|---|---|---|---|
| ||||
mkdir homework |
and press enter.
This will make a directory called homework.
Once the directory is created, navigate to it using the cd command
...
If you don't feel like typing homework all the way out, just type cd homew and press Tab.
This should autocomplete it for you.
Once you are in the homework directory, you can navigate back the home directory by entering either
...
Now we are going to make a file so you can learn how to remove, move, rename, and copy it.
There are many ways to do this, but for this example we will create a file using a program called vim.
Let's call the file myhw.txt:
...
Vim is an example of an application that runs through the terminal.
Although vim is not a standard bash command, it comes preinstalled on all of the CSIL machines.
Once you are in vim, press i, for insert, and type "Hello, World!".
When you are done, press Esc and then :wq and then enter (this writes/saves the changes and then quits out of vim).
Your new file myhw.txt has now been created.
...
when you run this, you should see myhw.txt along with the homework directory and possibly some other files.
In order to copy "myhw.txt" into the homework directory, type
...
This basically moves the contents of "myhw.txt" and put it inside "yourhw.txt".
The mv and cp commands are very similar, but have one key difference:
cp copies the file and leaves the original, whereas mv moves the file and deletes the original.
Mv can also be used to move files to other directories.
In order to move "yourhw.txt" into your home directory, enter either
...
in order to list your files.
You should see myhw.txt, yourhw.txt, and the directory homework (among other directories).
To prove that we really did copy and move myhw.txt, enter
...
which will remove all files ending in "hw.txt".
Now in order to remove the homework directory, you have to include a flag, which is basically a parameter that specifies how the command should be run:
...