最近搞了一個(gè)阿里ECS,CentOS7,涉及到一些基本的Linux指令,在這里總結(jié)一下,在搭環(huán)境中常用的一些指令,熟悉這些指令就基本能夠使用CentOS進(jìn)行日常操作了。
更多的可以參考系統(tǒng)自帶的 “Cammand --help” ,很實(shí)用。
目錄相關(guān)指令
/*cd指令 *跳至到XX目錄下,從Xshell遠(yuǎn)程登陸進(jìn)去的目錄是/root *cd .. 返回上一層目錄 */ [root@Lettiy ~]# cd /usr/local /*ls 顯示當(dāng)前目錄下的所有文件 */ [root@Lettiy local]# ls aegis bin etc games include lib lib64 libexec sbin share src /*mkdir 新建,可以是目錄,可以是文件 */ [root@Lettiy ~]# mkdir mytest [root@Lettiy ~]# ls mytest [root@Lettiy mytest]# mkdir text.txt [root@Lettiy mytest]# ls text.txt
文件處理指令(移動(dòng),刪除,復(fù)制cp 基本操作類似于mv>)
/*mv 可用于改名、也可用于移動(dòng) */ [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 /*rm 用于刪除文件 普通刪除文件用rm -f xx 普通目錄刪除 rm -rf xx 批量刪除同一名字 rm -v xx* (此處*類似于通配符) */ [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'
文件下載與解壓
/*wget 文件下載 wget url即可 */ [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: ‘a(chǎn)pache-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) - ‘a(chǎn)pache-tomcat-7.0.79.tar.gz' saved [8975395/8975395] /*tar 對(duì)于tar.gz文件進(jìn)行解壓,解壓為rpm文件再安裝 tar -zxvf */ [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)進(jìn)行安裝
/*yum 安裝/卸載 yum install software yum remove software */ [root@Lettiy newdir]# yum install postgresql /*查看yum可安裝的軟件包,可配合grep進(jìn)行關(guān)鍵字查詢,例如‘java'*/ [root@Lettiy newdir]# yum list [root@Lettiy newdir]# yum list|grep 'java' /*rpm 剛剛解壓tar得到的rpm文件則需要使用rpm 安裝rpm -ivh 刪除rpm -e 查看已經(jīng)安裝rpm -qa */ [root@Lettiy newdir]# rpm -ivh software.rpm
文件更改/查看
/*文件查看 cat指令、more指令、vi指令三者都可以實(shí)現(xiàn)查看 */ [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/*.sh ; do if [ -r "$i" ]; then if [ "${-#*i}" != "$-" ]; then . "$i" else . "$i" >/dev/null fi fi done unset i unset -f pathmunge export JAVA_HOME=/usr/develop/java/jdk1.8.0_144 export PATH=$JAVA_HOME/bin/:$PATH export CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar export CATALINA_HOME=/usr/develop/tomcat/apache-tomcat-8.5.20 /*vi vi directory 如果目錄下存在則打開 如果不存在則新建一個(gè)空文件 */
如果要修改,進(jìn)入按 I ,即可進(jìn)入insert模式,進(jìn)行更改;
保存:先ESC,然后輸入:
wq:保存退出
q!:不保存退出
主要用于修改配置文件 ,例如:etc/proflie
端口和進(jìn)程監(jiān)控常用
/*ps 檢測(cè)軟件是否運(yùn)行 或查看正在運(yùn)行的進(jìn)程 ps -ef|grep 'name' 例如:檢測(cè)tomcat的運(yùn)行狀況 */ [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 /*netstat netstat -tl 查看當(dāng)前tcp監(jiān)聽端口 netstat -tlp 查看當(dāng)前tcp監(jiān)聽端口, 需要顯示監(jiān)聽的程序名,當(dāng)不清楚mysql的監(jiān)聽端口時(shí)比較好用 netstat -tl | grep 34006 只查看mysql的監(jiān)聽端口,當(dāng)前啟動(dòng)的mysql端口為34006,明確知道m(xù)ysql監(jiān)聽端口時(shí)使用 */
本地文件上傳
需利用lrzsz
yum install lrzsz
然后使用rz sz即可上傳下載。
總結(jié)
以上所述是小編給大家介紹的Linux 日常常用指令及應(yīng)用小結(jié),希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
標(biāo)簽:贛州 昌都 臨沂 烏蘭察布 連云港 撫州 海北 廣東
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Linux 日常常用指令及應(yīng)用小結(jié)》,本文關(guān)鍵詞 Linux,日常,常用,指令,及,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。