Linux operating system entry commands

Directory commands

Add catalog

mkdir 【/路径/】目录名

Delete directory

Rmdir 【/路径/】目录名

Change directory

cp:(复制) 原路径 新路径 cp -r 复制文件夹

mv:(移动,重命名) 原路径 新路径

View catalog

  • - 查看当前路径:pwd
    - 切换到路径:cd
    - 查看目录内容:ls-a 
      - 展示所有文件(包括隐藏文件) -A(不包括.和..)
      - -l 展示所有的文件的详细信息
      - -R 递归查找所有子内容
    
mkdir .文件夹 建隐藏文件夹

File command

Create a file

touch 【/路径/】文件名

Delete Files

rm 【-r、 i、 f】【/路径/】文件名

Change file

同改变目录 cp/mv

View Files

ls

vi

document content

View file content

cat 文件名
head 【-n】文件名
tail 【-n】文件名

vi editor

mode

View mode, press a, A, i, I, o, O, insert to enter the edit mode, press:, / to enter the last line mode

Edit mode: press esc to enter view mode

Last line mode: press esc or delete the last line of code to return to view mode

hot key

  1. Quick positioning: first line gg, last line shift+G, nth line ngg
  2. Enter edit mode:
    • Insert after the cursor: a
    • Insert before the cursor: i
    • Insert at the end of the line: A
    • Insert at the beginning of the line: I
    • Insert in the next line: o
    • Insert in the previous line: O
  3. Copy: n (line) yy
  4. Delete/cut: n (line) dd
  5. Paste: n (line) p
  6. Undo the last time: u
  7. Replace: r: replace the character where the cursor is R: continue to replace until esc

Last line mode

  1. Exit: q

  2. Save:: w Save and exit:: wq or: x

  3. Mandatory:!

  4. Display line number: set nu Not display: set nonu

  5. Search string: search down:/search string up:? String

    Continue to find the next one: n Continue to find the previous one: N

  6. Replacement string: s/string to be searched/string after replacement/g

    Batch comment: %s/^/#/g

    Uncomment in bulk: %s/#//g

User Management

  1. User's home directory: ~

  2. Create user:

    useradd 用户名
    

  3. change Password:

    passwd 用户名
    

  4. Switch user:

    su 用户名
    

  5. delete users:

    userdel 用户名
    

authority management

  • Default permissions of the folder: drwxr-xr-x 755

  • Default permissions of the file: -rw-r–r--644

    1. First mark file type: d is directory,-is file, l is soft link

    2. The last 9 digits are divided into 3 parts: they represent the user's own authority, the user's group members, and the permissions of other group members (rwx: read, write, execute)

    3.chmod 777 -R test -R can recursively assign weights

  • Change the ownership of a file/folder to chown

    chown user name: group name file name changes the file’s attribution user to the corresponding user name, and the attribution group to the corresponding attribution group

Host name and host list

  1. The default host name is localhost.localhostDomain
  2. Two ways to modify the host name:
    • hostnamectl set-hostname new hostname
    • vi /etc/hostname in it, change the hostname to the new hostname (requires restart to take effect)
  3. Host list
    • vi /etc/hosts add: host IP address host name
  4. ssh username@hostname/IP address: can link to the corresponding host
  5. Add mutual trust (each machine must do the following operations on other machines)
    • ssh-keygen generates secret key
    • Copy to the key verification file: cat .ssh/id_rsa.pub> .ssh/authorized_keys
    • Transfer to the machine that needs mutual trust: ssh-copy-id -i .ssh/id_rsa.pub -p22 user@hostname

Process management

  1. View all processes ps -ef / ps -aux
  2. View an application ps -ef | grep application
  3. Kill process kill process pid, if you need to force kill -9 pid

Software Installation

1. Unzip the tar:

  • Packing: tar -zcvf Packed name The directory before packing
  • Unpack: tar -zxvf needs to be unpacked [-C needs to be unzipped to the directory]
  • Compression: gzip
  • Unzip: gunzip

2. Unzip the zip

  • Yum install -y zip/unzip
    unzip -d -o file directory file name

3. Install Yum online

4. Package installation rpm

5. Container installation docker

Remote transmission

scp file path target host:/target path

Guess you like

Origin blog.csdn.net/zmzdmx/article/details/108241632