Directories and Files
page is intended to help the Linux newbie come up to speed on
core file and directory commands including file permissions.
Brought to you by the gang here at ReallyLinux.com. If you need
more Basic Commands please click here.
If you're a beginner, it may help you to type the command ls -alt to list all of your
current files and directories.
Type ls -alt after you try each command below to be certain it
worked properly. If you already have experience with directories
and files, then you may want to skip to Commands for Guru Wanna-bees.
All of these commands should work from your command
prompt (regardless which shell you're using). And of course, if
they don't work or help you, we appologize.
cd to change directories. Type cd
followed by the name of a directory to access that
directory. Keep in mind that you are always in a
directory and can navigate to directories hierarchically
above or below. Ex:
If the directory games is not located hierarchically
below the current directory, then the complete path must
written out. Ex:
To move up one directory, use the shortcut command. Ex:
Use cp -r to copy a
directory and all of its contents
Type cp -r followed by the name of an existing directory
and the name of the new directory. Ex:
cp -r testing newdir
You must include the -r or youll see the following
cp: testing is a directory and -r not specified.
This command saves you time if you need to make a mirror
image of a directory packed with files.
mkdir to make/create a brand new
Type mkdir followed by the name of a directory. Ex:
mv to change the name of a directory
Type mv followed by the current name of a directory and
the new name of the directory. Ex:
mv testdir newnamedir
||Trying to find out where on your
Linux server you currently are located? The pwd
(print working directory) command will show you the full
path to the directory you are currently in. This is very
handy to use, especially when performing some of the
other commands on this page!
to remove an existing directory (assuming you have
permissions set to allow this).
Type rmdir followed by a directory's name to remove it.
You CAN'T remove a directory that contains files with this command.
Instead to delete non-empty directories in Linux, use the more useful
This command removes directories and files within the directories. Read more details about this in Commands for Beginning Admins
The rmdir command is used mostly to remove empty directories. If you have a desire to use this command then you'll need
to delete or move the files before attempting to remove a
full directory. For more help please read the mv command and
also File Related Commands.
WAIT! There are MANY more commands. This page only has items
related to directories. The page related to manipulating files is:
Need More Information or Help???