Linux command Daquan _ file Directory Operations Command

Source: Internet
Author: User
Tags parent directory svn

File Directory Operations Command

[[email] ~]# nl-n rz-w 2 list.txt protected ls02 cd03 pwd04 mkdir05 rm06 rmdir07 mv08 cp09 touch10 cat11 N L12 more13 less14 head15 Tail


Ls

LS Prints the inventory and details of the current directory, or you can specify the list and details of a file or folder

ls "option" "Directory Name"

Common options

-A view all subdirectories and files

-A put "." “..” Filter out

-l lists the details, or it can be the same as LL

-D list the properties of a directory

Instance

[email protected] ~]# ll data/web/log/system.log-rw-r--r--1 root root 4 18:19 data/web/log/system.log[[email PR Otected] ~]# ll-d data/web/log/drwxr-xr-x 2 root root 4096 Jan 4 18:19 data/web/log/[[email protected] ~]# ls-a data/we  B/log/system.log[[email protected] ~]# ls-a data/web/log/.  .. System.log[[email protected] ~]# ls/| Wc-l (add one) 20


Cd

CD switch to a different directory,

CD "Directory Name"

Common options

CD/Switch to root directory

CD Switch Home directory

CD Data/web/log switch to target directory

Cd.. /Switch to Parent directory

CD./Current Directory

CD ~ Switch home directory as CD

CD-Switch to the directory where you Last

[Email protected] ~]# CD/[[email protected]/]# CD [[email protected] ~]# CD Data/web/log/[[email protected] log]# CD. /[[email protected] web]# CD./[[email protected] web]# CD ~[[email protected] ~]# CD-(CD $ is also achievable)/root/data/web


Pwd

PWD View the full path to the current directory

PWD generally does not apply to any parameters

Pwd-p View the true path if the destination file has a link

[[email protected] web]# pwd/root/data/web[[email protected] web]# cd/etc/init.d/[[email protected] init.d]# pwd-p/etc/ Rc.d/init.d


Mkdir

mkdir creating the specified file directory

mkdir "Options" "Directory Name"

-M to set directory permissions

-p recursively Create a directory

-V Displays information each time it is created

[[Email protected] ~]# mkdir sh[[email protected] ~]# mkdir -p sh /install/web/tar[[email protected] ~]# mkdir -m 777 install[[email  Protected] ~]# mkdir -vp install/{bin/,log/,svn/{zabbix,cacti},ftp/{web,mysql,php},postfix /mail/{admin,pm}} mkdir: created directory  ' install/bin/' mkdir: created  directory  ' install/log/' mkdir: created directory  ' install/svn ' mkdir: created  directory  ' Install/svn/zabbix ' mkdir: created directory  ' install/svn/cacti ' mkdir:  created directory  ' install/ftp ' mkdir: created directory  ' Install/ftp/web ' mkdir:  created directory  ' install/ftp/mysql ' mkdir: created directory  ' install/ftp/php ' mkdir:  created directory  ' Install/postfix ' mkdir: created directory  ' install/postfix/ Mail ' Mkdir: created directory  ' install/postfix/mail/admin ' mkdir: created directory  ' install/postfix/mail/pm ' 
[Email protected] ~]# tree installinstall├──bin├──ftp│?? ├──mysql│?? ├──php│?? └──web├──log├──postfix│??     └──mail│??     ├──admin│?? └──pm└──svn├──cacti└──zabbix

Rm

RM is the command for deletion, which deletes one or more directories or files

RM [Options] [file name]

-F ignores nonexistent files and never prompts

-I do an interactive delete, delete a file prompt you

-R instructs RM to delete the specified file and all directories and files under the recursive delete

-V shows the steps

[Email protected] ~]# tree data/data/└──web└──log└──system.log2 directories, 1 file[[email protected] ~]# RM-RFV dataremoved ' data/web/log/system.log ' removed directory: ' data/web/log ' removed directory: ' Data/web ' removed Directory: ' data ' [[email protected] ~]# rm-i zabbix/*.logrm:remove regular file ' Zabbix/1.log '? Yrm:remove regular file ' Zabbix/2.log '? Y


RmDir

RmDir deleting an empty directory using Rm-r is too risky

rmdir [Options] [contents]

-V shows the execution process

-P Recursive Delete sub-directory is also empty directory, and deleted together

[[email protected] ~]# rmdir zabbixrmdir:failed to remove ' Zabbix ': Directory not empty[[email protected] ~]# rm-i Zabbi X/*.txtrm:remove regular file ' Zabbix/1.txt '? Y[[email protected] ~]# rmdir zabbix[[email protected] ~]# [[email protected] ~]# mkdir zabbix/install-p[[email protected ] ~]# rmdir zabbix/install-p


Mv

MV can be used to move files or rename files, often used to back up files or directories

MV [options] [source file] [target file]

-B If you need to overwrite the file, back up before overwriting

-F If the destination file exists, Force overwrite

-I already exists will prompt whether to overwrite

[[Email protected] ~]# mv aa.sh sh/install/web/install.sh[[email protected] ~]# mv-i install.sh sh/install/web/install.s H mv:overwrite ' sh/install/web/install.sh '? [Email protected] ~]# mv-b install.sh sh/install/web/install.sh mv:overwrite ' sh/install/web/install.sh '? Y[[email protected] web]# lsinstall.sh install.sh~ tar[[email protected] ~]# mv-f install.sh sh/install/web/install.sh


Cp

CP is used to copy files or directories

CP [Options] [source] [directory]

-p ownership, timestamp

-A full copy of the entire catalog file

-I copy time copying

[Email protected]t ~]# cp-ap sh shell/[[email protected] ~]# tree Shell/shell/└──sh└──install└──web ├──install.sh├──install.sh~└──tar

Touch

Touch is used to create a new file that does not exist

touch [options] [filename]

[email protected] ~]# Touch ceshi.txt


Cat

Cat is used to print out the contents of the file and is often used with redirection symbols

Cat [Options] [file]

-N Display number of rows

-S has two consecutive lines of blank line, on behalf of a row display

[[email protected] ~]# cat-n log2016_1_6.log 1 Install centos.6.5 2 Install centos.6.5 3 Install Centos.6 .5 4 Install centos.6.5


nl

NL can be output by default with the number of rows, suitable for more than the number of rows calculation, you can automatically add 0

-N

RZ number of rows in the back plus 0

0-digit number of-W brake occupied

[Email protected] ~]# nl-n rz log2016_1_6.log 000001 install centos.6.5000002 install centos.6.5000003 Install     centos.6.5000004 install Centos.6.5[[email protected] ~]# nl-n rz-w 3 log2016_1_6.log 001 Install centos.6.5002 Install centos.6.5003 install centos.6.5004 install centos.6.5


More

More similar to cat, the entire file will be displayed on the screen, press the SPACEBAR to scroll down, press the B key to turn back

more [options] [filename]+n from the first line shows the V Call VI editor Q exit! command to invoke the shell and execute the command--more--(10%)


Less

Less is also used to view the commands that can be page up and down

less [options] [filename]


Head

The head command displays the file start information output

head [parameters] [filename]

-N Displays the number of rows

-C Displays the number of bytes

[[email protected] ~]# head-n 5 who.txt 12345[[email protected] ~]# head-c 4 who.txt 12



Tail

Tail and head Instead, view trailer information

tail [options] [file name]

-C Display bytes

-N Display number of rows

-F Loop read to see how the file changes at any time

[[email protected] ~]# tail-5 who.txt 678910[[email protected] ~]# tail-c 8 who.txt 8910[[email protected] ~]# [[Email Protected] ~]# ping www.baidu.com > Ping.log[[email protected] ~]# ping www.baidu.com > Ping.log


This article is from the "Good Note ops" blog, please be sure to keep this source http://021soso.blog.51cto.com/11045979/1732004

Linux command Daquan _ file Directory Operations Command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.