最近搞了一个阿里ECS,CentOS7,涉及到一些基本的Linux指令,在这里总结一下,在搭环境中常用的一些指令,熟悉这些指令就基本能够使用CentOS进行日常操作了。
更多的可以参考系统自带的 “Cammand --help” ,很实用。
目录相关指令
[root@Lettiy ~]# cd /usr/local
[root@Lettiy local]# ls
aegis bin etc games include lib lib64 libexec sbin share src
[root@Lettiy ~]# mkdir mytest
[root@Lettiy ~]# ls
mytest
[root@Lettiy mytest]# mkdir text.txt
[root@Lettiy mytest]# ls
text.txt
文件处理指令(移动,删除,复制<cp 基本操作类似于mv>)
[root@Lettiy mytest]# mv text.txt newname.txt
[root@Lettiy mytest]# ls
newname.txt
[root@Lettiy mytest]# mv newname.txt newdir
[root@Lettiy mytest]# ls
newdir
[root@Lettiy mytest]# cd newdir
[root@Lettiy newdir]# ls
newname.txt
[root@Lettiy newdir]# ls
new1 new2 new3 new4 newname.txt
[root@Lettiy newdir]# rm -f newname.txt
[root@Lettiy newdir]# ls
new1 new2 new3 new4
[root@Lettiy newdir]# rm -rf new4.txt
[root@Lettiy newdir]# ls
new1 new2. new3
[root@Lettiy newdir]# rm -rf -v new*
removed directory: ‘new1'
removed directory: ‘new2'
removed directory: ‘new3'
文件下载与解压
[root@Lettiy newdir]# wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-7/v7.0.79/bin/apache-tomcat-7.0.79.tar.gz
--2017-08-13 23:35:56-- http://mirrors.hust.edu.cn/apache/tomcat/tomcat-7/v7.0.79/bin/apache-tomcat-7.0.79.tar.gz
Resolving mirrors.hust.edu.cn (mirrors.hust.edu.cn)... 202.114.18.160
Connecting to mirrors.hust.edu.cn (mirrors.hust.edu.cn)|202.114.18.160|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8975395 (8.6M) [application/octet-stream]
Saving to: ‘apache-tomcat-7.0.79.tar.gz
100%[================================================================================>] 8,975,395 19.3KB/s in 4m 36s
2017-08-13 23:40:33 (31.8 KB/s) - ‘apache-tomcat-7.0.79.tar.gz' saved [8975395/8975395]
[root@Lettiy newdir]# ls
apache-tomcat-7.0.79.tar.gz
[root@Lettiy newdir]# tar -zxvf apache-tomcat-7.0.79.tar.gz
apache-tomcat-7.0.79/bin/catalina.sh
apache-tomcat-7.0.79/bin/configtest.sh
apache-tomcat-7.0.79/bin/daemon.sh
apache-tomcat-7.0.79/bin/digest.sh
……
[root@Lettiy newdir]# ls
apache-tomcat-7.0.79 apache-tomcat-7.0.79.tar.gz
文件安装与卸载
CentOS集成了yum,可配置源(repository)进行安装
[root@Lettiy newdir]# yum install postgresql
[root@Lettiy newdir]# yum list
[root@Lettiy newdir]# yum list|grep 'java'
[root@Lettiy newdir]# rpm -ivh software.rpm
文件更改/查看
[root@Lettiy newdir]# cat /etc/profile
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
}
if [ -x /usr/bin/id ]; then
if [ -z "$EUID" ]; then
# ksh workaround
EUID=`/usr/bin/id -u`
UID=`/usr/bin/id -ru`
fi
USER="`/usr/bin/id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi
# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
fi
HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
umask 002
else
umask 022
fi
for i in /etc/profile.d
如果要修改,进入按 I ,即可进入insert模式,进行更改;
保存:先ESC,然后输入:
wq:保存退出
q!:不保存退出
主要用于修改配置文件 ,例如:etc/proflie
端口和进程监控常用
[root@Lettiy newdir]# ps -ef|grep 'tomcat'
root 19785 1 0 Aug12 ? 00:01:05 /usr/develop/java/jdk1.8.0_144/bin/java -Djava.util.logging.config.file=/usr/develop/tomcat/apache-tomcat-8.5.20/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -classpath /usr/develop/tomcat/apache-tomcat-8.5.20/bin/bootstrap.jar:/usr/develop/tomcat/apache-tomcat-8.5.20/bin/tomcat-juli.jar -Dcatalina.base=/usr/develop/tomcat/apache-tomcat-8.5.20 -Dcatalina.home=/usr/develop/tomcat/apache-tomcat-8.5.20 -Djava.io.tmpdir=/usr/develop/tomcat/apache-tomcat-8.5.20/temp org.apache.catalina.startup.Bootstrap start
root 22647 22470 0 23:58 pts/0 00:00:00 grep --color=auto tomcat
本地文件上传
需利用lrzsz
yum install lrzsz
然后使用rz sz即可上传下载。
总结
以上所述是小编给大家介绍的Linux 日常常用指令及应用小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对编程网网站的支持!