Working with files

It is a file system

© 2010, 2011, 2012 Dennis Leeuw dleeuw at made-it dot com
License: GPLv2 or later

Index

    1. Introduction
    2. LiSting files
    3. MaKing DIRectories
    4. Making empty files
    5. ReMoving DIRectories
    6. ReMoving files
    7. MoVing files
    8. CoPy a file

Introduction

Before we can start looking into the way GNU/Linux systems work with storage systems, we first need to make ourselfs aquinted with basic file system tools. Things like:

This section is simple introduction to the basic commands on a GNU/Linux system that we expect you to know in the following documents. If you are already familiar with a GNU/Linux system you can safely move on to the following document.

A more in depth document about rights and ownership of files within a filesystem is handled in a later document.

LiSting files

To view what is available on a filesystem you should use the ls command, which is short for list.

ls

To see the contect of a certain directory use the directory name as a parameter like this:

ls testdir

MaKing DIRectories

One uses computers to store files. If you have a lot of files to store you want to organize your files in logical groups. These groups of files are called directories, or folders. A directory, a unit that can contain files, is created by the mkdir command.

mkdir testdir

Making empty files

There are several ways to create an empty file on a GNU/Linux system. The most used one is probably by using the touch command.

touch testdir/emptyfile

ReMoving DIRectories

Empty directories can be removed from a system by using the rmdir command. If there are still files in the directory rmdir refuses to remove the directory. Test this yourself by using:

rmdir testdir

ReMoving files

To remove a file we have the rm command. So to empty our testdir we can use:

rm testdir/emptyfile

On GNU/Linux systems there is no such thing as undelete. What you remove is really gone. On most systems you hear people complain that the computer doesn't do what they want. On GNU/Linux systems this is quite the opposite.

MoVing files

To rename a file there is the mv command:

mv testdir testdir2
As you can see it can not only rename files, but also directories.

CoPy a file

To make a copy of a file one has several options, but the best known one is the cp command:

touch testdir2/testfile
cp testdir2/testfile testdir2/testfile2