Linux Common Commands 2

Source: Internet
Author: User
Tags clear screen

first, find files in Linux

  • Which, Whereis, plus locate.
    Yum install-y mlocate//Installation Locate
    The first time the data file does not exist,
    Input UpdateDB can be
  • Find
    find/tmp/chen/-type f-mmin-60-exec mv {} {}.bak \;
    Find/-inum 21111212
    Find. -name ". txt"-A (-perm 777-o-type D) First satisfies the file name of. txt, and then also satisfies the requirement of 777 or directory, that is, the directory with the file name. txt in the current directory is eligible, or the file name is. txt and the permission is 77 7 also meet the conditions
  • -type Specifying file types
    D folder
    F file
    L Link
    C Serial Device
    B Block
  • -mmin minutes, without this option is the number of days
    Atime the last time to view or open
    Mtime the last time the content was modified
    CTime Last modified permission: Time
    Mtime change when the CTime must change, the contrary does not set
  • The stat command is used to view details such as the three time inote number of a file
  • -size file size k, M
  • -type-size These conditions do not add-O is all the conditions are set, plus-O is OR
    Second, Linux common shortcut keys

    Ctrl L Clear Screen
    D (current command behavior is empty) Exit current terminal
    C Discard the current command line
    U delete the character before the cursor to the beginning of the line
    K Delete the character before the cursor to the end of the line
    A cursor moves to the front of the command line
    e cursor moves to the command line at the end
    H Delete from cursor position by word Fu Xiangmai
    D remove by character backwards from cursor position
    Z Pauses the current process
    Iii. Linux and Windows inter-pass files
    Yum Install-y Lrzsz
    SZ//from Linux to Windows
    RZ//From Windows to Linux
    General use XFTP can
    Iv. user profile and password configuration file
  • User Configuration Files
    /etc/passwd
    1) User name (if root in the first row is the user name), the string representing the user account. The user name character can be uppercase and lowercase letters, numbers, minus signs (not appearing in the first place), dots, and underscores, and other characters are illegal. Although the user name can appear in the point, but not recommended, especially the first point, the other minus is also not recommended, because it is easy to cause confusion.

2) The password of the account is stored, why is ' x '? The early Unix system password was actually stored here, but based on security factors, it was later stored in '/etc/shadow ', where only one ' x ' was used instead.

3) This number represents the user identification number, also called the UID. The system identifies the user identity is through this number, 0 is root, that is, you can modify the test user uid is 0, then the system will consider root and test for the same account. Usually the value of the UID range is 0~65535 (but actually can be supported to 4294967294), 0 is the Super User (root) identification number, 1~499 reserved by the system, as a management account, the ordinary user's identification number starting from 1000, if we customize the establishment of a normal user, You will see that the identification number of the account is greater than or equal to 1000.

4) Represents the group identification number, also called GID. This field corresponds to a record in/etc/group, in fact/etc/group and/etc/passwd are basically similar.

5) Note that the field does not make sense and typically records some of the user's attributes, such as name, phone, address, and so on. However, this information is displayed when you use the Finger feature (described later).

6) The user's home directory, which is in this directory when the user logs in. Root home directory is/root, ordinary user's home directory is/home/username, this field can be customized, such as you build a normal user test1, want to let Test1 home directory in/data directory, just modify/etc/ This field in the Test1 line in the passwd file is/data.

7) shell, the user log in to start a process to the user issued instructions to the kernel, this is the shell. The Linux shell has many kinds of sh, csh, ksh, tcsh, bash, and so on, while Redhat/centos's shell is bash. View the/etc/passwd file, which has more than/bin/bash in addition to/sbin/nologin, which indicates that the account is not allowed to log on. If you want to create an account to not let him log in, then you can change the field to/sbin/nologin, the default is/bin/bash.

    • /etc/shadow Store user-related information
      The meaning of each field is:

1) User name, corresponding to/etc/passwd.

2) User password, this is the real password of the account, but this password has been encrypted, but some hackers can be decrypted. Therefore, the file property is set to 000, but the root account can be accessed or changed.

3) The date the password was last changed, this number is calculated from January 1, 1970 to the date the password was last changed, such as the last time the password was changed to January 1, 2012, then this value is ' 365 x (2012-1970) + (2012-1970)/4 + 1 = 15341 '. Because if it is a leap year, there are 366 days.

4) How many geniuses can change the password, the default is 0, that is, unlimited.

5) The password expires after a few days. That is, the number of days you must change the password, for example, set to 30, you must change the password within 30 days, otherwise you will not be able to log on to the system, the default is 99999, it can be understood that never need to change.

6) The warning period before expiration of the password, if the value is set to 7, indicates that when the password expires after 7 days, the system warns the user that his password will expire after 7 days.

7) Expiration date of the account. You can understand that if you set this value to 3, it means: the password has expired, but the user did not change the password before expiry, then after 3 days, then the account is invalid, that is locked.

8) The life cycle of the account, as in the third paragraph, is calculated by the number of days from January 1, 1970. It means that the account can be used before this date, and the account will expire after expiration.

9) as a reserved use, no meaning.
/etc/passwd-
/etc/shadow-This type of file is a backup of user-related information
V. User group Management

  • Groupadd-g 1006 GRP2
    Add a user group, and specify a group ID of 1006
  • Groupdel GRP1//delete user groups
    User groups must be determined that no users are already in the user group before they can be deleted
    VI. User Management
  • Useradd-u 1005-g grp2-d/home/chinantfy-s/sbin/nologin user2
    Add user and specify UID and group, specify home directory and Sbin
  • Useradd-m User5
    Create user but do not create home directory
  • Userdel-r User2
    Deleting a user without the-r option does not delete the user's home directory
    Seven, Usermod
    Usermod-u 111 username #修改用户
    Usermod-g GRP2 username #修改用户组
    usermod-d/home/chinantfy2 username #修改用户家目录
    Usermod-s/sbin/nologin username #修改用户shell
    Usermod-g only one group can be modified
    Usermod-g can add multiple groups, with this command followed by several groups, the owning group of the file is the specified group plus the group to which the user was originally built
    For example
    Usermod-g grp1,user2 username
    Assuming that the group is USERGRP when the account is established
    The user group is now Usergrp,grp1,user2
    Eight, lock the user
    Passwd-l username
    Passwd-u username
    Other than that
    USERMOD-L username Lock User Password
    Usermod-u username Unlocking user
    commands to change passwords directly

    echo "111222aaa" |passwd--stdin USR2
    Echo-e "111222aaa\n111222aaa\n" |passwd USR2
    Ix. Order of MKPASSWD
    Yum Install-y expect
    Mkpasswd-l 12
    Then specify a password length of 12 bits
    -s Specifies the number of special symbols

Linux Common Commands 2

Related Article

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.