Linux notes-Administration, rights management, redirection, regular expressions

Source: Internet
Author: User
Tags aliases stdin

  • User management: Useradd userdel usermod passwd chsh chfn finger ID chage

  • Useradd:-u:uid-g:gid-g: Additional groups (can have multiple)-C: Comment Information-D: Specify a directory as home directory-S: Specify the path to the shell (a row in the/etc/shells file)-m: Force the user to create a home directory-K: Do not replicate/etc/ Skel (User personal Environment Profile) file home directory with-M: federated use-M: Do not create home directory-r: Add system User (cannot log in, no home directory) (/etc/login.defs is the default parameter of the configuration file) (/etc/ Installation shell for system user specified in shells)

  • Userdel: Delete the user, the default is not to delete home directory,-R: With the home directory at the same time delete

  • Usermod:-u: Modify Uid-g: Modify Gid-g: Overwrite add additional group (-A-G append additional group)-S: Modify Shell-c: Modify Comment-D: Modify home Directory-L: Modify LOGINNAME-E: Specify Expiration Time (YYYY-MM-DD)-D- M: Specify home directory location and can move data to modified directory-F: Inactive time-L: Lock Account-U: Unlock

  • ID: View user's account attribute information-u:uid-g:gid-g: ID of all groups

  • Finger: View user's account information

  • CHSH: Modifying the shell

  • CHFN: Modifying annotation information

  • Passwd:-l: Lock User-U: Unlock-d: Delete user password--stdin= for script creation account and specify password simultaneously (echo ' 123456 ' | passwd--stdin password is set to 123456)

  • PWCK: Checking user account Integrity

  • Group Management: Groupadd Groupdel groupmod gpasswd

  • Groupadd: Create group,-g:gid-r: Add System Group

  • Groupmod:-g: Modify Gid-n: Modify Group name

  • Groupdel: Deleting a group

  • GPASSWD: Add password to group to switch between groups (Newgrp other group name: Prompt for password) but the additional group does not require a password, exit: Back to the original group

  • Chage:-b: Modify the last Modified Time-e: Modify the Expiration Time-I: Modify inactivity Time-M: Modify the last used time-m.: Modify the maximum time to use-W: Modify the warning time

  • Rights Management: Chown chgrp chmod umask

  • Chown: Change the owner of the file, you can change multiple files at the same time-R: Recursive modification (directory and its subdirectories and files)--reference= specify the file to be modified, you can have multiple (modify the following file attributes to the previous file attributes) (Chown root:root or root Or: Root can modify the group at the same time or you can modify the group and user individually)

  • CHGRP: Modify group,-R: Recursively modify--reference= specify file to be modified, can have multiple

  • chmod: Modify the permissions properties of the file,--reference= specify the file to modify the file, you can have more than one, chmod number (octal) file .... chmod u=rwx,g=w,o-wx

  • To manually add a user (test):

  • Nano/etc/group test:x:5000 (GID)

  • NANO/ETC/PASSWD Test:x:5000:5000:test (note information):/home/test:/bin/bash

  • Nano/etc/shadow test:!! : 15765:0:99999:7:::

  • Cp-r/etc/skel//home/test

  • Chown-r Test:test/home/test

  • Chmod-r go=/home/test

  • (!! Out for MD5 password code, can also write: OpenSSL passwd-1 (number 1)-salt ' 12345678 ' Prompt for password and then get encrypted password MD5 code copy replacement!! To

  • Umask: Mask code (default permissions), 666-umask 777-umask (root user umask is 022, normal user umask is 002), the file default cannot have Execute permission, if the result has Execute permission to add its rights 1, such as: 3 (WX) +1 ( x) =4 (R)

  • Shell type of user login:

  • Log-in Shell:

  • Su-

  • Su-l

  • Non-logon Shell:

  • SU username

  • Login executed under the graphical interface terminal

  • Automatic execution of

  • Bash configuration file:
    Global configuration file:/ETC/PROFILE/ETC/PROFILE.D/*.SH/ETC/BASHRC

  • Personal Profile: ~/.bash_profile ~/.BASHRC

  • Profile class Files: Setting environment variables, running commands or scripts

  • BASHRC class files: Setting local user environment variables, defining command aliases

  • (if there are parts of the global and personal profiles that have similar but different definitions, whichever is the less, the smaller the scope, the easier it takes to take effect)

  • How the login shell reads the configuration file:

  • /etc/profile--/etc/profile.d/*.sh--~/.bash_profile--~/.bashrc--/etc/bashrc

  • How the non-logon shell reads the configuration file:

  • ~/.bashrc--/etc/bashrc--/etc/profile.d/*.sh

  • (~/.BASHRC: Where user-defined aliases, ~/.bash_profile: Define Run Command or script (echo ' Hello word ') (alias cl= ' Clear ') (define umask:~/bash_profile--Join Umask 027))

  • Piping and focus to:> < >> <<

  • System settings:

  • Default input device (standard input) STDOUT 0

  • Default output device (standard output) STDIN 1

  • Standard error Output Siderr 2

  • Standard input: Keyboard standard output and error output: Display

  • I/O redirection: Change the input and output source of the data, need to use the symbol to complete

  • Example: LS/> ~/test1.out (LS Run shows the content will be written to the Test1.out file) (Note: use > will overwrite the original content in the file, you can use >> append output content)

  • 2>: redirect error output 2>>: Append error output content

  • &>: Redirect standard output or error output, output to the same file

  • <: Input REDIRECT example: Tr ' A-Z ' A-Z ' < ~/test1.out (file contents in Test1.out will be capitalized)

  • Example: Cat << End (end tag)

  • It is a ...

  • >!!!!!!!!

  • >end

  • (The first two lines are displayed, and the first two lines can be added to the file: Cat >> ~/test1.out << END)

  • Tee: Can be displayed on the screen and simultaneously write to the file Tee file name

  • Pipelines: Commands | Command | Command (outputs the result of the previous command as input to the latter command)

  • Example: Remove line 6th of the ~/test1.out file

  • Head-6 ~/test1.out | Tail-1

  • Text lookup:

  • grep: Search for files based on pattern, partial match: Partial character match displays lines of text that conform to the pattern

  • Pattern: pattern is a matching condition formed by the combination of the source characters of the text-word wildcards regular expression

  • grep [options] pattern [file ....]

  • -I: Ignore case--color: line with pattern plus color-V: Reverse (shows only strings that are not matched to)

  • Regular expression: Regular expression--regexp

  • . : matches any single character *: matches any of its preceding characters any time. *: Any character of any length \?: matches its preceding character 1 or 0 times \{m,n\}: matches the preceding character at least m times up to N times ^$: blank line \<: Any character following it must appear as the word header (such as Roo4 As long as no special characters are considered to be words) \>: Any preceding character must appear as the tail of the word (\<ROO4\>: only Roo4 This word will appear alone \<roo4 roo4\>) \ (\): back reference (e.g. \ (ab\) * AB appears at least 1 times or any time) \ (root\). *\1 \ ([0-9]\). *\1

  • Location rules:

  • ^: The beginning of the line (any content after this character must appear at the beginning) $: End of Row []: matches any single character in the specified range [^]: matches any single character outside the specified range

  • CharSet: [:d igit:][:upper:][:p Unct:][:space:][:alpha:][:alnum:]


This article is from the "stupid Bird first-FAI" blog, please be sure to keep this source http://benniaoxianhui.blog.51cto.com/10463960/1671580

Linux notes-Administration, rights management, redirection, regular expressions

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.