some basic linux common commands (1)

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/LZPRO/article/details/90291779

linux has a lot of infrastructure frequently used commands, because too many commands, when not used for long linux often can not remember, here to be finishing a rainy day

1. Check the linux kernel command

   uname -a

2.linux file protection, prohibit modification and deletion mobile, etc.

   chattr +i

   Usage chattr command: chattr [-RV] [-v version] [mode] files ...

   +: Setting parameters on the basis of the original, an additional parameter.
   -: set the parameters on the basis of the original, remove parameters.
   =: Update set to specified parameters.
   A: atime file or directory (access time) can not be modified (modified), can effectively prevent such as laptops disk I / O errors.
   S: disk I / O synchronization options, functions like sync.
   a: That append, after setting the parameters, can only add to the data in the file, but not delete, multi-server log files for security, only root can set this property.
   c: That compresse, whether to set the file compressed before storage. Need to go through the automatic read decompression operation.
   d: That no dump, set the target files can not be backed up dump program.
   i: setting files can not be deleted, renamed, set the link relationship, and can not write or add content. i parameters of great help to the security settings of the file system.
   j: i.e. journal, this parameter is set so that when the mount by the parameter: data = ordered or data = writeback mounted file system, the file is first recorded (in the journal) when writing. If the parameter is set to filesystem data = journal, the parameter automatically disabled.
   s: Confidentiality delete files or directories that hard disk space is fully recovered.
   u: s and contrast, when set to u, the data content of the disk exists in fact, it may be used to undeletion.
Option parameters are used to the a and i. a mandatory only option that can be added can not be deleted, multiple security settings for logging system. And i is more stringent security settings, only the superuser (root) or have CAP_LINUX_IMMUTABLE processing capacity (identification) process can be applied to the option.

  chattr +i /etc/passwd

3. Check the linux memory usage

  (1) cat / proc / meminfo directly access RAM

  (2) free free returns the memory usage of the whole case $ free -h

  (3) htop to manually install

  (4) atop manually install

4. Review the use of linux port number

   netstat -tunlp

   netstat -tunlp | grep see what port numbers specified port

   lsof -i (the root)

   lsof -i: port number (the root)

   netstat -apn View all ports and process usage   

5. Review the use of linux process

   ps aux

   ps -aux | grep processes / process ID of a process view

6.linux file compression and decompression

   linux common compressed file extensions:

                * .Z compress file compression program

                * .Zip zip file compression program

                * .Gz gzip file compression program

                * .Bz2 bzip2 compressed program files

                * .Xz xz compressed program files

                * .Tar tar packaged data is not compressed

                * .Tar.gz tar packaged file, and after gzip compressed

                * .Tar.bz2 tar packaged file, and through bzip2 compressed

                * .Tar.xz tar packaged file, and been to the xz compressed  

  tar on Linux is commonly used in packaging, compression, compression tools, many of his argument, commonly used compression and decompression parameters are:

  -c: create compressed archives established parameters;

  -x: Unzip compression parameter files;

  -z: whether to use gzip compression;

  -v: Show file compression process;

  -f: Top document name, then immediately after the f file name can not be combined with parameters

   (1) extracting .tar.gz format

        tar  -zxvf  xx.tar.gz

        Unzip .tar.gz to the specified directory

        directory tar -zxvf xx.tar.gz -C

        .Tar.gz compressed file format into the designated directory

        tar -zcvf directory / archive .tar.gz source file name

   (2) extracting .tar.bz2 format

        tar -jxvf xx.tar.bz2

        Unzip .tar.bz2 to the specified directory

        directory tar -jxvf xx.tar.bz2 -C

        .Tar.bz2 compressed file format into the designated directory

        tar -jcvf directory / archive .tar.bz2 source file name

  7. linux View setting environment variables

      (1) see a single environment variable echo, for example: echo $ PATH

      (2) See all environment variables env

      (3) set the environment variable: set a value you can set the environment variable. Clear values ​​of environment variables with the unset command

       Common environment variables

       PATH determines the shell to which directories to find commands or programs 
       HOME current user's home directory 
       history record number HISTSIZE 
       LOGNAME current user's login name 
       HOSTNAME refers to the name of the host 
       SHELL current user Shell type 
       LANGUGE language related environment variables, multiple languages can modify this environment variable 
       MAIL current user's mail store directory 
       PS1 primary prompt is # for the root user, for the average user is $

       And environmental variables related documents:

       • / etc / profile - This file system is set up for each user environment information when the user first logs in, the file is executed and collect shell settings from the configuration file /etc/profile.d directory;.
       • / etc / environment - the second file the operating system uses at login system before reading your own profile, set the environment variable environment file;
       • / etc / bashrc - for each run the bash shell when the user executes this file bash shell is opened, the file is read;.
       • ~ / .profile - each user can use the shell of the file input information specific to their own use, when a user logs in, the file is only performed once! By default, it sets some environment variables, execute .bashrc file users;
       • ~ / .bashrc - when the file contains dedicated to the bash shell bash your information, log on, and when every time you open a new shell, the file is read;

       After modify environment variables relevant documents will not take effect immediately, it needs Source.

 

Guess you like

Origin blog.csdn.net/LZPRO/article/details/90291779