Linux related commands

computer system

hardware

  1. calculator
  2. controller
  3. storage
  4. input device
  5. output device

software

  1. system software

    Operating System (Windows, Linux, Macos, etc.)

  2. application

Linux commands

  1. See what shell version it is: ps
  2. Clear the screen: clear
  3. Create a new user: adduser helloword
  4. Set new user password: passwd helloword
  5. View system: uname
  6. View hostname: hostname
  7. switch user: su username
  8. View history commands: history
  9. Invoke a historical command: ! (command number)
  10. View the current working directory (print working directory): pwd
  11. Switch to the previous working path: cd ..
  12. Check which files and folders (lists) are in the current directory: ls
  13. View all files, including hidden files: li -a
  14. Display in long form: li -l or use its alias ll
  15. Create an empty file (files starting with . are hidden files): touch hello.txt
  16. Create the file as administrator: sudo touch hello.txt
  17. rwx = read/write/execute
  18. View file content: cat
  19. Look at the output results one screen at a time: (command) | less(more)
  20. View information about a command: man or --help or info
  21. delete file: rm
  22. Forcibly delete files: rm -f
  23. Create a folder: mkdir
  24. delete folder: rmdir
  25. echo: echo
  26. Echo the content into a file: echo hello,word! > hello.txt
  27. Copy file: cp hello.txt (folder)/(new name)
  28. Cut the file (or rename the file): mv shit.txt goodbye.txt (rename operation)
  29. Search for a string in a file (for example in general usage): cat goodbye.txt | grep script
  30. View the front part of the file, such as viewing the first five lines of the file: head 5 hello.txt
  31. Look at the back part of the file: tail
  32. Sort file contents: sort
  33. Compare the similarities and differences of two files: diff goodbye.txt hello.txt
  34. Count how many words are in the file: wc(-w,-l,-c, only count words, lines, characters)
  35. Internet download things: wget
  36. View file type: file
  37. Remove the duplicate part of the file content: uniq
  38. Compress/decompress files: gzip/gunzip
  39. Archive files (together archive):

    archive tar -cvf test.tar .txt .html

    archive folder tar -cvf hello.tar abc/*

    Unarchive tar -xvf test.tar

  40. Find python location: which python
  41. Find all paths containing python: whereis python
  42. Exit: exit()
  43. View time, calendar: date cal
  44. Recording script: script (with file name)
  45. View process: top
  46. View a process: ps -aux | grep (process name)
  47. View the downloaded process (take yum as an example): yum list installed | grep (process name)
  48. Stop the process:

    systemctl stop (process name)

    start is the start process

    status View process status

    restart restart process

  49. Open a hole in the firewall (open port 80): firewall-cmd –zone=public –add-port=80/tcp –permanent
  50. Restart the firewall: firewall-cmd –reload
  51. View firewall status: firewall-cmd --state
  52. Search file contents:

    grep “function” *.html -n -R

    -n means display line number, -R means recursive search

  53. crontab -e:

    Edit cron expressions

  54. crontab -l:

    Check

we

  1. set nu: call out the number of lines in vi
  2. syntax on: call out the highlighted syntax in vi
  3. set ts=4: Set the smart mark to four spaces
  4. Double-click dd: delete this line of code,
  5. u: restore
  6. yy: copy a whole line of code
  7. p:paste
  8. wq: save and exit
  9. G: go to the last line, or go to the 50th line, 50G
  10. gg: go back to the first line
  11. Modify file permissions:

    chmod u+x (filename)

    chmod 755 (filename)

    chmod 777 (filename)

    chmod 444 (filename)

    chmod 644 (filename)

  12. Transcoding: #- - coding: utf-8 - -

  13. Restart the web server: nginx -s reload
  14. Substitute (go to silent mode first):

    :1, $s/regex/jlsfja/gice

    g: global
    i: ignore case
    c: confirm
    e: display error message

MySQL

  1. To install mysql, enter:

    yum install mariadb-server mariadb

  2. Whether the installation was successful:

    yum list installed | grep mariadb

  3. Start the server:

    systemctl start mariadb

  4. Enter mysql:

    mysql -u root

  5. Set the boot to start mysql:

    systemctl enable mariadb

  6. Turn off auto-start at boot:

    systemctl disable mariadb

  7. Create a symbolic link (hard link, delete hello.py, hehe will still have content, which is equivalent to creating a backup, but will not occupy memory):

    len hello.py hehe (hello.py is the file name, heh link)

  8. Soft link (also called symbolic link, hehe is equivalent to the shortcut of hello.py):

    len -s hello.py hehe

  9. awk:

    ps -aux | grep mysql | awk ‘{print}’ | xargs kill -9 2>error.log

    xargs means passing parameters, which is equivalent to passing the previous process number

  10. select * from limit 5:

    Limit the number of inquiries, only the first five can be inquired

  11. select * from limit 5 offset 6:

    Starting with (but not including) the fifth, look for the last six

  12. select * from student order by(-id):

    Search from the largest id

  13. desc student:

    View table structure

  14. Join two tables via primary key and foreign key:

    foreign key(g_id) references grade(id)

    key and grade are two tables

  15. select * from student s join grade g on g.id=s.g_id where g.g_name=’java’;

    Associate two tables

  16. Find out how many students are in each class:

mysql> select count(*) as '学生个数', g.g_name as '班级名称' from student s join
 grade g on s.g_id=g.id group by(g.id);
+----------+----------+
| 学生个数 | 班级名称 |
+----------+----------+
|        2 | python   |
|        2 | java     |
|        2 | php      |
|        2 | c        |
|        1 | html5    |
+----------+----------+
  1. Delete a field (column):

    alter table student drop s_gardes

  2. find the maximum value

    select max(g_grades) from student

  3. Find the minimum value:

    select min(g_grades) from student

  4. Find the average:

    select avg(g_grades) from student

Network related commands

[Learning website]( http://linuxtools-rst.readthedocs.io/zh_CN/latest/index.html
)
1. Query the network configuration:

ifconfig

ip 
  1. Check network connectivity:

    ping

  2. Check which services are started (name, IP address, process ID):

    netstat -nap

  3. Reset item:
  4. Link others remotely:

    ssh username@address

  5. Upload (download) files

    sftp

  6. Source code build installation:

    make && make install

  7. Start the redis service:

    redis-server myredis.conf > redis.log &

    & means let the service run in the background and redirect in redis.log

  8. Switch back to the foreground:

    fg %1

Add Python3 in Linux

  1. Download the source code of python3.6
  2. Upload the source code through xshell
  3. blog

Guess you like

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