Commands for using Directories in Linux
时间:2007-04-11 来源:zhangzijian
原文:http://www.reallylinux.com/docs/direct.html
Manipulating Directories and Files
This 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.
NOTE:
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.
Directory Related Commands
Command |
Summary Use |
cd |
Use 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: cd games If the directory games is not located hierarchically below the current directory, then the complete path must be written out. Ex: cd /usr/games To move up one directory, use the shortcut command. Ex: cd ..
Use cp -r to copy a directory and all of its contents |
mkdir |
Use mkdir to make/create a brand new directory Type mkdir followed by the name of a directory. Ex: mkdir testdir |
mv |
Use 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 |
pwd |
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! |
rmdir |
Use rmdir to remove an existing directory (assuming you have permissions set to allow this). Type rmdir followed by a directory's name to remove it. Ex: rmdir testdir You CAN'T remove a directory that contains files with this command. A more useful command is rm -r that removes directories and files within the directories. You can read more 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: Manipulating Files.
Need More Information or Help???
- Much more beginner Help at a glance
- Installation help and detailed tips
- Server configuration help including httpd, ftp, telnet, mysql
- Help and Tips from our message boards