computer system
hardware
- calculator
- controller
- storage
- input device
- output device
software
system software
Operating System (Windows, Linux, Macos, etc.)
application
Linux commands
- See what shell version it is: ps
- Clear the screen: clear
- Create a new user: adduser helloword
- Set new user password: passwd helloword
- View system: uname
- View hostname: hostname
- switch user: su username
- View history commands: history
- Invoke a historical command: ! (command number)
- View the current working directory (print working directory): pwd
- Switch to the previous working path: cd ..
- Check which files and folders (lists) are in the current directory: ls
- View all files, including hidden files: li -a
- Display in long form: li -l or use its alias ll
- Create an empty file (files starting with . are hidden files): touch hello.txt
- Create the file as administrator: sudo touch hello.txt
- rwx = read/write/execute
- View file content: cat
- Look at the output results one screen at a time: (command) | less(more)
- View information about a command: man or --help or info
- delete file: rm
- Forcibly delete files: rm -f
- Create a folder: mkdir
- delete folder: rmdir
- echo: echo
- Echo the content into a file: echo hello,word! > hello.txt
- Copy file: cp hello.txt (folder)/(new name)
- Cut the file (or rename the file): mv shit.txt goodbye.txt (rename operation)
- Search for a string in a file (for example in general usage): cat goodbye.txt | grep script
- View the front part of the file, such as viewing the first five lines of the file: head 5 hello.txt
- Look at the back part of the file: tail
- Sort file contents: sort
- Compare the similarities and differences of two files: diff goodbye.txt hello.txt
- Count how many words are in the file: wc(-w,-l,-c, only count words, lines, characters)
- Internet download things: wget
- View file type: file
- Remove the duplicate part of the file content: uniq
- Compress/decompress files: gzip/gunzip
Archive files (together archive):
archive tar -cvf test.tar .txt .html
archive folder tar -cvf hello.tar abc/*
Unarchive tar -xvf test.tar
- Find python location: which python
- Find all paths containing python: whereis python
- Exit: exit()
- View time, calendar: date cal
- Recording script: script (with file name)
- View process: top
- View a process: ps -aux | grep (process name)
- View the downloaded process (take yum as an example): yum list installed | grep (process name)
Stop the process:
systemctl stop (process name)
start is the start process
status View process status
restart restart process
- Open a hole in the firewall (open port 80): firewall-cmd –zone=public –add-port=80/tcp –permanent
- Restart the firewall: firewall-cmd –reload
- View firewall status: firewall-cmd --state
Search file contents:
grep “function” *.html -n -R
-n means display line number, -R means recursive search
crontab -e:
Edit cron expressions
crontab -l:
Check
we
- set nu: call out the number of lines in vi
- syntax on: call out the highlighted syntax in vi
- set ts=4: Set the smart mark to four spaces
- Double-click dd: delete this line of code,
- u: restore
- yy: copy a whole line of code
- p:paste
- wq: save and exit
- G: go to the last line, or go to the 50th line, 50G
- gg: go back to the first line
Modify file permissions:
chmod u+x (filename)
chmod 755 (filename)
chmod 777 (filename)
chmod 444 (filename)
chmod 644 (filename)
Transcoding: #- - coding: utf-8 - -
- Restart the web server: nginx -s reload
Substitute (go to silent mode first):
:1, $s/regex/jlsfja/gice
g: global
i: ignore case
c: confirm
e: display error message
MySQL
To install mysql, enter:
yum install mariadb-server mariadb
Whether the installation was successful:
yum list installed | grep mariadb
Start the server:
systemctl start mariadb
Enter mysql:
mysql -u root
Set the boot to start mysql:
systemctl enable mariadb
Turn off auto-start at boot:
systemctl disable mariadb
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)
Soft link (also called symbolic link, hehe is equivalent to the shortcut of hello.py):
len -s hello.py hehe
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
select * from limit 5:
Limit the number of inquiries, only the first five can be inquired
select * from limit 5 offset 6:
Starting with (but not including) the fifth, look for the last six
select * from student order by(-id):
Search from the largest id
desc student:
View table structure
Join two tables via primary key and foreign key:
foreign key(g_id) references grade(id)
key and grade are two tables
select * from student s join grade g on g.id=s.g_id where g.g_name=’java’;
Associate two tables
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 |
+----------+----------+
Delete a field (column):
alter table student drop s_gardes
find the maximum value
select max(g_grades) from student
Find the minimum value:
select min(g_grades) from student
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
Check network connectivity:
ping
Check which services are started (name, IP address, process ID):
netstat -nap
- Reset item:
Link others remotely:
ssh username@address
Upload (download) files
sftp
Source code build installation:
make && make install
Start the redis service:
redis-server myredis.conf > redis.log &
& means let the service run in the background and redirect in redis.log
Switch back to the foreground:
fg %1
Add Python3 in Linux
- Download the source code of python3.6
- Upload the source code through xshell
- blog