1. Linux common commands

Yum command summary

  1. Yum clean clear cache information

清除header:#yum clean headers

Clear the downloaded rpm package: #yum clean packages

Clear the previous yum source: #yum clean all

  1. Use of Yum command

Install the specified package: #yum install –y <package>

    * Parameter -y means install directly without asking each time you install the package.

Update the specified package: #yum update <package>

Display the specified installation status: #yum list <package>

Delete the installed package: #yum rename / erase <package>

rpm command summary

  1. Query rpm software package

Check whether the specified software package is installed: #rpm –q <package name list>

Query all installed packages: #rpm –qa <list of package names>

Check if the package is installed: #rpm -qa | grep <list of package names>

For more detailed software information: #rpm -qi <package name list>

List the files installed by the package: #rpm -ql <list of package names>

  1. Install the rpm package

#rpm –ivh <full package name of package>

E.g:

#rpm –ivh –nodeps –force samba-common-3.5.4-68-el6-i686.rpm

* Parameter description:

i : installation mode using rpm ;

    v : display installation information during the installation process;

    h : during the installation process, output # sign to show the progress of the installation;

--nodeps --force : Do not check dependencies and force installation;

  1. Remove rpm package

#rpm --e <full path name of the package>

  1. Upgrade rpm software package

#rpm --Uvh <full package name of package>

  1. Verify rpm package

#rpm --V <full package name of package>

Vim editor

  1. Switch from command line mode to text input mode: input i, I, a, A, o, O, s, r ... command
  2. Switch text input mode to command line mode:

dd : delete the entire line where the mouse is

#G : Jump to line #

G : last line

  1. Switch the command line mode to the last line mode:

: q ! : Forced exit

: wq : save and exit

   : set nu : display line number

   ., $ d : Delete the current line to the last line

   : U : Restore deleted content

Note: vim can only be written as vi when minimized.

Operations under the file

Key name / command

Operation solution

/pattern

pattern batches the content to be found, vi will find the first content in the file that matches the specified content.

/

Repeat the last search to find the next matching content in the file.

?pattern

What the pattern is looking for. vi will search backward in the file for the first content that matches the specified content. (Note and / or are reversed)

 

?

Repeat the last search to find the content in the file that matches the last search.

%

Move the current cursor to the matching parentheses or square brackets

:s/patten1/pattern2

Replace everything in the current line that matches pattern1 with pattern2. (Is the current line)

 

:%s/patten1/patten2

Replace everything in the entire file that matches pattern1 with pattern2. (Replace one per line)

Permissions issue

  1. File or directory permissions modification

chmod [-R] mode file or directory

* -R : Recursively set the permissions of all files and directories in the specified directory.

For example: Set the permissions of the / opt / computer directory to 755.

#chmod 755 /opt/computer

Or written as

#chmod u=rwx,g=rx,o=rx /opt/computer

View: #ls -ld / opt / computer

  1. Change the owner of a file or directory

chown [-R] account name file or directory

chown [-R] account name: user group name file or directory

* -R : Continuous recursive changes, that is, all files and directories under the subdirectory are updated to this user group Often used to change a directory.

  1. Change the group of a file or directory

chgrp [-R] User group name file or directory

setfacl

  1. #setfacl -m u: user1: rw- test // Add user1 user has read and write permissions to the file test
  2. #setfacl -m g: user: rw test // Add user group user to read and execute the file test
  3. #setfacl -b test // Clear all acl
  4. #setfacl -x u: user1 test // Clear user acl rules for test files
  5. #getfacl test // View acl

parameter:

  -m: change the file's access control list

  -x: change according to the access control list entry in the file

  -b: delete all extended access control list entries

Published 4 original articles · Likes0 · Visits1

Guess you like

Origin blog.csdn.net/qq_44710985/article/details/105596240