老男孩-yum及Linux必背命令

老男孩-yum及Linux必背命令


yum以及Linux必備命令

  1. yum
  2. Linux必備工具詳情
    1. 娛樂命令
    2. 必備工具

1.yum

  • yum源:Linux下載軟件 軟件倉庫

    • 默認的yum源是隨機地方的 修改到yum源為指定的網站
    • 增加新的yum源:epel
  • yum源配置文件:

[root@oldboyedu ~]# ll /etc/yum.repos.d/
total 40
-rw-r--r--. 1 root root 2523 Jan  7 23:46 CentOS-Base.repo
-rw-r--r--. 1 root root 1664 Nov 23  2018 CentOS-Base.repo.backup
-rw-r--r--. 1 root root 1309 Nov 23  2018 CentOS-CR.repo
-rw-r--r--. 1 root root  649 Nov 23  2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 Nov 23  2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Nov 23  2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Nov 23  2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 5701 Nov 23  2018 CentOS-Vault.repo
-rw-r--r--. 1 root root  664 Jan  7 23:59 epel.repo



[root@oldboyedu ~]# cat /etc/yum.repos.d/CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
#mirrorlist  下載地址
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#released updates 
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  • 把系統當前的yum源 修改為清華/阿里云下載
#查看Linux當前使用的yum源是什么?
[root@oldboyedu ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
repo id                  repo name                                              status
base/7/x86_64            CentOS-7 - Base - mirrors.aliyun.com                   10,097
epel/x86_64              Extra Packages for Enterprise Linux 7 - x86_64         13,510
extras/7/x86_64          CentOS-7 - Extras - mirrors.aliyun.com                    307
updates/7/x86_64         CentOS-7 - Updates - mirrors.aliyun.com                 1,010
repolist: 24,924
  • 修改為 從阿里下載軟件

    http://mirrors.aliyun.com/
    
    mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS.Base.repo.backup
    #
    wget curl 用于下載軟件
    wget centos 7 中 默認沒有安
    
  • 增加epel
curl -o /etc/yum.repos.d/epel.repo 
http://mirrors.aliyun.com/repo/epel-7.repo


[root@oldboyedu ~]# yum repolist 
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
repo id                  repo name                                              status
!base/7/x86_64           CentOS-7 - Base - mirrors.aliyun.com                   10,097
!epel/x86_64             Extra Packages for Enterprise Linux 7 - x86_64         13,510
!extras/7/x86_64         CentOS-7 - Extras - mirrors.aliyun.com                    307
!updates/7/x86_64        CentOS-7 - Updates - mirrors.aliyun.com                 1,010
repolist: 24,924

2.Linux必備工具詳解


必須安裝的工具

yum install -y tree

tree   vim wget bash-completion bash-completion-extras lrzsz net-tools sysstat iotop iftop htop unzip nc nmap telnet bc psmisc httpd-tools bind-utils nethogs cowsay sl 
#刪除linux下面 yum緩存
[root@oldboyedu ~]# yum clean all
命令 作用
tree 以樹形顯示目錄結構 ls
psmisc pstree 等命令
vim vi升級版
wget 下載工具
bash-completion(默認源) 自動補全增強工具,可以補全命令參數
bash-completion-extras(epel) 自動補全超級增強工具,可以補全命令參數
lrzsz 上傳下載工具rz和sz
net-tools ifconfig route命令屬于軟件包
sysstat sar iostat屬于軟件包
iotop 查詢網絡流量情況
iftop 查詢網絡流量情況
nethogs 顯示每個進程的流量情況
htop top升級版
unzip 解壓
nc ncat類似telnet
nmap 網絡掃描工具
telnet 檢查端口是否開啟
bc 基礎計算機
lsof 顯示所有被打開文件
dig DNS解析bind-utils軟件包
nslookup DNS解析bind-utils軟件包
host DNS解析bind-utils軟件包
htpasswd 創建密碼文件 存放用戶名和加密的密碼 一般用于nginx簡單認證中

2.1娛樂命令


#cowsay "奧力給" 奶牛說“奧力給”
[root@oldboyedu ~]# cowsay "奧力給"
 _____
< 奧力給 >
 -----
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

[root@oldboyedu ~]# animalsay "我來啦"
 _____
< 我來啦 >
 -----
 \     ____________ 
  \    |__________|
      /           /\
     /           /  \
    /___________/___/|
    |          |     |
    |  ==\ /== |     |
    |   O   O  | \ \ |
    |     <    |  \ \|
   /|          |   \ \
  / |  \_____/ |   / /
 / /|          |  / /|
/||\|          | /||\/
    -------------|   
        | |    | | 
       <__/    \__>

2.2必備工具


#1.tree  以樹形顯示目錄結構
## -L  2   顯示目錄中最多 幾層內容
[root@oldboyedu ~]# tree -L 1 /
/
├── bin -> usr/bin
├── boot
├── data
├── dev
├── etc
├── home
├── lib -> usr/lib
├── lib64 -> usr/lib64
├── media
├── mnt
├── myfile
├── oldboy
├── oldzhu
├── opt
├── proc
├── root
├── run
├── sbin -> usr/sbin
├── srv
├── sys
├── tmp
├── usr
└── var

23 directories, 0 files


#2.vim vi升級版

#3. wget 下載指定的文件
wget www.baidu.com
#下載到指定目錄 使用 -P 如果目錄不存在 則wget自動創建
默認下載到當前目錄
[root@oldboyedu ~]# wget -P 
/oldwang/lidao/oldboy/alex/ddd/xxxx/oooo/ www.baidu.com 
#4. 自動補全增強版
安裝完成后 第1次使用需要重新登錄(窗口 斷開 重新連接)
bash-completion(默認源)自動補全增強工具,可以補全命令參數
bash-completion-extras(epel)自動補全超級增強工具,可以補全命令參數
#5. bc   basic calc  計算機
[root@oldboyedu ~]# bc 
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
1/3
0

##  -l顯示帶小數
[root@oldboyedu ~]# bc -l
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
1/3
.33333333333333333333



##6.lrzsz  rz和sz

##7.htop

##8.nmap
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容