Software engineers must master linux command

è½¯ä »¶æμ <and • · ¥ ç <å¸å¿ ... é¡» è| 掌æ ?? ?? ¡cs "linuxå'½ä» ¤

 

Engineers of the four basic skills: database, linux, network protocols, testing tools, either just getting started or have been working for many years, these directions are to grasp. Today we revisit what engineers must master the linux command.

Engineers need to grasp the necessity of linux system?

Because Linux is widely used in the server space, there are many open-source and mature software, most applications are deployed on the background of linux, familiar with Linux operating system and related command, can deepen our structure and operational mechanism of the software understanding, can also increase their core competencies to broaden their skills stack, resulting in higher salary.

Different positions rank, capacity requirements for linux is not the same, if you are a junior engineer, then there may only need the command to view the log, analyze the reasons bug. If you are a mid-level engineers, you need to build a variety of test environments in linux environment, including applications, middleware applications rely on, as well as software testing tools. If you are a senior, you need to optimize the system architecture, writing shell scripts, improve test efficiency.

Ten software engineer linux scene command
1. Log View

Tomcat log file to view real-time view:

  1 cd / Home / Tomcat / logs # directory can also be relatively `
   2  
  3 ` tail -f # catalina.out real-time print log file `
   4  
  5 ` Ctrl + c # to exit Review

View Log command:

  . 1 tail -f log.txt: to cycle
   2  
  . 3 TAI -500f log.txt: 500 Check last row
   . 4  
  . 5 CAT File: See short file
   . 6  
  . 7 less File: Long File View
   . 8  
  . 9 head example.txt in: display file example. the first ten lines of the contents of txt head -n 20 example.txt: displays the first twenty lines of the contents of the file example.txt
2. Modify the contents of the configuration file

The most common is to modify environment variables

  . 1 Vim / etc / Profile enter letters I,
   2  
  . 3 to enter the edit mode (the INSERT)
   . 4  
  . 5 typing, press ESC, enter command mode.
  6  
  7 execution: wq, keeping modify.
  8  
  9 Enter soucre / etc / profile so that the environment variables to take effect.
10  
11 Can / profile viewed by cat / etc file modification success.
3.vi/vim Editor

vi / vim editor: linux system provides text editing tools for editing text files.

vim is an enhanced version of vi, an increase of some commands.

How to enter?

New: direct input vi

Open the file for viewing or editing: vi filename

Three modes:

插入模式:底部有“--INSERT--”标记,完成文本的编辑功能。

  1 i:在当前光标前插入文本;
  2 
  3 a:在当前光标后添加文本;
  4 
  5 o:在当前光标下一行插入文本;

命令模式:刚进入的状态,可以实现光标的移动以及字符的删除、复制、粘贴等。

  1 x:删除字符
  2 
  3 dw/dd:删除词/删除行
  4 
  5 yw/yy:复制词,复制行
  6 
  7 P:粘贴
  8 
  9 kjhl:上下左右
 10 
 11 ctrl+f/b:翻页

底线模式:命令模式下输入冒号进入,可设置行号、查找、替换字符、保存退出等。

  1 set nu/nonu:设置行号
  2 
  3 w filename:保存文件
  4 
  5 wq:保存退出
  6 
  7 q!:强制退出,不保存。
  8 
  9 edit:在vi里打开另一文件。
 10 

vim模式切换

4.查看tomcat进程,杀死进程,重启进程。
  1 查看tomcat进程
  2 
  3 ps -ef|grep tomcat
  4 
  5 ps –aux|grep tomcat
  6 
  7 杀死进程
  8 
  9 kill -9 进程ID
 10 
 11 ps -ef|grep tomcat#查看进程是否已关闭
 12 
 13 进入tomcat的bin目录cd /usr/local/tomcat/bin
 14 
 15 启动tomcat
 16 
 17 ./startup.sh
5.压缩解压缩文件
  1 tar cvf a.tar 1.txt 2.txt 3.txt#将3个文件放到文件包a.tar中。
  2 
  3 tar cvf /tmp/a1.tar *.txt#指定包存放的位置。
  4 
  5 tar xvf a.tar#将文件解压缩到当前目录。
  6 
  7 tar -zcvf a.tar.gz *.txt#打包与压缩为a.tar.gz。
  8 
  9 tar -zxvf a.tar.gz#解压缩并解包。

参数说明

  1 -c: 建立压缩档案
  2 -x:解压
  3 -t:查看内容
  4 -r:向压缩归档文件末尾追加文件
  5 -u:更新原压缩包中的文件
  6 -z:有gzip属性的
  7 -j:有bz2属性的
  8 -Z:有compress属性的
  9 -v:显示所有过程
 10 -O:将文件解开到标准输出
6.上传/下载

在xshell中可以通过下面的命令进行上传下载:

一般般需要安装,可使用 yum install lrzsz

rz:选择上传文件

sz 文件名:选择下载路径

当然你也可以通过xftp工具,进行可视化的上传下载。

7.文件查找

find:实时查找,通过遍历指定起始路径下文件系统层级结构,根据文件的属性进行查找,如文件名,文件大小,所有者,所属组,是否为空,访问时间,修改时间。

格式:

find [OPTION]... [查找路径] [查找条件] [处理动作]

结合通配符和管道命令有如下示例:

  1 find /etc  -name \*****.txt** **:在/etc目录下,查找以.txt结尾的文件,给出所有文件的路径。**
  2 
  3 **find /etc -name '\*abc\*':在/etc目录下查找文件名中含有字符串‘abc’的文件。**
  4 
  5 **find / -amin -5:查找在系统中最后5分钟访问的文件(access time)。**
  6 
  7 **find / -mmin -5:查找在系统中最后5分钟里修改过的文件(modify time)。**
  8 
  9 **find / -size -1000k:查找出小于1000KB的文件。**
 10 
 11 **find /etc | grep  local   在/etc目录下查找含有local这几个字母的所有文件或者目录
8.移动、复制命令

移动mv

  1 移动当前目录文件夹AA 到/home/aa/
  2 
  3 mv AA/ /home/aa/
  4 
  5 移动当前目录文件a.txt到 /home/aa/目录,并重命名为b.txt
  6 
  7 mv a.txt /home/aa/b.txt

复制 cp

  1 复制当前目录文件a.txt到/home/B目录
  2 
  3 cp a.txt /home/B
  4 
  5 复制文件夹 AA到/home/B目录
  6 
  7 cp -r AA/ /home/B

跨服务器复制:scp

命令格式: scp [参数] [原路径] [目标路径]

  1 从远处复制文件到本地目录
  2 scp [email protected]:/home/soft/tomcat.tar.gz /home/test/
  3 上传本地文件到远程机器指定目录
  4 scp /home/test/nginx-0.5.38.tar.gz [email protected]:/opt/soft/
9.权限修改

通过ls -l命令,可查看文件的相关属性。

                                                    ls -l

第一个字符:- (代表文件) d(代表目录) l(是L代表链接)

第二到第九位是文件的所属权限。

Linux file permissions are divided into four kinds:

read (read) write (writable) execute (executable) none (nothing)

9 is divided into three groups:

The first group represents the owner of the owner of the file what authority

The second group of people representative of all the groups in this file group owned by permission

The third group represents what else others have rights

Modify file access:

chmod who +/- r/w/x file

chmod u + x file only give yourself permission to perform

chmod ug + x file owner and group executable permissions plus

chmod ux file executable permissions canceled by the user

Express permission in Linux (Unix) inside, with three binary numbers to represent the

Example 000: 0111: 7

Therefore, r = 4, w = 2, x = 1

7 shows the permissions all here that there is no written permission 5

假设owner:rwx,group:r-x,other:r-x

The permissions set to: chmod 755 file

10. Server Performance Monitoring

Monitor CPU, memory

top: similar to the windows task manager, capable of running real-time monitoring system, the main display system resource usage of each process, such as cpu, memory, load and so on.

                                                 top command

free: See server memory usage, including physical memory, swap memory (the swap) and an idle and a remaining statistical kernel buffer memory.

                                               free command

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/lz1996/p/11576526.html