文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Commands for using Directories in Linux

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
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 you’ll see the following message:
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 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???

相关阅读 更多 +
排行榜 更多 +
骑战烈火之剑作弊菜单版

骑战烈火之剑作弊菜单版

角色扮演 下载
越狱模拟器无限金币版

越狱模拟器无限金币版

角色扮演 下载
破烂水手手机版

破烂水手手机版

冒险解谜 下载