服务器返回上一级目次(windows返回上一级目次)「从服务器返回一个参照win10」

  Linux下令太多,根据每个人利用用途的差别所用到的下令一样平常也差别。本日归纳了一些常用的Linux目次处理惩罚下令,仅供各人学习交换。

  下令提示符

  [root@localhost~]#

  root:当前登任命户

  localhost:主机名

  ~:当前地点的目次,此处为“家”目次

  #:root超等用户的提示符,假如是平凡用户,则为$

  下令格式

  下令[选项][参数]

  中括号[]表现可选

  查询目次中的内容:ls

  ls[选项][文件或目次]

  选项:

  -a:表现全部文件,包罗隐蔽文件

  -l:表现具体信息

  -d:查察目次属性

  -h:人性化表现文件巨细

  -i:表现inode

  根据以上选项,敲入下令,表现结果分别如下:

  [root@localhost~]#ls

  anaconda-ks.cfgtest

  [root@localhost~]#ls-a

  ...anaconda-ks.cfg.bash_history.bash_logout.bash_profile.bashrc.cache.config.cshrc.tcshrctest[root@localhost~]#ls-l

  总用量4

  -rw-------.1rootroot2752Nov1002:51anaconda-ks.cfgdrwxr-xr-x.2rootroot6Nov1219:26test[root@localhost~]#ls-lanaconda-ks.cfg

  -rw-------.1rootroot2752Nov1002:51anaconda-ks.cfg[root@localhost~]#ls-ldtest/

  drwxr-xr-x.2rootroot6Nov1219:26test/

  [root@localhost~]#ls-lh

  总用量4.0K

  -rw-------.1rootroot2.7KNov1002:51anaconda-ks.cfgdrwxr-xr-x.2rootroot6Nov1219:26test[root@localhost~]#ls-i

  71259104anaconda-ks.cfg36099565test

  请留意观察ls-l与ls-lh下令的结果的区别

  这里必要表明一下:

  -rw-------.1rootroot2.7KNov1002:51anaconda-ks.cfgdrwxr-xr-x.2rootroot6Nov1219:26test

  起首第一个符号“-”(引号内的-),表现文件范例(常用的有三种,即-表现文件,d表现目次,l表现软链接文件),别的尚有不常用的,为块装备文件,字符装备文件、套接字文件、管理文件。

  在上述中,我们可以看到anaconda-ks.cfg是一个文件,而test是一个目次(可明白为windows的文件夹的概念)。

  其次,撤除第一个符号,我们来看rw-------,一共有九个字符,需分为三组,分别为rw-,---,---,每个组按照次序分别表现u全部者,g所属组,o其他人的权限。在上述中,分别对应为root,root。即第一个root表现全部者权限为root权限,第二个root表现所属组的权限也是root权限,对于其他人,则无所谓的权限可言。

  此中,r表现可读,w表现可写,x表现实行的权限。

  为了更加明白,对于anaconda-ks.cfg这个文件,这里列一个表格:

前三个字符

中心三个字符

后三个字符

rw-

全部者u的权限

所属组g的权限

o其他人的权限

可读可写

无权限

无权限

  那么,对于test这个文件rwxr-xr-x,请读者自行判定它的权限。

  在九个字符之后的点“.”,表现ACL权限,之后的数字1表现引用计数,比如一个文件有一个软链接(雷同windows快捷方式),那么它的引用计数就是2。

  root背面的2.7k表现文件的巨细,再背面表现日期,末了是文件的名称。

  目次处理惩罚下令

  1

  创建目次:mkdir

  mkdir-p[目次名]

  -p:递归创建

  [root@localhost~]#ls

  anaconda-ks.cfgtest

  [root@localhost~]#mkdirotherFolder

  [root@localhost~]#ls

  anaconda-ks.cfgotherFoldertest

  [root@localhost~]#mkdirfolder_2/test_2

  mkdir:无法创建目次"folder_2/test_2":没有谁人文件或目次[root@localhost~]#mkdir-pfolder_2/test_2

  [root@localhost~]#ls

  anaconda-ks.cfgfolder_2otherFoldertest

  [root@localhost~]#lsfolder_2/

  test_2

  如上所示,mkdir不加选项-p时,可以创建一个空目次,但是无法递归创建一个包罗子目次的目次。加上-p即可递归创建。

  2

  切换地点目次:cd

  cd[目次]

  操纵:

  cd~:进入当前用户的家目次

  cd-:进入前次目次

  cd..:进入上一级目次

  cd:回抵家目次

  [root@localhost~]#ls

  anaconda-ks.cfgfolder_2otherFoldertest

  [root@localhost~]#cd/folder_2/test_2

  [root@localhosttest_2]#cd

  [root@localhost~]#cd-

  /root/folder_2/test_2

  [root@localhosttest_2]#cd../../otherFolder[root@localhostotherFolder]#cd..

  [root@localhost~]#

  留意理清概念:相对路径和绝对路径

  绝对路径:从根目次一级级找下去,必要写全路径

  [root@localhost~]#cdfolder_2/test_2

  [root@localhosttest_2]#

  相对路径:参照当前地点目次举行查找

  [root@localhosttest_2]#cd../../otherFolder

  [root@localhostotherFolder]#

  3

  查询地点目次位置:pwd

  pwd

  可以说是最简单的下令了,查询地点目次的位置

  [root@localhost~]#pwd

  /root

  [root@localhost~]#ls

  anaconda-ks.cfgfolder_2otherFoldertest

  [root@localhost~]#cdfolder_2/

  [root@localhostfolder_2]#ls

  test_2

  [root@localhostfolder_2]#cdtest_2/

  [root@localhosttest_2]#pwd

  /root/folder_2/test_2

  4

  删除空目次:rmdir

  rmdir[目次名]

  只能删除空目次,这个下令用得比力少。

  [root@localhost~]#ls

  anaconda-ks.cfgfolder_2otherFoldertest

  [root@localhost~]#rmdirotherFolder

  [root@localhost~]#ls

服务器返回上一级目录(windows返回上一级目录) 服务器返回上一级目次
(windows返回上一级目次
)「从服务器返回一个参照win10」 行业资讯

  anaconda-ks.cfgfolder_2test

  [root@localhost~]#rmdirfolder_2

  rmdir:删除"folder_2"失败:目次非空

  [root@localhost~]#

  5

  删除文件或目次:rm

  rm-rf[文件或目次]

  r表现可以同时删除文件和目次,f表现逼迫删除

假如不添加任何选项,那么只可以删除文件,删除时提示是否确认删除

假如只添加选项-r,那么可以删除文件也可以删除目次,删除时提示是否确认删除

假如添加了选项-rf,那么将不做任何提示删除文件或目次

  [root@localhost~]#ls

  abc.txtanaconda-ks.cfgfolder_2test

  [root@localhost~]#rmabc.txt

  rm:是否删除平凡空文件"abc.txt"?y

  [root@localhost~]#rmtest

  rm:无法删除"test":是一个目次

  [root@localhost~]#rm-rtest

  rm:是否删除目次"test"?y

  [root@localhost~]#ls

  anaconda-ks.cfgfolder_2

  [root@localhost~]#rm-rffolder_2

  [root@localhost~]#ls

  anaconda-ks.cfg

  [root@localhost~]#

  6

  复制下令:cp

  cp[选项][原文件或目次][目标目次]

  选项:

  -r:复制目次

  -p:同时复制文件属性

  -d:若源文件是链接文件,则复制链接属性

  -a:包罗以上全部选项,相称于-rpd

  在[目标目次]背面加上文件名,就是改名复制。

  [root@localhost~]#ls

  anaconda-ks.cfgbbc.txtfolder_afolder_b

  [root@localhost~]#cpbbc.txtfolder_a

  [root@localhost~]#lsfolder_a/

  bbc.txt

  [root@localhost~]#cpfolder_afolder_b

  cp:略过目次"folder_a"

  [root@localhost~]#cp-rfolder_afolder_b

  [root@localhost~]#lsfolder_b

  folder_atest_1

  [root@localhost~]#ll

  总用量4

  -rw-------.1rootroot2752Nov1002:51anaconda-ks.cfg-rw-r--r--.1rootroot0Nov1317:21bbc.txtdrwxr-xr-x.2rootroot20Nov1317:38folder_adrwxr-xr-x.4rootroot34Nov1317:39folder_b[root@localhost~]#llfolder_a

  总用量0

  -rw-r--r--.1rootroot0Nov1317:38bbc.txt[root@localhost~]#cp-abbc.txtfolder_b

  [root@localhost~]#llfolder_b

  总用量0

  -rw-r--r--.1rootroot0Nov1317:21bbc.txtdrwxr-xr-x.2rootroot20Nov1317:39folder_adrwxr-xr-x.2rootroot6Nov1317:38test_1[root@localhost~]#

  这里必要表明一下的是,在原文件bbc.txt中,其修改时间为17:21,在平凡复制下,它的时间这个属性是不会被复制,我们可以看到复制后的bbc.txt的时间为17:38,假如必要连同属性一起复制,那么就加上-pd大概直接-a,如上所示,我们把bbc.txt复制到folder_b,这时我们查察属性的时间,时间属性和原属性是同等的。

  在上述下令中,ll是ls-l的简写。

  7

  剪切或改名下令:mv

  mv[原文件或目次][目标目次]

假如原文件大概目次与目标目次在同一个目次下,那么就是重定名

假如不在同一个目次下,那么就是剪切

  通过以下实践明白:

  [root@localhost~]#ls

  anaconda-ks.cfgbbc.txt

  [root@localhost~]#mvbbc.txtabc.txt

  [root@localhost~]#ls

  abc.txtanaconda-ks.cfg

  [root@localhost~]#mkdirtest

  [root@localhost~]#ls

  abc.txtanaconda-ks.cfgtest

  [root@localhost~]#mvabc.txttest/

  [root@localhost~]#ls

  anaconda-ks.cfgtest

  [root@localhost~]#lstest/

  abc.txt

  [root@localhost~]#

  8

服务器返回上一级目录(windows返回上一级目录) 服务器返回上一级目次
(windows返回上一级目次
)「从服务器返回一个参照win10」 行业资讯

  链接下令:ln

  ln-s[原文件][目标文件]

  天生链接文件

  -s:创建软毗连

  硬链接的特性:

拥有雷同i节点和存储block块,可以看做是同一个文件

可通过i节点辨认,i节点是雷同的

不能跨分区

不能针对目次利用

  通过上述下令,可以明白为为某个内容添加一个标签,通过打开这个标签就可以进入这个内容,硬毗连,即再天生一个标签,同样可以通过这个标签进入这个内容。

  假如内容被修改,那么不管从硬链接的哪个文件进入,都是被修改的。

  软链接的特性:

雷同windows的快捷方式

软链接拥有本身的i节点和block块,但是数据块只生存原文件的文件名和I节点号,并没有实际的文件数据

lrwxrwxrwxl为软链接(软链接的权限都为rwxrwxrwx,这只是软链接本身的权限)

修改恣意文件,另一个都改变

删除原文件,软链接不能用(和windows的快捷方式一样)

  硬链接:

  [root@localhost~]#ls

  anaconda-ks.cfg

  [root@localhost~]#mkdirfolder

  [root@localhost~]#ls

  anaconda-ks.cfgfolder

  [root@localhost~]#touchbbb.txt

  [root@localhost~]#ls

  anaconda-ks.cfgbbb.txtfolder

  [root@localhost~]#lnbbb.txtfolder/ccc.txt[root@localhost~]#llfolder/

  总用量0

  -rw-r--r--.2rootroot0Nov1318:08ccc.txt[root@localhost~]#llbbb.txt

  -rw-r--r--.2rootroot0Nov1318:08bbb.txt

  软链接:

  [root@localhost~]#mkdirfolder_b

  [root@localhost~]#ln-sbbb.txtfolder_b/eee.txt[root@localhost~]#ll

  总用量4

  -rw-------.1rootroot2752Nov1002:51anaconda-ks.cfg-rw-r--r--.2rootroot0Nov1318:10bbb.txtdrwxr-xr-x.2rootroot20Nov1318:09folderdrwxr-xr-x.2rootroot20Nov1318:11folder_b[root@localhost~]#llfolder_b

  总用量0

  lrwxrwxrwx.1rootroot7Nov1318:11eee.txt-bbb.txt[root@localhost~]#rm-rfbbb.txt

  [root@localhost~]#llfolder_b

  总用量0

  lrwxrwxrwx.1rootroot7Nov1318:11eee.txt-bbb.txt

  删除了原文件,软链接的箭头目标为赤色一闪一闪,表现找不到目标文件。

  常用目次作用

  [root@localhost~]#ls/

  binbootdevetchomeliblib64mediamntoptprocrootrunsbinsrvsystemptmpusrvar

  阐明:

  /根目次

  /bin下令生存目次(平凡用户权限)

  /sbin下令生存目次(root权限)

  /boot启动目次,包罗启动相干文件,和开机有关

  /dev装备文件生存目次

  /etc设置文件生存目次

  /home平凡用户家目次

  /lib体系库生存目次

  /mnt体系挂载目次

  /media挂载目次(常用于光盘挂载)

  /root超等用户家目次

  /tmp临时目次

  /proc直接写入内存的

  /sys直接写入内存的

  /usr体系软件资源目次

  /var体系相干文档内容

  作者:翁艺逢

  泉源:https://www.codeceo.com/article/linux-directory-command.html

  炼石信息安全培训班

专注信息安全人才作育

搭建企业人才供需桥梁

咨询QQ群:495066536

客户评论

我要评论