Linux System Commands - Supplement

16 Reboot system command: reboot


15. Check the system version

      cat /etc/redhat-release

 

14. View all files in the directory and list the file size in the form of K, M, G

       ls -lh

 

13. grep search text

     The grep command in Linux is a powerful text search tool that uses regular expressions to search for text and print out the matching lines

    Format: grep [options]

//The main parameters
[options] main parameters:
-c: Print only the count of matching lines.
-I: Case insensitive (only applies to single characters).
-h: Do not display file names when querying multiple files.
-l: When querying multiple files, only output file names that contain matching characters.
-n: Display matching lines and line numbers.
-s: Do not display error messages for nonexistent or no matching text.
-v: Display all lines that do not contain matching text.
The main parameters of the pattern regular expression:
\: Ignore the original meaning of special characters in regular expressions.
^: Matches the starting line of the regular expression.
$: Matches the end line of the regular expression.
\<: Starts on a line matching the regular expression.
\>: to end of line matching regular expression.
[ ]: A single character, such as [A] that A meets the requirements.
[ - ]: Range, such as [AZ], that is, A, B, C up to Z all meet the requirements.
. : All single characters.
* : There are characters, the length can be 0.

    Example: View all lines containing "logback" in the catalina.out file

    grep -rn "logback" catalina.out

     

    PageUp: previous page

    PageDown: next page

    GG: Bottom

    gg: top

 

12. view View and modify text 

    view transList.jsp

        View and modify the text, and you can query data through /xxxx, n to query the next item, Shift+n to query the previous item

     vim transList.jsp

         View and modify text, you can copy and paste (right-click to copy, left-click to paste)

     vi  transList.jsp

         View and modify text

    

11. Commands to view the size and usage of the system disk

      df -h

 

10. Commonly used combination of ps and grep to find a specific process
      command: ps -ef|grep tomcat

 

9. When you do not have permission to operate, you can directly use the sudo or sh command to force the execution

     example:

          sudo kill 9 24782 force close process 24782                                                  
          sudo service tomcat start & tail -f /home/sxdkj/tomcat/log/support.log force start tomcat and see scrolling

log

          sh ./run.sh to force the execution of the run.sh startup file

 

8、查看启动的端口:netstat
    -a (all)显示所有选项,默认不显示LISTEN相关
    -t (tcp)仅显示tcp相关选项
    -u (udp)仅显示udp相关选项
    -n 拒绝显示别名,能显示数字的全部转化成数字。
    -l 仅列出有在 Listen (监听) 的服務状态

    -p 显示建立相关链接的程序名
    -r 显示路由信息,路由表
    -e 显示扩展信息,例如uid等
    -s 按各个协议进行统计
    -c 每隔一个固定时间,执行该netstat命令。

 

    例子:netstat -tupnl
    提示:LISTEN和LISTENING的状态只有用-a或者-l才能看到

 

7、切换到sudo权限
    sudo su -

6、将/data/home/app1104596675/TencentGetUserInfo.class文件拷贝的当前跟目录
    cp /data/home/app1104596675/TencentGetUserInfo.class ./

 

5、修改系统时间

    date -s 时间字符串

    例如只修改系统的日期,不修改时间(时分秒)

    date -s 2012-08-02

    或只修改时间不修改日期

    date -s 10:08:00

    当然也可以同时修改日期和时间

    date -s "2012-05-18 04:53:00"

    注意:由于日期和时间之间有空格,所以必须用引号引起来,否则命令会报错。

上述修改只是修改了linux的系统时间,CMOS中的时间可能还没有改变,所以为了保险,需要使用 clock -w 把当前系统时间写入到CMOS中。

    系统时间和CMOS时间的关系。系统时间是由linux操作系统来维护的;CMOS时间是CMOS芯片保存的时间。系统启动时,操作系统将从CMOS读出时间记录为系统时间,同时操作系统也会自动每隔一段时间将系统时间写入CMOS中。如果使用date命令修改系统时间后马上重启电脑,操作系统还没有将系统时间同步到CMOS,这样开机后就还是没有修改前的时间了,所以为了保险起见,最还还是手动使用命令 clock 将系统时间同步到CMOS中。

 

4、删除某一目录下的所有文件,只需进入该目录然后执行:rm -f *  就可以了例如

[root@iZ280qf2sbfZ file]# rm -f *

  就是删除file目录下的所有文件。

 

3、查找目录下的文件(查找/etc 下所有文件名包含"my"的文件)

[root@www etc]# find -name '*my*' -print

 

2、查询软件的安装路径

[root@www etc]# which mysql
/usr/bin/mysql

 

1、清空防火墙

iptables -F

 

 

100、查看tomcat的版本

    进入tomcat的bin目录下然后输入命令:./version.sh即可如图

 

 

 

    

    

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327036803&siteId=291194637