1. What are the file management commands on Linux, their commonly used methods and their related examples?
1.1, File Rights Management class command
chown: Changing the file owner
chown [Optinon] ... [OWNRR] [: [GROUP]] FILE ...
Common Parameters-R: Recursive modification (directories and files in the directory and Directory Change)
Example: #chown-R Root/tmp/ligang
# chown-r Root:root/tmp/ligang
chown [OPTION] ...--reference=rfile FILE ...
Example: # chmod--reference=/tmp/issue/tmp/fstab
chgrp: Changing the owning group of a file
Usage, the parameters are basically the same as Chown:
Example: # chgrp Root/tmp/ligang
chmod: Change the permissions of a file, modify some or some bit permissions for a class of users
chmod [OPTION] ... Mode[,mode] ... FILE ...
MODE: Modify a class of permissions
-u user,-G group,-o Other,-a all,-r recursive modification
Example: #chmod A=rwx/tmp/ligang
Umask: Mask code when a file or directory is created (valid only for the current shell)
Catalogue with 777-umask
File with 666-umask
Note: If there is an X permission in the result of a class of user whose permissions are reduced, its permissions +1
Umask: View
Umask #: Setting
1.2. File Processing Tools
WC command: Count the number of words, count the number of words, number of lines, number of bytes
WC [OPTION] ... [FILE] ...
WC [OPTION] ...--files0-from=f
-l:line Display of rows
-w:words number of words
-c:characters Number of bytes
Example: Wc/tmp/issue
1.3, file base creation search and other commands
Common basic commands: CD, PWD, mkdir, touch
View: Cat,more,less,tail,head,tac
Copy: CP
Mobile: MV
Delete: RM
Create: Touch
Meta Data properties: Stat
View Content Type: File
File management is one of the most basic functions of an OPS engineer, which can be managed independently of a file or directory in Linux, with great controllability and encryption. In Liunx, user-given file management permissions are much more convenient than Windows and search aspects can be searched separately for each file and directory, but the centralized management of files in Linux may require scripts and third-party software to operate.
2. Bash's work characteristics the command execution status return value and command line expansion are involved in the content and its sample demonstration.
2.1 When the command finishes executing, its status return value is saved in Bash's special variable $?.
Bash outputs this result with a status return value:
Success: 0
Failed: 1-255
650) this.width=650; "height=" 141 "src=" http://b198.photo.store.qq.com/psb?/V14ApF1036yr41/ zpxt6t2zzu52e1tqqyan7odmh*jw96z.ycz.lvzcmby!/b/dmyaaaaaaaaa&bo=jaknaaaaaaafaca! "width=" 652 "style=" vertical-align:top;font-family:arial;font-size:14px;line-height:22.4px;white-space:normal; "Alt=" DMYAAAAAAAAA &bo=jaknaaaaaaafaca! "/>
Note the difference between the command execution status return value and the execution result of the command. For example, the execution result of LS shows the file name of the current directory, followed by the echo command to display the command's execution status return value, regardless of whether the LS command executed successfully, it will have related data display, but the command execution status return value is different.
Command-line expansion of Bash's working features:
~: Automatically expands to the user's home directory, or the specified user's home directory.
{}: A comma-separated list of paths can be hosted and can be expanded to multiple paths.
3. Use the command line opening function to complete the following exercises.
(1), create the/tmp directory: A_c,a_d,b_c,b_d
mkdir-p {A,b}_{c,d}
650) this.width=650; "height=" http://b199.photo.store.qq.com/psb?/V14ApF1036yr41/"src=" 6ldy2pdxssn.r4xn6eewanqcosofp8az*ae. h2damqe!/b/dmcaaaaaaaaa&bo=kgflaaaaaaafaps! "width=" 402 "style=" vertical-align:top; "alt=" DMcAAAAAAAAA&bo =kgflaaaaaaafaps! "/>
(2), create the/tmp/mylinux directory:
mylinux/
---bin
---boot
---Grub
---Dev
---etc
---rc.d
---INIT.D
---Lib
---modvies
---lib64
---proc
---sbin
---sys
---tmp
---usr
---Local
---bin
---sbin
---var
---lock
---Log
---run
Mkdir-pv/tmp/mylinux/{bin,boot/grub,dev,etc/{rc.d/init.d,sysconfig/network-scripts},lib/modules,lib64,proc, Sbin,sys,tmp,usr/local/{bin,sbin},var/{lock,log,run
650) this.width=650; "height=" "src=" http://b199.photo.store.qq.com/psb?/V14ApF1036yr41/ nfbvtuptlsqzl1psxgxnogpp76auv5za5jhorqndjui!/b/dmcaaaaaaaaa&bo=4wi.aaaaaaafapw! "width=" 739 "style=" vertical-align:top; "alt=" dmcaaaaaaaaa&bo=4wi.aaaaaaafapw! "/>
650) this.width=650; "height=" src= "http://b200.photo.store.qq.com/psb?/V14ApF1036yr41/ 9qr9xfclqjdlrlopdpmgkwn4xuem0khv9us6lxvuw9k!/b/dmgaaaaaaaaa&bo=sgi5aaaaaaafafi! "width=" 586 "style=" vertical-align:top; "alt=" dmgaaaaaaaaa&bo=sgi5aaaaaaafafi! "/>
{} This symbol can be created in bulk-PV recursive creation
4, what is the metadata information of the file, what does it mean, how to view it? How to modify timestamp information for a file.
4.1, the file metadata refers to the file's attributes, size, creation time, access time, belong to the main group and other information.
4.2, three time stamps:
Access time: Atime, read and write file contents
Modify Time: Modified, Mtime, change file contents (data)
Change time: Changing times, ctime, meta data changes
4.3. Time stamp of modified file: Touch
-a:only Atime
-m:only Mtime
-S STAMP:[[CC]YY]MMDDHHMM[.SS]
-C: If the file does not exist, it is not created
5, how to define the alias of a command, how to reference the result of another command execution in the command?
5.1. Command alias: Alias
Alias: Displays all the available command aliases for the current shell process
Alias name= "VALUE": Naming aliases
Special reminder: Aliases defined on the command line are only valid for the current shell process, and if you want to be permanently active, go to the configuration file
For the current user only: ~/.BASHRC
Valid for all:/ETC/BASHRC
5.2. Using Pipeline Command |
grep/etc/* | grep init* | grep initio*
Note: The last command executes in the child shell process of the current shell process
6. Display all files or directories in the/var directory that start with L, end with a lowercase letter, and have at least one digit (can have other characters) appear in the middle.
Mkdir/var/1314hua
Ls-d/var/1*[0-9]*[a-z]
650) this.width=650; "Src=" http://b200.photo.store.qq.com/psb?/V14ApF1036yr41/ utjfljihbr7e55o1i5pp9jtsbidxplip5qjab8kngy0!/b/dmgaaaaaaaaa&bo=1we9aaaaaaafamg! "width=" 471 "height=" 61 " Style= "vertical-align:top;" alt= "dmgaaaaaaaaa&bo=1we9aaaaaaafamg!"/>
7. Displays files or directories that begin with any number in the/etc/directory and end in a non-numeric number.
Mkdir/etc/250ligang
Ls-d/etc/[0-9]*[^0-9]
650) this.width=650; "Src=" http://b199.photo.store.qq.com/psb?/V14ApF1036yr41/ w7xsfzo74lzmdix9jd6fri.3jp1fko0oanv*bfjcn.0!/b/dmcaaaaaaaaa&bo=wgfcaaaaaaafaki! "width=" height= "66" Style= "vertical-align:top;" alt= "dmcaaaaaaaaa&bo=wgfcaaaaaaafaki!"/>
8, display/etc/directory, start with a non-letter, followed by a letter and any other arbitrary length of any character file or directory.
Mkdir/etc/123abcla
Ls-d/etc/[^a-z]*[^a-z][a-z]
650) this.width=650; "Src=" http://b198.photo.store.qq.com/psb?/V14ApF1036yr41/ ag06iz.10nf.zgpdicwlqkiulzdx4rjhcyil6j9su.k!/b/dmyaaaaaaaaa&bo=dge2aaaaaaafagi! "width=" 374 "height=" 54 " Style= "vertical-align:top;" alt= "dmyaaaaaaaaa&bo=dge2aaaaaaafagi!"/>
9. In the/tmp directory, create a file that starts with Tfile, followed by the current date and time, with a filename such as: tfile-2016-05-27-09-32-22.
touch/tmp/' echo tfile-$ (date +%y-%m-%d-%h-%m-%s)
Ls/tmp
650) this.width=650; "Src=" http://b200.photo.store.qq.com/psb?/V14ApF1036yr41/ o63geh5jfgkptgxagizvvzj9wfmvxc0fkvnme4v4jzk!/b/dmgaaaaaaaaa&bo=bqiqaqaaaaafadu! "width=" 517 "height=" 272 " Style= "vertical-align:top;" alt= "dmgaaaaaaaaa&bo=bqiqaqaaaaafadu!"/>
10. Copy all the files or directories in the/etc/directory to the/tmp/mytest1 directory that begin with P and not end with a number.
Mkdir/tmp/mytest1
Cp-a/etc/p*[^0-9]/tmp/mytest1
Ls/tmp/mytest1
650) this.width=650; "Src=" http://b200.photo.store.qq.com/psb?/V14ApF1036yr41/ nqasulhoiynqyymq9eg.5zvgscia5kcrb7yuswumylo!/b/dmgaaaaaaaaa&bo=yqjhaaaaaaafaik! "width=" 713 "height=" 97 " Style= "vertical-align:top;" alt= "dmgaaaaaaaaa&bo=yqjhaaaaaaafaik!"/>
11. All files or directories ending with. D in the auxiliary/etc directory to the/tmp/mytest2 directory.
Mkdir/tmp/mytest2
Cp-a/etc/*.d/tmp/mytest2
Ls/tmp/mytest2
650) this.width=650; "Src=" http://b263.photo.store.qq.com/psb?/V14ApF1036yr41/ Jyvxrhm11dj5xdvilxulma4xmihbhn.lqn8xhuj0fqy!/b/dacbaaaaaaaa&bo=uakdaaaaaaafabo! "width=" 696 "height=" 131 " Style= "vertical-align:top;" alt= "dacbaaaaaaaa&bo=uakdaaaaaaafabo!"/>
12. Copy all files in the/etc/directory that begin with L or M or N and end with. conf to the/TMP/MYTEST3 directory.
Mkdir/tmp/mytest3
Cp-a/etc/{1,m,n}*.conf/tmp/mytest3
Ls/tmp/mytest3
650) this.width=650; "Src=" http://b199.photo.store.qq.com/psb?/V14ApF1036yr41/ lhlw7yvkifqzh9mi4gor3f3gps3mqpcddvbmxngpxcu!/b/dmcaaaaaaaaa&bo=xgjkaaaaaaafaim! "width=" 710 "height=" 100 " Style= "vertical-align:top;" alt= "dmcaaaaaaaaa&bo=xgjkaaaaaaafaim!"/>
Common uses of Linux commands, files, and directories