Missing pieces

Everything you should know about technology, but have been missing out

Linux/Unix command line: part 3 - managing files

, , , ,

Computer is made for copying and processing information. So sometimes you need to make directories (to keep things organized), copy and remove files. Just telling what the commands are is not very efficient, so it's better to try those commands out and maybe learn some things about them along the way.

Let's start by making a directory. But let's first make sure that you're in your home directory:

cd


Let's keep home directory and make a directory for our experiment and move to our new directory:

mkdir experiments
cd experiments


So mkdir is command for making directories. That directory is bit empty, let's create some content.

touch foo


Check if the file is really there:

ls


Curious? Let's look inside.

cat foo


Nothing happened. Don't worry though, the file is empty so there was nothing to display. That's what touch does, creates empty files and that's fine for our experiments. Let's continue by creating another directory:

mkdir bar


Now move previously created file to new directory and enter that directory:

mv foo bar
cd bar


Another command again, mv is for moving files.

Oops, we need that file in it's original location too, let's make a copy:

cp foo ..


Make sure that the file is really there:

ls ..


Were done with this directory, let's move back:

cd ..


Let's make copy of a directory:

cp bar test


Didn't work? I guess we missed something:

cp -r bar test


It works now. You need to tell cp that you want to copy whole directory (and all it's files as a side effect). Let's check if everything is OK:

ls test


We're done now, let's clean up.

cd ..
rm experiments


Same mistake again. Let's fix that:

rm -r experiments


Now you should know how to manage your files. And as always, read the manuals if you wan't to know more about commands, most have all kinds of options that could come handy sooner or later.

Back to the IPTVOpera, chat and managing contacts.

Write a comment

New comments have been disabled for this post.

June 2012
M T W T F S S
May 2012July 2012
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30