I. Overview of the Order
Directory Management Commands: Ls,cd,pwd,mkdir,rmdir,tree
File Management: Touch,stat,file,rm,cp,mv,install
Ii. detailed usage of commands
1.ls-list Directory Contents
ls [OPTION] ... [FILE] ...
-L: Long format
1th column 1th bit: file type:
-: Normal file (f)
D: catalog (directory)
B: Block devices (blocks)
C: Character device (character)
L: Symbolic Connection (symbolic link file)
P: Command pipe file (pipe)
S: Socket file (socket)
1th column 第2-10位: Permission bit (rwxrwxrwx)
2nd Column: Number of hard connection files
3rd Column: File owner
4th Column: Group of file genera
5th column: File size (size), Unit bytes, (can be used for unit conversion display with-h)
6th column: Timestamp (timestamp), Last modified time
Access: Access
Modified: Modify, default display, file content has changed
Change: change,metadata (meta data)
-H: Do unit conversions
-A,--All: shows hidden files starting with.
. Represents the current directory
.. Represents the parent directory
-A,--Almost-all: not displayed with [.] [..] Files, others are the same as-a
-D,--Directory: Display the directory's own properties
-i:index Node,inode
-R,--Reverse: Reverse Display
-R,--Recursive: recursive display
2.CD--change the Shell working directory
#cd ~: Return to home directory
#cd ~ USERNAME: Go to USERNAME Home directory
#cd-: Return to the previous directory
3.pwd-print Name of current/working directory
PWD [OPTION] ...
- L Force Symbolic links to be followed
- p Use the physical directory structure without following symbolic links
4.mkdir-make Directories
mkdir [OPTION] ... DIRECTORY ...
-P,--Parents: Creating a directory recursively
-V,--verbose: Show Create directory procedure
# mkdir-p/tmp/x/y/z/...
5.rmdir--remove Empty Directories
rmdir [OPTION] ... DIRECTORY ...
-P,--Parents: recursively Delete empty directories
#rmdir-P/tmp/x/y/z: Delete directory z, y, Z
6.tree--list contents of directories in a tree-like format.
tree [-adfghilnopqrstuvxacdfns] [-L level [-r]] [-H basehref] [-t title] [-o filename] [--nolinks] [-P pattern] [-I Pattern] [--inodes] [--device] [--noreport] [--dirsfirst] [--version] [--help] [--filelimit #] [directory ...]
-A: Show All files, hidden files are not displayed by default
-D: List only directories
-F: Show full path for each file
-u: Show file owner
-G: Show file Genus Group
-r: Display results sorted in reverse order
-o FileName: Display results sent to filename
7.touch--change File Timestamps
Touch [OPTION] ... FILE ...
-A: Modify the file access time
-M: Modify the file modification time
-T STAMP: Time format: [[CC]YY]MMDDHHMM[.SS]
-R,--reference=file: reference the current file time
-C,--no-create: Do not create a file, the default file does not exist will create a file empty files
8.stat-display the file or file system status displays the Detail property information
Stat [OPTION] ... FILE ...
9.file-determine file type View files
file [-bchiklnnprsvz0] [--apple] [--mime-encoding] [--mime-type] [-e testname] [-F separator] [-f namefile] [-M magicfiles ] File ...
file-c [-M magicfiles]
file [--help]
-B: The file name is not displayed and only the file type is displayed. Useful in shell scripts.
-I,--MIME: Displays the MIME category.
-L,--dereference: directly displays the category of the file to which the symbolic connection is pointing.
-F,--files-from NameFile: Specifies the name file (NameFile), each of which behaves as a file name, and the file command will identify the type of the files per line file name
-S,--special-files: Detect special files such as disk partitions
File. bashrc/dev/sda1
. bashrc:ascii Text
/dev/sda1:block Special
# file-i. bashrc/dev/sda1
. Bashrc:text/plain; Charset=us-ascii
/dev/sda1:application/x-block-device; Charset=binary
# FILE/BIN/TRACEROUTE6
/bin/traceroute6:symbolic link to ' traceroute '
# file-l/bin/traceroute6
/bin/traceroute6:elf 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for Gnu/linu X 2.6.18, stripped
# FILE/DEV/SDA1
/dev/sda1:block Special
# file-s/DEV/SDA1
/dev/sda1:linux Rev 1.0 ext4 FileSystem data (needs Journal recovery) (extents) (huge files)
10.rm-remove Files or directories
RM [OPTION] ... FILE ...
-i:prompt before every removal Interactive, confirm delete
-F,--force: forcibly removed
-r,-r,--Recursive: Recursively delete all files under directory
11.cp-copy Files and directories
CP [OPTION] ... [-T] SOURCE DEST
CP [OPTION] ... SOURCE ... DIRECTORY
CP [OPTION] ...-t DIRECTORY SOURCE ...
-A,--archive:same as-dr--preserver=all, archive replication, often used for backup
-I,--Interactive: Confirm when overwriting existing files
-r,-r,--Recursive: Recursive replication
-F,--force: Forced replication
-P: Preserve attributes such as owner, group, timestamp, etc.
12.mv-move (rename) file
MV [OPTION] ... [-T] SOURCE DEST
MV [OPTION] ... SOURCE ... DIRECTORY
MV [OPTION] ...-t DIRECTORY SOURCE ...
-I,--Interactive: Confirm when overwriting existing files
-F,--force: Forced movement
13.install-copy files and Set attributes copy file and set file properties
Install [OPTION] ... [-T] SOURCE DEST
Install [OPTION] ... SOURCE ... DIRECTORY
Install [OPTION] ...-t DIRECTORY SOURCE ...
Install [OPTION] ...-d DIRECTORY ... Create a Directory
-M,--mode=mode, reset file permissions by default: 755
This article is from the "Kaka" blog, please be sure to keep this source http://cakaluote.blog.51cto.com/504821/1612490
Linux Directory and file management