Linux Know-How provides a collection of introductory texts on often needed Linux skills.


File management

Command Explanation/Remarks
cp src dest 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 src dest Copy a file from/to a DOS file system (no mounting of the DOS file system 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 file system.
mv src dest 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 src dest 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 file system, hard links to directories or special files are impossible.
ln -s src dest 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 file system. 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.
mc 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.
xwc (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.


Last Update: 2010-12-16