主页 > Linux > Linux文件和目录管理常用重要命令(二)

Linux文件和目录管理常用重要命令(二)

二、管理文件与目录
在了解目录与路径之后,我们继续学习管理文件与目录的一些命令!文件与目录的管理上,不外乎【显示属性】、【拷贝】、【删除文件】及【移动文件或目录』】等等,由于文件与目录的管理在 Linux 当中是很重要的, 尤其是每个人自己自家目录的数据也都需要注意管理!

1.ls (查看文件和目录)

[root@xiaoluo ~]# ls [-aAdfFhilRS] 目录名称 [root@xiaoluo ~]# ls [--color={none,auto,always}] 目录名称 [root@xiaoluo ~]# ls [--full-time] 目录名称 参数: -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) 而非内容变更时间 (modification time)

在 Linux 系统当中,这个 ls 指令可能是最常被执行的命令!因为我们随时都要知道文件或者是目录的相关信息啊。 不过,我们 Linux 的文件所记录的信息实在是太多了, ls 没有需要全部都列出来呢, 所以,当输入ls命令时,默认显示的只有:非隐藏文件的文件名、 以文件名进行排序及文件名代表的颜色显示;

[root@xiaoluo home]# ls -al ~ 总用量 216 dr-xr-x---. 31 root root 4096 4月 19 20:40 . dr-xr-xr-x. 26 root root 4096 4月 21 11:14 .. drwxr-xr-x. 2 root root 4096 3月 31 14:26 .abrt -rw-------. 1 root root 13062 4月 21 00:58 .bash_history -rw-r--r--. 1 root root 18 5月 20 2009 .bash_logout -rw-r--r--. 1 root root 176 5月 20 2009 .bash_profile -rw-r--r--. 1 root root 177 4月 8 22:43 .bashrc drwxr-xr-x. 4 root root 4096 4月 1 12:28 .cache drwxr-xr-x. 6 root root 4096 4月 1 12:26 .config -rw-r--r--. 1 root root 100 9月 23 2004 .cshrc drwx------. 3 root root 4096 3月 31 14:25 .dbus -rw-------. 1 root root 16 3月 31 14:26 .esd_auth drwx------. 4 root root 4096 4月 5 12:09 .gconf drwx------. 2 root root 4096 4月 5 18:56 .gconfd drwx------. 7 root root 4096 4月 1 12:28 .gnome2 drwx------. 2 root root 4096 4月 1 11:49 .gnome2_private drwxr-xr-x. 3 root root 4096 3月 31 14:26 .gnote drwx------. 2 root root 4096 4月 1 11:46 .gnupg drwxr-xr-x. 2 root root 4096 3月 31 14:26 .gstreamer-0.10 -rw-r--r--. 1 root root 160 4月 1 11:46 .gtk-bookmarks drwx------. 2 root root 4096 3月 31 14:25 .gvfs -rw-------. 1 root root 624 4月 1 11:46 .ICEauthority -rw-r--r--. 1 root root 785 4月 1 11:46 .imsettings.log drwx------. 3 root root 4096 4月 1 12:26 .kde -rw-------. 1 root root 46 4月 20 23:50 .lesshst drwxr-xr-x. 3 root root 4096 3月 31 14:25 .local drwxr-xr-x. 4 root root 4096 4月 1 11:49 .mozilla -rw-------. 1 root root 1711 4月 19 20:23 .mysql_history drwxr-xr-x. 2 root root 4096 3月 31 14:26 .nautilus drwx------. 2 root root 4096 3月 31 14:26 .pulse -rw-------. 1 root root 256 3月 31 14:25 .pulse-cookie -rw-------. 1 root root 3244 4月 1 12:34 .recently-used.xbel drwxr-xr-x. 3 root root 4096 3月 31 14:26 .redhat drwx------. 2 root root 4096 3月 31 14:25 .ssh drwxr-xr-x. 2 root root 4096 3月 30 11:20 .targetcli -rw-r--r--. 1 root root 129 12月 4 2004 .tcshrc drwx------. 3 root root 4096 4月 1 12:18 .thumbnails -rw-------. 1 root root 511 4月 5 00:04 .viminfo -rw-------. 1 root root 52 3月 31 14:18 .xauth58xele -rw-------. 1 root root 52 4月 19 19:34 .xauthAQSudj -rw-------. 1 root root 52 4月 1 20:09 .xauthFR3WoT -rw-------. 1 root root 52 3月 31 21:56 .xauthGPcuIJ -rw-------. 1 root root 52 3月 31 22:06 .xauthhgV2Ad -rw-------. 1 root root 0 3月 30 15:26 .Xauthority

2. cp (复制命令)
要复制文件,我们就要用到cp(copy)命令。不过cp命令的用途非常的广泛,除了单纯的复制之外,还可以建立连接文件(相当于windows下的快捷方式),比较两个文件的新旧而予以更新,以及复制整个目录等等。

说点什么吧
  • 全部评论(0
    还没有评论,快来抢沙发吧!