cd:切换目录
语法:cd
[root@localhost Desktop]# cd /home/
[root@localhost home]#
pwd:显示当前目录
[root@localhost home]# pwd
/home
ls:查看当前目录下的文件
[root@localhost home]# ls
manniu
因为ls用的比较多,对应参数
-a :全部的档案,连同隐藏档( 开头为 . 的档案) 一起列出来~
-A :全部的档案,连同隐藏档,但不包括 . 与 .. 这两个目录,一起列出来~
-d :仅列出目录本身,而不是列出目录内的档案数据
-f :直接列出结果,而不进行排序 (ls 预设会以档名排序!)
-F :根据档案、目录等信息,给予附加数据结构,例如:
*:代表可执行档; /:代表目录; =:代表 socket 档案; |:代表 FIFO 档案;
-h :将档案容量以人类较易读的方式(例如 GB, KB 等等)列出来;
-i :列出 inode 位置,而非列出档案属性;
-l :长数据串行出,包含档案的属性等等数据;
-n :列出 UID 与 GID 而非使用者与群组的名称 (UID与GID会在账号管理提到!)
-r :将排序结果反向输出,例如:原本档名由小到大,反向则为由大到小;
-R :连同子目录内容一起列出来;
-S :以档案容量大小排序!
-t :依时间排序
--color=never :不要依据档案特性给予颜色显示;
--color=always :显示颜色
--color=auto :让系统自行依据设定来判断是否给予颜色
--full-time :以完整时间模式 (包含年、月、日、时、分) 输出
--time={atime,ctime} :输出 access 时间或 改变权限属性时间 (ctime)
mkdir: 建立新的文件目录(参数-p建立多级目录)
mkdir
[root@localhost home]# mkdir test
[root@localhost home]# ls
manniu test
[root@localhost home]# mkdir test1/one
mkdir: cannot create directory ‘test1/one’: No such file or directory
[root@localhost home]# mkdir -p test1/one
[root@localhost home]# ls
manniu test test1
rmdir:删除空目录(参数-p连同上层空目录一起删去)
rmdir
[root@localhost home]# rmdir test1/one/
[root@localhost home]# ls
manniu test1
[root@localhost home]# mkdir test1/two
[root@localhost home]# ls test1/
two
[root@localhost home]# rmdir -p test1/two/
[root@localhost home]# ls
manniu
cp:复制文档或目录,
cp
[root@localhost home]# cp /software/redis-3.0.5.tar.gz /home/
[root@localhost home]# ls
manniu redis-3.0.5.tar.gz
[root@localhost home]# cp -r /software/redis-3.0.5/ /home/
[root@localhost home]# ls
manniu redis-3.0.5 redis-3.0.5.tar.gz
[root@localhost home]# cp /software/redis-3.0.5/ /home/
cp: omitting directory ‘/software/redis-3.0.5/’
从其他目录下面复制文件过来,cp其实很多参数。用的时候再说吧,我一般用的最多的就是-r,其实就是类似于window里面复制文件,复制文件夹。
rm(移除文档或目录)
rm
不加参数,删除文件。-r目录的删除,-f强制删除。(我经常用的~.~)
[root@localhost home]# ls
manniu redis-3.0.5 redis-3.0.5.tar.gz
[root@localhost home]# rm -r redis-3.0.5
rm: descend into directory ‘redis-3.0.5’? y
rm: remove regular file ‘redis-3.0.5/.gitignore’? ^Z
[2]+ Stopped
[root@localhost home]# rm -rf redis-3.0.5
[root@localhost home]# ls
manniu redis-3.0.5.tar.gz
[root@localhost home]# rm redis-3.0.5.tar.gz
rm: remove regular file ‘redis-3.0.5.tar.gz’? y
mv(移动文件或目录)
mv
参数:
-f :force 强制的意思,强制直接移动而不询问;
-i :若目标档案 (destination) 已经存在时,就会询问是否覆盖!
-u :若目标档案已经存在,且 source 比较新,才会更新 (update)
[root@localhost home]# ls
manniu
[root@localhost home]# mkdir test
[root@localhost home]# mkdir test1
[root@localhost home]# ls
manniu test test1
[root@localhost home]# mv test test1/
[root@localhost home]# ls
manniu test1
[root@localhost home]# ls test1/
test
文件的查找:
which
一般的which只找出一个结果,加上参数-a,同名的结果也会被列出来。
[root@localhost home]# which mongod
/usr/bin/mongod
[root@localhost home]# which mongod -a
/usr/bin/mongod
/bin/mongod
whereis(寻找特定档案)
whereis
-b :只找 binary 的档案
-m :只找在说明文件 manual 路径下的档案
-s :只找 source 来源档案
-u :没有说明档的档案!
[root@localhost home]# whereis mongod
mongod: /usr/bin/mongod /etc/mongod.conf /usr/share/man/man1/mongod.1
[root@localhost home]# whereis -m mongod
mongod: /usr/share/man/man1/mongod.1
find
find [PATH] [option] [action]
下面这个是根据文件的名字来进行寻找,因为find是直接操作硬盘的,我表示在虚拟机上慢的很。这仅仅是-name一个参数,因为我一般也就用这个,其他还有很多参数。还是用的时候再加上来
[root@localhost home]# find / -name mongod
find: ‘/run/user/1000/gvfs’: Permission denied
/run/lock/subsys/mongod
/etc/sysconfig/mongod
/etc/rc.d/init.d/mongod
/usr/bin/mongod