Linux Common commands

Source: Internet
Author: User
Tags create directory file copy



One: LS

1.-L: Listing information in a longer format


2.-H: Do the unit conversion, together with-l, output file size in an easy-to-read format (e.g. 1K 234M 2G)


3.-A: Displays all files, including "." Hidden files at the beginning

“.” : Represents the current directory

“..” : Represents the top level directory of the current directory


4.-A: Displays all files, including "." The hidden file that starts with, but does not contain the "." and ".."


5.-D: Displays the directory like a file instead of displaying the file under it----display the properties of the directory itself


6.-i:index Node (index node number) abbreviated to Inode, displays the inode number of each file


7.-r:reverse reverse Order


8.-r: Recursively display subdirectories


9.-S: Sort by file size




II: File type

"-": Normal file


"D": Catalog file


"B": Block device files (blocks)


' C ': Character device file (character)


"L": Symbolic Link files (symbolic link file)


"P": Command pipe file (pipe)


"s": Socket file (socket)



Three: Date Time management

1. Format: Date [OPTION] ... [+format]

2. Date: View system time

3. Clock: View hardware time

4. Hwclock: View hardware time

Hwclock-w synchronizing system time to hardware

Hwclock-s synchronizing hardware time to System




Four: Flip screen and find

4.1 Turning screen

Turn One screen: SPACE

Turn One screen forward: b

Turn back one line: ENTER

Turn One line forward: K

4.2 Find:

/keyword: Looking backwards

N Key: Next

N Key: Previous

? Keyword: Looking forward

N Key: Next

N Key: Previous



V: Directory Management

1. Create an empty directory--mkdir

-P: Create a parent directory for the target directory

-v:verbose More information

Example 1: If you need to create the X and Y directories under the/mnt/test directory, then create the M directory under the X directory, if it is done with a command?

mkdir-pv/mnt/test/x/m/ment/test/y

Mkdir-pv/mnt/test/{x/m,y}

' {} ': Curly brace expansion or command line expansion, the comma-delimited path is automatically expanded to two when curly braces are encountered


Example 2: Create a a_c,a_d,b_c,b_d------(a+b) (c+d) =ac+ad+bc+bd in the SRV directory

Mkdir-pv/srv/{a,b}_{c_d}


2. View the directory tree--tree


3. Delete Empty directory--rm

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6C/52/wKiom1VF_KahK_3xAADdoy8eJ80539.jpg "style=" float: none; "title=" 1.png "alt=" Wkiom1vf_kahk_3xaaddoy8ej80539.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6C/4E/wKioL1VF_hOB_S2CAAA82NTGln4303.jpg "style=" float: none; "title=" 2.png "alt=" Wkiol1vf_hob_s2caaa82ntgln4303.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6C/52/wKiom1VF_KbgLJC3AAEVpSD06eE488.jpg "style=" float: none; "title=" 3.png "alt=" Wkiom1vf_kbgljc3aaevpsd06ee488.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6C/4E/wKioL1VF_hSSPzd1AAA4H6-f_6M299.jpg "style=" float: none; "title=" 4.png "alt=" Wkiol1vf_hsspzd1aaa4h6-f_6m299.jpg "/>




VI: Creation of files

Touch: Modify the timestamp of a file

-C: Only modify file timestamp, do not create file

-A: Change access time only

-M: Change the modification time only

-T: modified to the specified time Touch-m-T 201212121212 a

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6C/4E/wKioL1VF_n_z9BgTAAEN2qXfMpo213.jpg "style=" float: none; "title=" 6.png "alt=" Wkiol1vf_n_z9bgtaaen2qxfmpo213.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6C/52/wKiom1VF_RLBd28vAAEQkUZGgHc914.jpg "style=" float: none; "title=" 7.png "alt=" Wkiom1vf_rlbd28vaaeqkuzgghc914.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6C/4E/wKioL1VF_oCywI8UAAEB-ofWr4o013.jpg "style=" float: none; "title=" 8.png "alt=" Wkiol1vf_ocywi8uaaeb-ofwr4o013.jpg "/>



Seven: File copy

Cp

-R: Recursive replication

-P: Reserved file permissions, belong to the main group, timestamp

-P: Keep connected

-F: Forced replication

-A: Archive replication, often used for backup

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6C/52/wKiom1VF_XixSFtjAACW9wtX91c307.jpg "style=" float: none; "title=" 9.png "alt=" Wkiom1vf_xixsftjaacw9wtx91c307.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6C/4E/wKioL1VF_uaiNt5jAAIHLoY2IUU060.jpg "style=" float: none; "title=" 10.png "alt=" Wkiol1vf_uaint5jaaihloy2iuu060.jpg "/>



VIII: Belong to group, owner

1.chown: Change file owner (only administrators can use this command)

-R: Modify the owner of the directory and its internal files

--reference=/path/to/somefile file,... Set file and subsequent files to the same owner and owner group as the previous path file


# chown USERNAME File,...

#chown username:groupname File,...

#chown: GROUPNAME file,..

#chown USERNAME. GROUPNAME file,...


2.chgrp: Change the genus Group of a file

-R

--reference

# chgrp GROUPNAME File,...



Nine: Rights Management

9.1 Files:

R: Readable, you can view the contents of the file using commands like Cat

W: writable, can edit or delete this file

X: Executable, can be submitted to the kernel at the command prompt as a command to run


9.2 Contents:

R: You can perform LS on this directory to list all internal files

W: You can create files in this directory

X: You can switch to this directory using a CD, or you can use Ls-l to view the details of internal files


9.3RWX:

r--: Read-only

R-x: Read and Execute

---: No permissions


9.4 Classification of permissions for a certain class of users (from status to High 1,2,4)

0---: No permissions

1 001--x: Execution

2 010-w-: Write permission

3 011-wx: Write and Execute

4 r--: Read-only

5 101 R-x:

6 rw-: Read and Write

7 111 rwx: Read and write execution


9.5umask: Permission Mask

Create file: 666-umask

Create directory: 777-umask

# Umask shows the value of Umask

# umask 022

The value of Umask becomes 022.


9.6chmod: Permissions to modify files

9.6.1 Modify the permissions of three categories of users:

chmod MODE File,...

-R

--reference=/path/to/somefile file,...


9.6.2 modify certain types of users or certain class user rights:

chmod user category =mode file,...

U: Owner

G: Array

O: Other users

A: the user used



9.6.3 Modify a certain bit or some bit permission for a class of users:

chmod user category + (-) MODE file,...

U,g,o,a




9.7 Administrator-Created by default

File permissions: 644

Directory Permissions: 755


9.8 Normal user created by default

File permissions are: 664

Directory permissions are: 775



For the directory, execute permissions must have, need to allow other users to execute the LS and other commands, but if a file is a text file, put some malicious commands, if you have execute permissions, may lead to fatal damage consequences, it is not recommended to let the file default has execute permissions, but the directory should have




10. User Management

1.useradd [options] Usernmae adding users

-u:uid

-g:gid (Basic Group)

-R: Add a System User

-g:gid,... (Additional groups)

-C: "COMMENT" comment information

-D: Specify the path for the user's home directory

-S: Specifies the path to the shell (/etc/shells the currently available system shell)

-m-k: Forcing users to create home directories

-M: Do not create home directory for users

2.userdel [option] USERNAME the default user's home directory is not deleted if the user is removed without the option

-r: Delete User's home directory while deleting


3.usermod: Modify user account attribute information

-u:uid

-g:gid (Basic Group)

-g:gid (additional group) the user already has an additional group, and if additional groups are specified, the original additional group is gone.

-A: Use with-G to append new additional groups to the user

-C: Comment Information

-d-m: Home directory, if you specify a new home directory, then some of the property information in the previous home directory will not be brought past, so if you want to move the information in the home directory needs to add-M option

-S: Modify shell

-L: Modify login Name

-L: Lock account

-U: Unlock Account


4.chsh: Modify the user's default shell

Chsh Usernmae

5.CHFN: Modify user's comment information

CHFN USERNAME

6.PASSWD USERNAME: Modify the user password, for non-administrators, can only modify their own password, for the administrator can modify other people's password

--stdin: read password from standard input

-L: Lock user account

-U: Unlocking

-N: Change Password minimum age

-X: Change the password maximum age

-W: Change Password warning time

-D: Remove user password


7. User: UID user file/etc/passwd


8. Group: GID Group File/etc/group


9.Linux Shadow Password:

User Password storage location:/etc/shadow

Group Password store Clerical:/ect/gshadow


10. User category (the user is distinguished on the ID number):

Administrator: uid:0

Normal User: uid:1-65535

1. System User: uid:1-499 not allowed to log on to the system

2. General Users: uid:500-60000


11. User Group Category

Administrators group:

Normal Group:

System Group:

General Group:


12. User Group Category:

Private group: When a user is created, a group with the same name as the user name is automatically created if the group to which it belongs is not specified

Basic group: Default group for users

Additional groups, additional groups: groups other than the default group























This article is from the "Everyman" blog, please make sure to keep this source http://caoyt.blog.51cto.com/9978141/1641449

Linux Common commands

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.