Linux common commands,Linux


Features of linux operating system :
  There is no drive letter in the system. There are only files.
Directory structure:
  /etc stores system configuration files. (Network configuration firewall....)
  /home The home of ordinary users.
  /root The home of super administrators
  /usr share File
  /system root directory
common directory
disk command
  ls to view files or folders in a directory
  -a to view all files (including hidden files)
  -l to display detailed
combinations of files or directories:
  ls -al query all file names
  ll -a query All file names
cd switch directory
  cd / system root /
  cd space switch to the current user's root (home) by default ★★/root
  cd ~ the current user's root (home)/root
  cd .. the previous directory ★★
  cd - go back to the last visited directory

  pwd shows the current working directory

mkdir to create a directory mkdir -pv
  -p If the parent directory does not exist, first create the parent directory and then create the subdirectory
  -v Display the details of the execution

touch filename to create a file


File operation
  cp copy files or directories
    -r loop recursion--for copy directories★
    -b copied directory already exists a file or directory. First back up the original file or directory, in copying (understanding)
development:
publish project or resources , first backup and then overwrite.
  mv move or rename
    -f force overwrite
    rm delete file or directory
    -f force delete
    -r loop recursion--if the directory has subdirectories or files. Delete subdirectories or files first, and then delete the parent directory
combination :
  rm -rf to force the loop to delete ★★★

find query to query the file or folder in the specified directory -name
  query according to the file name or directory name
  find the specified directory -name 'file or directory name'


Document Editing ★★★
  vi or vim Editing files
  vim When modifying files, some keywords will be highlighted.
Format:
  vim file name
Basic mode:
general mode:
  vim file name, default to normal mode
  Copy, delete. . .
Insert mode:
  Press "a/i/o" to enter insert mode and
  modify the content of the file

    a Insert after the
    current cursor i Insert the current cursor
    o Insert the next line into
the bottom line mode:
  press esc to return to the normal mode.
  Press ":" to switch to the bottom line mode
    ":wq" save and exit
    ":q!" without saving quit

yy copy the current line -- normal mode
p paste -- normal mode
dd delete the line where the cursor is located -- normal mode
x delete the character where the cursor is -- only delete one -- normal mode

grep command: grep -i haha ​​a/1.txt
  is used to filter/query special characters
  grep -i keyword file path
    -i ignore case query

Pipe|
Format: Command1|Command2: The output of command1 is
combined as the input of command2:
  ps -ef|grep process name


File browsing ★★★
cat Query all contents of the file.
Applicable to: Query configuration file
  more Paging query (understand)
  less Paging query ★★★
  -m show percentage
  -N show line number
  / search down
  ? search up
  q exit

tail View the content at the end of the file ★★★
  -f loop query
combination:
  tail -f log file path

System command
ps to view the process
combination:
  ps -ef to query the details of all processes
  ps -ef | grep process name to query the specified process

kill kill process
  -9 force kill process
combination:
  kill -9 process number (pid)

ifconfig display network configuration information
ping test connectivity with the target host

Compress and decompress tar ★★★
  tar
    -c compress
    -x decompress
    -v show execution details
    -z whether to use gzip compression
    -f specify the name
combination of compressed files:
  tar -zcvf compressed file name needs to be compressed file or directory compression `
  tar -zxvf The name of the file to be decompressed is decompressed to the directory where the current compressed package is located by default.
  tar -zxvf The name of the file to be decompressed -C The directory is decompressed to the specified directory

File permission chmod
combination:
  chmod 777 file or directory adds read, write, and execute permissions to all users
  chmod 775 file or directory current and group users add read, write, and execute permissions, and other groups add read and execute permissions Permissions ★
  chmod 000 file or directory removes all permissions on a file or directory (rarely)

Network configuration:
Method 1. Modify the configuration file
  cat /etc/sysconfig/network-scripts/ifcfg-eth0

Restart the network service:
  service network restart

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324903007&siteId=291194637
Recommended