小鳥chacha初學linux 第一課 常規目錄操作

 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
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章