您好,登錄后才能下訂單哦!
小編給大家分享一下Linux中常用指令有哪些,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
目錄相關指令
/*cd指令 *跳至到XX目錄下,從Xshell遠程登陸進去的目錄是/root *cd .. 返回上一層目錄 */ [root@Lettiy ~]# cd /usr/local /*ls 顯示當前目錄下的所有文件 */ [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
文件處理指令(移動,刪除,復制<cp 基本操作類似于mv>)
/*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 /*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: ‘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] /*tar 對于tar.gz文件進行解壓,解壓為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)進行安裝
/*yum 安裝/卸載 yum install software yum remove software */ [root@Lettiy newdir]# yum install postgresql /*查看yum可安裝的軟件包,可配合grep進行關鍵字查詢,例如‘java'*/ [root@Lettiy newdir]# yum list [root@Lettiy newdir]# yum list|grep 'java' /*rpm 剛剛解壓tar得到的rpm文件則需要使用rpm 安裝rpm -ivh 刪除rpm -e 查看已經安裝rpm -qa */ [root@Lettiy newdir]# rpm -ivh software.rpm
文件更改/查看
/*文件查看 cat指令、more指令、vi指令三者都可以實現查看 */ [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 如果目錄下存在則打開 如果不存在則新建一個空文件 */
如果要修改,進入按 I ,即可進入insert模式,進行更改;
保存:先ESC,然后輸入:
wq:保存退出
q!:不保存退出
主要用于修改配置文件 ,例如:etc/proflie
端口和進程監控常用
/*ps 檢測軟件是否運行 或查看正在運行的進程 ps -ef|grep 'name' 例如:檢測tomcat的運行狀況 */ [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 查看當前tcp監聽端口 netstat -tlp 查看當前tcp監聽端口, 需要顯示監聽的程序名,當不清楚mysql的監聽端口時比較好用 netstat -tl | grep 34006 只查看mysql的監聽端口,當前啟動的mysql端口為34006,明確知道mysql監聽端口時使用 */
本地文件上傳
需利用lrzsz
yum install lrzsz
然后使用rz sz即可上傳下載。
以上是“Linux中常用指令有哪些”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。