The first experience of Xiaofan in Linux

Time:2020-10-27

Linux learning

This is the first blog. It introduces the configuration environment when I just worked. I don’t have any experience in blogging, so it may be messy. I hope you can include it more.

1、 Common instructions

Linux command Encyclopedia

  • -EQ / / equal to
  • -NE / / not equal to
  • -GT / / greater than
  • -LT / / less than
  • Ge / / greater than or equal to
  • Le / / less than or equal to

2、 Common commands for processing directory

  • Ls: List directory and file name
  • CD: switch directory
  • PWD: displays the current directory
  • MKDIR: create a new directory
  • Rmdir: delete an empty directory
  • CP: copy a file or directory
  • RM: remove file or directory
  • MV: move files and directories, or modify the names of files and directories

3、 Linux content view

  • Cat displays the contents of the file from the first line
  • TAC is displayed from the last line. You can see that TAC is written backwards for cat!
  • NL display, by the way output line number!
  • More page by page display file content
  • Less is similar to more, but better than more, it can turn pages forward!
  • Head only looks at the first few lines
  • Tail only looks at the tail

4、 Change file properties:

  • Chgrp: change file group

    Chgrp [- R] group name file name
  • Chown: change the file owner or group at the same time

    Chown [– R] name
    Chown [- R] subject name: group name file name
  • Chmod: change 9 attributes of the file

    There are two ways to set Linux file properties, one is number, the other is symbol.

    There are nine basic permissions for Linux files, which are owner / group / others, and each has its own read / write / execute permissions.

    Let’s review the data just mentioned above: the permission character of the file is: [- rwxrwxrwx “, and the nine permissions are in groups of three! Among them, we can use numbers to represent each permission. The score comparison table of each permission is as follows:

  • r:4
  • w:2
  • x:1

    The three permissions (R / w / x) scores of each identity (owner / group / others) need to be accumulated. For example, when the permission is: [rwxrwx –] the score is:

  • owner = rwx = 4+2+1 = 7
  • group = rwx = 4+2+1 = 7
  • others= — = 0+0+0 = 0

5、 Linux system account management

1. To add a new user account, use the useradd command. The syntax is as follows:

Useradd option user name

Parameter Description:

  • Options:

    • -C comment specifies an annotative description.
    • -D directory specifies the user home directory. If this directory does not exist, you can create a home directory by using the – M option.
    • -G user group specifies the user group to which the user belongs.
    • -The user group specifies the additional group to which the user belongs.
    • -The S SHELL file specifies the login shell of the user.
    • -U user ID specifies the user ID of the user. If the – O option is available, the ID number of other users can be reused.
  • user name:

    Specify the login name of the new account.