您的位置:首页 > 运维架构 > Linux

小鸟chacha初学linux 第一课 常规目录操作

2012-01-14 23:33 253 查看
1.pwd 查看当前文件路径 即用户所处位置

2.cd 进入一个目录
cd 使用格式 cd [目录名]
[root@localhost ~]# pwd
/root //当前所处目录是/root
[root@localhost ~]# cd /etc/yum.repos.d//切换到/etc/yum.repos.d
[root@localhost yum.repos.d]# pwd
/etc/yum.repos.d //当前目录是/etc/yum.repo.d
cd - 返回上一次的所在目录 相当于windows的后退
[root@localhost yum.repos.d]# cd -
/root //后退到目录/root
cd . . 切换到上一级目录
[root@localhost Desktop]# pwd
/root/Desktop //当前所在目录是/root/Desktop
[root@localhost Desktop]# cd ..//切换到上一级目录 /root
[root@localhost ~]# pwd
/root

3.ls 命令使用介绍
ls使用权限 所有用户
格式 ls [选项][目录]
功能:列出目录中所有子目录和文件
[root@localhost ~]# ls
anaconda-ks.cfg install.log.syslog
Desktop 小鸟chacha初学linux.ncd
install.log
选项说明
-a 显示所有文件和子目录(以.开头的是隐藏文件)
[root@localhost ~]# ls -a
. .gnome2_private
.. .gstreamer-0.10
anaconda-ks.cfg .gtkrc-1.2-gnome2
.bash_history .ICEauthority
.bash_logout install.log
.bash_profile install.log.syslog

ls -A 同-a 不列出当前目录和父目录
[root@localhost ~]# ls -A
anaconda-ks.cfg .config .gconfd .ICEauthority .recently-used.xbel 小鸟chacha初学linux.ncd
.bash_history .cshrc .gnome install.log .redhat
.bash_logout Desktop .gnome2 install.log.syslog .scim
.bash_profile .dmrc .gnome2_private .metacity .tcshrc
.bashrc .eggcups .gstreamer-0.10 .nautilus .Trash
.chewing .gconf .gtkrc-1.2-gnome2 .notecase .xsession-errors
-l 列出文件名 权限 所有者 文件大小 等详细信息(不包含隐藏文件)
[root@localhost ~]# ls -l
总计 80
-rw------- 1 root root 1567 01-15 05:06 anaconda-ks.cfg
drwxr-xr-x 2 root root 4096 01-15 05:10 Desktop
-rw-r--r-- 1 root root 39319 01-15 05:06 install.log
-rw-r--r-- 1 root root 5303 01-15 05:05 install.log.syslog
-rw------- 1 root root 1886 01-15 06:14 小鸟chacha初学linux.ncd
[root@localhost ~]# ll
总计 80
-rw------- 1 root root 1567 01-15 05:06 anaconda-ks.cfg
drwxr-xr-x 2 root root 4096 01-15 05:10 Desktop
-rw-r--r-- 1 root root 39319 01-15 05:06 install.log
-rw-r--r-- 1 root root 5303 01-15 05:05 install.log.syslog
-rw------- 1 root root 2627 01-15 06:20 小鸟chacha初学linux.ncd

-r 将目录内容清单按字母逆序显示 ,逆序是按行逆序
[root@localhost ~]# ls -r
小鸟chacha初学linux.ncd install.log.syslog install.log Desktop anaconda-ks.cfg
-t 按文件修改时间排序
[root@localhost ~]# ls -t
小鸟chacha初学linux.ncd Desktop anaconda-ks.cfg install.log install.log.syslog

4.tree 把当前目录的子孙以树形 显示
[root@localhost ~]# tree /root
/root
|-- Desktop
|-- anaconda-ks.cfg
|-- install.log
|-- install.log.syslog
`-- 小鸟chacha初学linux.ncd

1 directory, 4 files

5.mkdir 创建目录
使用权限 所有用户
格式 mkdir [选项][目录]
选项
-p 创建多曾目录
[root@localhost ~]# mkdir /chacha/zhx/love
mkdir: 无法创建目录 “/chacha/zhx/love”: 没有那个文件或目录
[root@localhost ~]# mkdir -p /chacha/zhx/love

6.du
显示当前目录所占的磁盘空间 以为单位
[root@localhost ~]# du /boot
236 /boot/grub
12 /boot/lost+found
6427 /boot
-a 显示目录内所有文件目录的使用磁盘情况
[root@localhost ~]# du -a /boot
2 /boot/.vmlinuz-2.6.18-164.el5.hmac
939 /boot/System.map-2.6.18-164.el5
34 /boot/grub/splash.xpm.gz
9 /boot/grub/e2fs_stage1_5
8 /boot/grub/minix_stage1_5
2 /boot/grub/device.map
2 /boot/grub/grub.conf
8 /boot/grub/vstafs_stage1_5
9 /boot/grub/fat_stage1_5
8 /boot/grub/ufs2_stage1_5
11 /boot/grub/reiserfs_stage1_5
8 /boot/grub/iso9660_stage1_5
9 /boot/grub/jfs_stage1_5
2 /boot/grub/stage1
8 /boot/grub/ffs_stage1_5
1 /boot/grub/menu.lst
105 /boot/grub/stage2
10 /boot/grub/xfs_stage1_5
236 /boot/grub
12 /boot/lost+found
3236 /boot/initrd-2.6.18-164.el5.img
1823 /boot/vmlinuz-2.6.18-164.el5
107 /boot/symvers-2.6.18-164.el5.gz
70 /boot/config-2.6.18-164.el5
6427 /boot

-h 以人能读懂的方式显示 加单位
[root@localhost ~]# du -h /boot
236K /boot/grub
12K /boot/lost+found
6.3M /boot

-s 显示整体目录大小
[root@localhost ~]# du -s /boot
6427 /boot
[root@localhost ~]# du -sh /boot
6.3M /boot
本文出自 “初学linux” 博客,请务必保留此出处http://zhxchacha.blog.51cto.com/4277964/764151
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: