Linux Common shell commands

Source: Internet
Author: User
Tags continue zip centos iptables scp command linux

This article records my common or useful system level commands under Linux system, including hardware and software view, modify command, CPU, memory, hard disk, network, system management, etc. However, this article does not intend to introduce uncommon commands, and does not introduce the unique commands under each Linux distribution, and will continue to update later.

Description, I was tested in a CentOS 6.4 64-bit virtual machine system. The commands described in this article run the validation under this CentOS (and some of the commands will be tested in my suse/ubuntu system and will do the instructions), but the results are no longer listed.

Hardware Chapter

CPU related

Lscpu #查看的是cpu的统计信息.

Cat/proc/cpuinfo #查看CPU信息详细信息, such as the model of each CPU, frequency, etc.

Memory related

Free-m #概要查看内存情况 the unit here is MB

Cat/proc/meminfo #查看内存详细信息

Disk-related

Lsblk #查看硬盘和分区分布, the display is very intuitive

Df-h #查看各分区使用情况

Cat/proc/partitions #查看硬盘和分区

Mount | Column-t #查看挂接的分区状态

Network card related

Lspci | Grep-i ' ETH ' #查看网卡硬件信息

Ifconfig-a #查看系统的所有网络接口

Ethtool eth0 #如果要查看某个网络接口的详细信息, such as detailed parameters and indicators for eth0

Software articles

Kernel-related

Uname-a                #查看版本当前操作系统内核信息)
cat/proc/version       #查看当前操作系统版本信息
cat/etc/issue          #查看版本当前操作系统发行版信息
cat/etc/redhat-release #同上
cat/etc/suse-release   #suse系统下才可使用
lsb_release-a          # Release information for viewing Linux compatibility
lsmod                   #列出加载的内核模块

Internet

Ifconfig                #查看所有网络接口的属性
iptables-l             #查看防火墙设置
service iptables status #查看防火墙状态
service iptables Stop   #关闭防火墙
route-n                #查看路由表
netstat-lntp           #查看所有监听端口
netstat-antp           #查看所有已经建立的连接
netstat-s              #查看网络统计信息进程
netstat-at             #列出所有tcp端口
netstat-au             #列出所有udp端口
netstat- Lt             #只列出所有监听tcp端口

System Management

Top                     #查看系统所有进程的详细信息, such as CPU, memory, and so on, a lot of information!
df-lh                  #查看硬盘大小及使用率
Mount                   #挂接远程目录, NFS, local share directory to Linux
hostname                #查看/Modify Computer name
W                       # View active user
ID                      #查看指定用户信息
last                    #查看用户登录日志
cut-d:-f1/etc/passwd #查看系统所有用户
cut-d:-f1/etc/ Group  #查看系统所有组
crontab-l              #查看当前用户的计划任务服务
chkconfig–list         #列出所有系统服务
chkconfig–list | grep on #列出所有启动的系统服务程序
rpm-qa                 #查看所有安装的软件包
uptime                  #查看系统运行时间, number of users, load    
/sbin/chkconfig--list  #查看系统自动启动列表
/sbin/chkconfig–add MySQL #把MySQL添加到系统的启动服务组里面

File related

LS-LHT #列出一个文件夹下所有文件及大小, access rights

Du-sh <dir> #查看指定目录的大小

DU-LH <dir> #查看指定目录及各文件的大小

Ln-s #建立软链接

Process-related

Pstree-p pid           #查看一个进程下的所有线程
pstree  -              a #显示所有进程的所有详细信息, the same process name is encountered to compress the display.
ps-ef                  #查看所有进程
kill-9 pid             #杀死进程
kill all test           #杀死进程
kill-9 ' pgrep test '    #杀死进程
./test.sh &             #使程序在后台运行
nohup./test.sh &       #使程序在后台运行

Compression decompression

Zip-r dir.zip dir file #将目录dir, file files, etc. compressed into the ZIP package,

Zip-re dir.zip dir file #创建zip包, and encrypted

Unzip Dir.zip #解压

TAR-ZCVF dir.tar.gz dir file #将目录dir, file files, etc. compressed into the TAR package

TAR-XF dir.tar.gz #解压

Screen command

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/

The biggest advantage of the screen command group is that when your shell exits or shuts down, the services you run are not related, that is, we can open a set of services in screen and not be affected by a terminal disconnect.

Screen-s test          #创建一个名字为test的screen
screen-r test          #打开名字为test的screen
screen-r pid           # Open the screen screen-ls with process number
PID              #列出所有的screen
Ctrl + A,d              #当在一个screen时, exit screen
Ctrl + A,n              When in a screen, switch to the next window
Ctrl + A,c              #当在一个screen时 to create a new window

SCP command

SCP Local_file Remote_username@remote_ip:remote_dir #拷贝本地文件到远程机器上

Scp-r Local_dir Remote_username@remote_ip:remote_dir #拷贝本地整个目录到远程机器上

Package Installation Management Commands

Suppose the package you want to install is called the app, and note that commands here usually require sudo or root privileges.

CentOS system, Redhat system
Rpm-qa | grep app      #查找本机是否安装了app
rpm-ivh app.rpm        #假设你有app的rpm包 to install
sudo directly Yum Install app    #否则就在线安装
yum update app          #更新app
rpm-e app              #删除已安装的app包
//suse, openSUSE system
Zypper Search App       #查找本机是否安装了app
zypper install app      #安装
zypper update app       #更新
Zypper Remove app       #删除
zypper lr               #列出所有已定义的安装源.
zypper    ar            #添加新安装源.
zypper    rr            #删除指定的安装源
zypper    Mr            #修改指定的安装源
//ubuntu system
apt-get install app     #安装
apt-get update app      #更新
apt-get Remove app      #删除    
apt-cache search app    #搜索软件包
dpkg-i app.deb         #假设你有app的deb包 so that it is installed directly

Please be aware that the follow-up will continue to be updated as you use it further.

Author: cnblogs Lizhenghn

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.