cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Etc


Reference














.

os:linux:command:tree.html



Linux Commands#File, Directory

tree - How to use tree command in Linux with examples

man tree

NAME
       tree - list contents of directories in a tree-like format.

OPTIONS
      -a     All files are printed.  By default tree does not print hidden files
             (those beginning with a dot ‘.’).
      -p     Print the protections for each file (as per ls -l).
      -D     Print the date of the last modification time for the file listed.
      -u     Print the username, or UID # if no username is available, of the file.
      -g     Print the group name, or GID # if no group name is available, of the file.
      -d     List directories only.

       -I pattern
              Do not list those files that match the wild-card pattern.


Example

# tree -Dpuga /etc |more
/etc
|-- [-rw------- root     root     Apr 23  2014]  .pwd.lock
|-- [-rw-r--r-- root     root     Jul 22  2011]  DIR_COLORS
|-- [-rw-r--r-- root     root     Jul 22  2011]  DIR_COLORS.xterm
|-- [drwxr-xr-x root     root     Apr 23  2014]  NetworkManager
|   |-- [drwxr-xr-x root     root     Jul 22  2011]  VPN
|   |-- [drwxr-xr-x root     root     Jul 22  2011]  dispatcher.d
|   `-- [-rw-r--r-- root     root     Jul 22  2011]  nm-system-settings.conf
|-- [drwxr-xr-x root     root     Apr 23  2014]  X11
|   |-- [-rw-r--r-- root     root     May 24  2008]  Xmodmap
|   |-- [-rw-r--r-- root     root     May 24  2008]  Xresources
|   |-- [drwxr-xr-x root     root     May 11  2011]  applnk
|   |-- [drwxr-xr-x root     root     Apr 23  2014]  fs
|   |   `-- [-rw-r--r-- root     root     Apr 23  2014]  config
|   |-- [-rwxr-xr-x root     root     Aug 19  2011]  prefdm
|   |-- [drwxr-xr-x root     root     May 11  2011]  serverconfig
|   |-- [drwxr-xr-x root     root     May 11  2011]  sysconfig
|   |-- [drwxr-xr-x root     root     Apr 23  2014]  twm
|   |   `-- [-rw-r--r-- root     root     Jan  7  2007]  system.twmrc
|   |-- [drwxr-xr-x root     root     Apr 23  2014]  xinit
(abbr)
$ tree -a -I '.git'
.
|-- README.md
|-- bin
|   `-- .gitkeep
|-- conf
|   |-- httpd
|   |-- named
|   `-- os
|-- deb
|   `-- .gitkeep
|-- fabfile
|   |-- __init__.py
|   |-- auth.py
|   |-- check.py
|   |-- get.py
|   |-- httpd.py




Ref.

File Number

find /usr/local/apache2/htdocs  -type f | wc -l

Check Permittion

Sample1

# rsync  -avz --delete /etc/ /etc.bk
# tree -Dpuga /etc/ > /tmp/tree1
# tree -Dpuga /etc.bk/ >  /tmp/tree2
# diff /tmp/tree1 /tmp/tree2

Sample2

# tree -Dpuga /usr/local/apache2/htdocs/ > /tmp/tree.out
# tree -Dpuga /tmp/htdocs/ | diff - /tmp/tree.out



os/linux/command/tree.html.txt · Last modified: 2018/02/09 by admin

Page Tools