Linux development environment and application (MOOC course)-study notes

Course link

【Basic command】

1. Gadgets

  1. man view manual

Commonly used commands:
man name
such as man cd

  1. date read system date and time
jackgee@ubuntu:~$ date 
Thu 30 Apr 2020 04:58:58 PM CST
jackgee@ubuntu:~$ date "+%Y-%m-%d %H:%M:%S 星期%w"
2020-04-30 17:03:11 星期4
jackgee@ubuntu:~$ date "+%j"
121

  1. cal print calendar
jackgee@ubuntu:~$ cal
     April 2020       
Su Mo Tu We Th Fr Sa  
          1  2  3  4  
 5  6  7  8  9 10 11  
12 13 14 15 16 17 18  
19 20 21 22 23 24 25  
26 27 28 29 30        
                      
jackgee@ubuntu:~$ cal 1 2020
    January 2020      
Su Mo Tu We Th Fr Sa  
          1  2  3  4  
 5  6  7  8  9 10 11  
12 13 14 15 16 17 18  
19 20 21 22 23 24 25  
26 27 28 29 30 31 
  1. bc calculator
    Advantages:
    1) Precision can be customized
    2) Support variables, functions, conditions and loops
jackgee@ubuntu:~$ bc
a =10
b = 2
a/b

Output:

5

Use scale to customize precision

scale =6
a/b

Output

5.000000

5. passwd change user password

Ordinary user:
need to verify the original password first
root user:
do not need to verify the original password to set up,
you can also use the passwd username to forcibly modify other user passwords

2. System status

  1. who determines the users entered in the system
jackgee@ubuntu:~$ who 
jackgee     :0           2020-05-01 07:57 (:0)
jackgee@ubuntu:~$ whoami
jackgee

  1. Uptime understands resource startup time and busyness
    . The three parameters in load average correspond to CPU:
    1-minute average load, 5-minute average load, and 15-minute average load. understand more
jackgee@ubuntu:~$ uptime
 09:05:06 up  1:08,  1 user,  load average: 0.94, 0.36, 0.21
  1. top lists the top processes that take up resources
index PR NI VIRT RES SHR Process status %CPU %MEN TIME+ COMMAND
meaning Process scheduling priority The nice value (priority) of the process Virtual memory used by the process Resident memory Shared memory Common: S sleep R run Z zombie Percentage of CPU time from the last update to the present Percentage of physical memory used CPU time used Command name
jackgee@ubuntu:~$ top
进程号 USER      PR  NI    VIRT    RES    SHR    %CPU  %MEM     TIME+ COMMAND   
 2679 jackgee   20   0 4789124 207732  90164 S  13.2   7.0   7:00.73 chrome 
  1. ps will selectively print out the process status in the kernel
command Options Features
ps Only list the processes started by the current terminal
ps -e List all processes in the system
ps -f List processes in full format
ps -l List processes in long format
jackgee@ubuntu:~$ ps 
    PID TTY          TIME CMD
   5501 pts/0    00:00:00 bash
  12136 pts/0    00:00:00 ps
jackgee@ubuntu:~$ ps -f
UID          PID    PPID  C STIME TTY          TIME CMD
jackgee        5501    5487  0 May01 pts/0    00:00:00 bash
jackgee       12138    5501  0 09:43 pts/0    00:00:00 ps -f
jackgee@ubuntu:~$ ps -l
F S   UID     PID    PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
0 S  1000    5501    5487  0  80   0 -  4878 do_wai pts/0    00:00:00 bash
4 R  1000   12139    5501  0  80   0 -  5009 -      pts/0    00:00:00 ps
parameter name significance
S Process status
UID User ID
PID Process ID
PPID Parent process ID
C The CPU usage of the process in the last period of time (second level)
PRI Process priority (dynamic kernel update)
NI nice value, priority correction parameter; PRI(new) = PRI(old)+NI
ADDR Specify the location of the program in the memory, the execution program is generally "-"
SZ Process logical memory size
WCHAN "-" process in operation
TTY Terminal name
TIME Used CPU time
CMD Command name
  1. Free memory usage management
    Linux uses temporarily unused memory to cache read and write disk information to improve reading efficiency.
jackgee@ubuntu:~$ free
              总计         已用        空闲      共享    缓冲/缓存    可用
内存:     2954128     2226728      199556      145764      527844      398200
交换:            0          0           0 

3. Text processing

  1. Redirection mechanism

Output redirection:
For example, ls -l> out.txt
input redirection
For example: sort <in.txt

  1. Pipeline mechanism

For example: ls -l | sort
transfers the output of the ls query result into the input of sort through the pipeline mechanism

Guess you like

Origin blog.csdn.net/weixin_43347204/article/details/105865567