[an error occurred while processing this directive]

6.6 File management

cp source destination

Copy files. E.g., cp /home/stan/existing_file_name . will copy a file to my current working directory. Use the "-R" option (stands for "recursive") to copy the contents of whole directory trees, e.g. , cp -R my_existing_dir/ ~ will copy a subdirectory under my current working directory to my home directory.

mcopy source destination

Copy a file from/to a DOS filesystem (no mounting of the DOS filesystem is necessary). E.g., mcopy a:\autoexec.bat ~/junk. See man mtools for other commands that can access DOS files without mounting: mdir, mcd, mren, mmove,mdel,mmd,mrd,mformat .... We don't use the mtool commands that often--operations on DOS/MS Windows files can be performed using regular Linux commands after you mount the DOS/MS Windows filesystem.

mv source destination

Move or rename files. The same command is used for moving and renaming files and directories.

rename string replacement_string filename

Flexible utility for changing parts of filenames. For example:

rename .htm .html *.htm

ln source destination

Create a hard link called destination to the file called source. The link appears as a copy of the original files, but in reality only one copy of the file is kept, just two (or more) directory entries point to it. Any changes to the file are automatically visible throughout. When one directory entry is removed, the other(s) stay(s) intact. The limitation of the hard links are: the files have to be on the same filesystem, hard links to directories or special files are impossible.

ln -s source destination

Create a symbolic (soft) link called "destination" to the file called "source". The symbolic link just specifies a path where to look for the "real" file. In contradistinction to hard links, the source and destination do not have to be on the same filesystem. In comparison to hard links, the drawback of symbolic links are: if the original file is removed, the link is "broken"--it points to nowhwere; symbolic links can create circular references (like circular references in spreadsheets or databases, e.g., "a" points to "b" and "b" points back to "a"). In short, symbolic links are a great tool and are very often used (more often than hard links), but they can create an extra level of complexity.

rm files

Remove (delete) files. You must own the file in order to be able to remove it (or be "root"). On many systems, you will be asked for a confirmation of deletion; if you don't want this, use the "-f" (=force) option, e.g., rm -f * will remove all files in my current working directory, no questions asked.

mkdir directory

Make a new directory.

rmdir directory

Remove an empty directory.

rm -r files

(recursive remove) Remove files, directories, and their subdirectories. Careful with this command as root--you can easily remove all files on the system with such a command executed on the top of your directory tree, and there is no undelete in Linux (yet). But if you really wanted to do it (reconsider), here is how (as root):

rm -rf /*

rm -rf files

(recursive force remove). As above, but skip the prompt for confirmation, if one is set on your system. Careful with this command particularly as root--see the command above.


Launch the "Midnight Commander" file manager (looks like "Norton Commander" for Linux). According to some computer dinosaurs, this is the best file manager ever.

konqueror &

(in X terminal) Launch the KDE file manager. Perhaps this is the utltimate for file managment. Much better that the MS "Windows Explorer". It embeds web browsing, pdf viewing, and more. Really cool.


(in X terminal). Another excellent file manager (called "X Win Commander"). Faster than konqueror, but not as loaded with features.

nautilus &

(in X terminal). A really cool file manager. Slower than konqueror, but offers me goodies like icon-preview of the content of files (!). It even "previews" the contents of sound files! Speedwise, it runs great on my 1.33 GHz computer, but I don't use it on my 133MHz computer.

[an error occurred while processing this directive]