I am trying to learn basic commands in the terminal. I have a couple of quick questions. I know that to make a file and place it in a specific folder, one needs to create the directory and then use touch
to create an empty file and place it there by mv
:
mkdir folder/sub
touch file.txt
mv file.txt folder/sub
Could we somehow chain these things together and use touch
to create a file and place it in a specific directory in just one line?
and then if I am in a sub-directory, in order to get back from there (say: folder/sub) to my home, either of these three commands would work (cd
, cd -
, cd ..
) I am not sure I get the differences among the three. I get that cd ..
takes you back one step up but the other two seem to work exactly the same.
and let's say I have already a text file in my home directory named file.txt
. If I write this in shell it overrides that existing file:
cp folder/sub/file.txt ~/
How would I go about this if I wanted to keep both files?