linux常用软件安装,常用命令

时间:2023-03-09 02:11:51
linux常用软件安装,常用命令

jdk

[root@localhost]# tar -zxvf jdk-8u144-linux-x64.tar.gz

[root@localhost]# vi /etc/profile

在profile文件中添加下述内容

#set java environment
JAVA_HOME=/usr/java/jdk1.8.0_144
JRE_HOME=/usr/java/jdk1.8.0_144/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH

[root@localhost]# source /etc/profile

[root@localhost]# java -version

tomcat

[root@localhost]# tar -zxvf apache-tomcat-9.0.0.M22.tar.gz

[root@localhost]# /tomcat path/bin/startup.sh ---之后访问http://host:8080/,显示Tom猫

[root@localhost]# vi /tomcat path/conf/server.xml

 查找8080,找到如下两处地方
<<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
将port="8080"改成port="80"
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
这样做的目的是通过浏览器url访问时不用输入端口号,因为浏览器自动填充80
---重启之后访问http://host 显示Tom先生

[root@localhost]# vi /tomcat path/conf/tomcat-users.xml

拷贝下面代码
<role rolename="manager"/>
<role rolename="admin"/>
<role rolename="admin-gui"/>
<role rolename="manager-gui"/>
<user username="xxx" password="***" roles="admin-gui,manager-gui"/>
---重启访问http://host/manager,弹出窗口,输入用户名密码,在本地部署服务器项目

下面是修改Tomcat默认加载的root项目和index.html的方法,假设我要改成home项目下的first.html

[root@localhost]# vi /tomcat path/conf/server.xml

找到下面这段
<Engine name="Catalina" defaultHost="localhost">
<host name="localhost" appBase="webapps"
unpackWARs="true"
xmlValidation="false" xmlNamespaceAware="false">
.......
<host>
在host标签里面添加
<Context path="" docBase="home" debug="0" reloadable="true" />

[root@localhost]# vi /tomcat path/conf/web.xml

找到下述标签
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
改为
<welcome-file-list>
<welcome-file>first.html</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
---重启访问http://host Tom女士不见了,显示webapps/home/first.html

mysql

--使用 yum install mysql安装msyql后mysql启动不了

--是因为上述命令默认安装的是mariadb

--下载yum库

[root@localhost]# wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

--安装yum库

[root@localhost]# yum localinstall mysql57-community-release-el7-11.noarch.rpm

--安装mysql server

[root@localhost]#yum install mysql-community-server

--启动mysql server

[root@localhost]# service mysqld start

--查看mysql当前状态

[root@localhost]# service mysqld status

--获得临时密码

[root@localhost]# grep 'temporary password' /var/log/mysqld.log

--重置临时密码

[root@localhost]# mysql_secure_installation

--连接数据库

[root@localhost]# mysql -u root -p

--修改字符集

[root@localhost]# show varibles like '%char%';

[root@localhost]# exit

[root@localhost]# whereis my.cnf

[root@localhost]# vi /etc/my.cnf

[client]
default-character-set=utf8 在[mysqld]下添加
character-set-server=utf8

redis

[root@localhost]tar -zvxf redis-4.0.2.tar.gz

[root@localhost]mv redis-4.0.2 /usr/local/redis

[root@localhost]make MALLOC=libc

[root@localhost]make install

[root@localhost]vim redis.conf

修改bind 127.0.0.1(允许访问的ip) 和 daemonize yes(是否允许后台运行)  requirepass 040209(访问密码)

[root@localhost]redis-server ./redis.conf

[root@localhost]ps -ef | grep redis-server

[root@localhost]./utils/install_server.sh

[root@localhost]systemctl start redis_6379

rabbitmq

  • openssl

    [root@localhost]tar -zvxf openssl-1.0.1s.tar.gz

    [root@localhost]cd openssl-1.0.1s

    [root@localhost]./config --prefix=/usr/local/openssl

    [root@localhost]vi Makefile
将原来的:CFLAG=     -DOPENSSL_THREADS
修改为: CFLAG= -fPIC -DOPENSSL_THREADS

[root@localhost]make && make install

  • erlang:

    [root@localhost]yum install ncurses-devel

    [root@localhost]tar xf otp_src_20.1.tar.gz

    [root@localhost]cd otp_src_20.1

    [root@localhost]./configure --prefix=/usr/local/erlang20 --without-javac

    [root@localhost]make

    [root@localhost]make install

    [root@localhost]/usr/local/erlang20/bin/erl
  • RabbitMQ

    [root@localhost]xz -d rabbitmq-server-generic-unix-3.7.2.tar.xz

    [root@localhost]tar xf rabbitmq-server-generic-unix-3.7.2.tar

    [root@localhost]yum install python -y

    [root@localhost]yum install xmlto -y

    [root@localhost]yum install python-simplejson -y

    [root@localhost]mv rabbitmq_server-3.7.2/ /usr/local/rabbitmq
  • 导入环境变量

    [root@localhost]vim /etc/profile
添加如下命令:
PATH=$PATH:/usr/local/erlang20/bin:/usr/local/rabbitmq/sbin

[root@localhost]export PATH

[root@localhost]source /etc/profile

[root@localhost]rabbitmqctl start_app

nginx

[root@localhost]tar -zvxf nginx

[root@localhost]./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf

[root@localhost]yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

[root@localhost]make && make install

[root@localhost]./sbin/nginx

[root@localhost]./sbin/nginx -s reload

常用命令

  • df

    df -lh 查看磁盘的使用情况以及文件系统被挂载的位置

  • mount

    mount /dev/vda1 /mnt/d 将分区vda1挂载到mnt下的d目录上

  • vi编辑器

    复制 : yy(当前行) , nyy(复制n行)

    粘贴 : p

    删除 : dd(当前行)

    查找 : /+查找的内容,之后再按n匹配下一个

  • find

    删除满足条件的文件 find / -name mysql -exec rm -rf {} ;

    find dir/dir1 -ctime -num 查找在dir/dir1目录下num*24小时内被修改的文件

    find dir/dir1 -perm 777 查找在dir/dir1目录下访问权限为777的文件

    find dir/dir1 -name x1 查找在dir/dir1目录下名为x1的文件或者是目录

    find dir/dir1 -size x 查找在dir/dir1目录下大小为x的目录

  • whereis

    whereis my.cnf

  • ls

    ls -l xx.xx:

    显示该目录下的所有文件的详细信息,文件权限:

    -rw-rw-r--

      一共有10位数

      其中: 最前面那个 - 代表的是类型

      中间那三个 rw- 代表的是所有者(user)

      然后那三个 rw- 代表的是组群(group)

      最后那三个 r-- 代表的是其他人(oth老师er)

    改变文件权限:

    r= 4 表示可读

    w=2表示可写

    x=1表示可执行

  • cat

    cat xx 查看xx内容

    cat -n xx对xx内容进行编号

    cat x1 x2 >x3 合并x1和x2的内容并且输出到x3中,如果x3有数据则覆盖

    cat x1 x2 >>x3 合并x1和x2的内容后加在x3后面

  • chmod

    chmod 775 xx 将xx文件的权限改为-rwxrwxr-x

  • chown

    chown manager xx 将xx文件的拥有者变为manager

    chown manager:other 将xx文件拥有者变为manager,用户组变为other

    chown manager: xx 将xx文件的拥有者变为manager,用户组变为manager的

    chown :other 将xx文件的用户组变为other

  • cmp

    cmp x1 x2 比较x1文件和x2文件

    可能输出 : x1 x2 differ: byte 1, line 1 ,表示x1文件与x2文件在第一行第一个字节就不同

  • cp

    cp x1 dir/dir1 复制x1文件到dir/dir1的目录下,重名会报错

    cp x1 dir/dir1 x2 复制x1文件到dir/dir1的目录下,并且重命名为x2

    cp -fr dir/dir1 dir2/dir3 复制dir下的dir1文件夹到dir2/dir3目录下

  • diff

    diff x1 x2 比较x1与x2文件的不同,显示不同的内容

    diff -c x1 x2 分别显示x1与x2文件内容,把不同的标识了出来

  • file

    file x1 显示x1文件类型

    file * 显示当前文件夹下所有文件类型

  • gzip

    gzip x1 将文件x1压缩,形成x1.gz并代替原来的文件

    gzip * 将当前目录下的文件都压缩

    gzip -d x1.gz 对文件进行解压缩 注:gunzip x1.gz也可以进行解压缩

  • less长文本阅读

    less x1显示x1文本内容并显示一页

  • ln

    ln x1 x2 建立x1的硬链接x2

    ln -s x1 x3 建立x1的软链接x3

    软硬区别:x1和x2具有相同的inode号,指向同一个内容而x3通过指向x1指向具体内容

  • locate

    locate x1 查找符合x1文件名样式的文件和目录

  • more

    more x1显示x1内容

    more x1 x2首先显示x1内容,空格键后显示x2内容

  • mv

    mv x1 x2将文件x1重命名为x2

    mv x1 dir/dir1将文件x1移动到dir/dir1目录下

  • tac

    tac x1 反序输出x1

  • tar

    tar -c x1 x2 >x3.tar 将文件x1和x2压缩后建立x3文件

    tar -cf x3.tar x1 x2 同上

    tar -xzvf x1.tar.gz 解压缩x1.tar.gz文件

  • tee

    tee x1 通过标准输入到文件x1(覆盖x1内容),ctrl+D退出

    tee -a x1 同上 append到x1后,不是覆盖

    cat x1|tee x2 将x1内容输入到x2中