liunx- basic command 001jiangnan

Liunx command

Description See port number and process orders

netstat -nlp | grep httpd / 7088 ( process name or port number )

ps -ef | grep httpd / 7088 ( httpd main / sub-process, 7088 shows only a main course )

Kill -9 process ID

ps -ef | grep httpd | grep -v grep | awk '{print $ 2}' | xargs kill -9 bulk kill

 Tool Set - Tools - Options - Mouse and Keyboard

 

 

Liunx and Windows difference

Windows execution is actually in the installation directory - double-click the shortcut icon: .exe file

Liunx : Enter the command execution by the environment variable

echo $PATH

Liunx command comes in PATH under

$ PATH effects: After entering the command knockout round, display the corresponding content - in fact, to find the environment variable

Path and the path separated by a colon - lookup is performed from left to right - find on the implementation - can not find, keep looking - if you really can not find the pop-up prompts Command not Found

 

Execution paths have a look at what files - shows the file if there are not looking down

 

Software is installed

cd / opt / lampp

 

Start Service

① cd / opt / lampp ./lampp start cutting into the directory and the relative path start

② / opt / lampp / lampp start absolute path to the boot

 

Introduction execute the command without absolute path - execution starts in any directory

For example: a plurality jdk , the switching sometimes not effective versions perform the following operations

Vim /etc/profile

Edit the file - add a line at the end of the file Export the PATH = / opt / lammp: $ the PATH

 

$ PATH put back to allow the latest entry into force, from left to right execution

Direct execution lampp stop would not write ./lampp STOP

 

Soft connection command

Put in this directory mysql soft environment variables connected to - open service

① cd / opt / lampp / bin

② echo $PATH

③ cd /bin切换到环境变量的bin目录下

④ 在环境变量的bin下找mysql—提示没找到

⑤ Ln  -s  /opt/lampp/bin/mysql mysql  mysql软连接

⑥ Mysql -uroot -p123456

⑦ 在任意目录下登录mysql也可以

 

在任意目录下登录mysql

什么情况下用service启动—服务方式启动

cd  /etc/init.d/  这个目录下的命令都可以service启动

Service也就是个脚本执行原有的命令

启动mysql

① cd /etc/init.d

② Ln -s /opt/lampp/bin/mysql.server   mysqld

③ Service mysqld start—任意目录下都可以执行

④ ps -ef|grep  mysql

 

Liunx服务启动级别—在系统哪一级别启动和关闭相当于开机自动启动—相当于软件管家设置开机自动启动也可以不让他启动

 

命令格式command -option -option

绝对路径cd /绝对路径&相对路径cd ./相对路径

cd  .. 返回父路径

cd - 返回上一次操作目录

cd ~ 返回主目录

文件目录—增删改查

vi test创建一个文件-自动新建—输入命令i-从当前光标开始输入

—保存ESC:wq-w保存-q退出

—强制退出q!

                            —强制保存退出wq

一般模式下不是输入模式

i :在当前光标处进行编辑

I :在行首插入

A :在行尾插入

a :在光标后插入编辑

o :在当前行后插入一行

O :在当前行前插入一行

R :替换

切换到本行行尾:END$

切换到本行行首:Home^

切换到最后一行:G

切换到行首:gg

删除光标所在的一整行:dd

从光标开始向下删除两行:2dd

如果操作错了想返回:u

如果想删除当行后面5个字符:5x

拷贝命令:选中要复制的内容按下yy  到粘贴的地方按下p

查找替换:切换模式:1,$/hello/world/g

查找:/要查找的内容   n-找下一个  N-找上一个

新建目录—拷贝—移动—删除—查看

mkdir -P /test/test1  _创建子目录

cp -r  /test/  /opt_带子目录的拷贝—备份文件

cp -r  test  test.bak  -备份文件  -r如果有子文件夹一定要加这个

Profile文件比较重要要用之前一定要备份—.bak表示备份文件

mv 文件 目录 移动文件命令

rm  -fr  文件名 删除

 

 

 

 

ls  命令

共显示了七列信息,从左至右依次为:权限、文件数、归属用户、归属群组、文件大小、创建日期、文件名称

第一列可以用字符表示的文件类型

 -:普通文件 d:目录文件 l:链接文件 b:块设备文件 c:字符设备文件 p:管道文件

1-3文件持有者的权限4-6用户所在组的权限7-9其他的除了他组以为的权限

Chmod a+x所有人    g+x组的权限  o+x 其他人 u+x 自己 chmod  a+rwx

绿色文件: 可执行文件,可执行的程序 

红色文件:压缩文件或者包文件

蓝色文件:目录

白色文件:一般性文件,如文本文件,配置文件,源码文件等 

浅蓝色文件:链接文件,主要是使用ln命令建立的文件

红色闪烁:表示链接的文件有问题

黄色:表示设备文件

灰色:表示其他文件

 

按照大小查看ll  -h

 

隐藏文件ll  -a

 

打包压缩命令

tar -zcvf  文件-打包之后文件的名称.tar.gz   .tar.gz打包并压缩的文件)

z:压缩c:打包v:可视化能看到打包过程f:文件)

可以连续打包多个文件

tar -zcvf hello.tar.gz  etc  docs

 

解压命令

tar -zxvf   文件名—解压文件

l 查看文件

cat     由第一行开始显示内容,并将所有内容输出

tac     从最后一行倒序显示内容,并将所有内容输出

more    根据窗口大小,一页一页的现实文件内容

less    more类似,但其优点可以往前翻页,而且进行可以搜索字符

head    只显示头几行

tail    只显示最后几行  tail   -f看动态日志

nl      类似于cat -n,显示时输出行号

tailf   类似于tail -f  默认显示10

解释:

more的功能是将文件从第一行开始,根据输出窗口的大小,适当的输出文件内容。当一页无法全部输出时,可以用回车键向下翻行,用空格键向下翻页。退出查看页面,请按“q”键。另外,more还可以配合管道符“|”pipe)使用,例如:ls -al | more

more的语法:more 文件名

Enter 向下n行,需要定义,默认为1行; 

Ctrl f 向下滚动一屏; 

空格键 向下滚动一屏; 

Ctrl b 返回上一屏; 

= 输出当前行的行号; 

:f 输出文件名和当前行的行号; 

v 调用vi编辑器; 

! 命令 调用Shell,并执行命令; 

q 退出more

Less

less的功能和more相似,但是使用more无法向前翻页,只能向后翻。

less可以使用【pageup】和【pagedown】键进行前翻页和后翻页,这样看起来更方便。

less的语法:less 文件名

less还有一个功能,可以在文件中进行搜索你想找的内容,假设你想在passwd文件中查找有没有weblogic字符串,那么你可以这样来做:

[root@redhat etc]# less passwd

然后输入:

/weblogic

回车

此时如果有weblogic字符串,linux会把该字符已高亮方式显示。

退出查看页面,请按“q”键。

l 文件查找

find  / -name  filename

查看磁盘命令df -h  日志把磁盘写满了宕机了

 

du  /opt/lampp 查看文件大小

查看ip    Ifconfig

查看进程

ps -ef|grep mysqlmysql未启动、没有进程—下面图里grep mysql只是显示要查询程序的名称。

 service  mysqld start

ps -ef|grep mysql—启动后的看到路径、进程在哪里都展示出来了

 

杀死进程

Kill  -9  2275

批量杀进程

 

ps  -ef|grep httpd|grep -v grep—要把grep本身去掉

 

awk:处理段落—输出第二行的进程号

ps -ef|grep httpd|grep -v grep|awk '{print $2}'

 

批量杀死 ps -ef|grep httpd|grep -v grep|awk '{print $2}'|xargs kill -9

杀别得进程换一下httpd

xargs:前面产生的结果当成后面的参数

杀死后查看ps -ef|grep httpd

 

定时任务

Guess you like

Origin www.cnblogs.com/njq666/p/10943149.html