27. Common shell command record under Linux

Source: Internet
Author: User
Tags scp command



This article records my common or useful system-level commands under the Linux system, including hardware and software view, modify commands, CPU, memory, hard disk, network, System management and other commands. However, this article does not intend to introduce uncommon commands, nor does it introduce specific commands under each Linux distribution, and will continue to be updated in the future.



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



Hardware Chapter



    • CPU-related
Lscpu #View the statistics of the cpu.
Cat /proc/cpuinfo #View CPU information details, such as the model of each CPU, the main frequency, etc.
    • Memory-related
Free -m #Summary view memory situation The unit here is MB
Cat /proc/meminfo #View memory details
    • Disk-related
Lsblk #View hard disk and partition distribution, the display is very intuitive
Df -h #View the usage of each partition
Cat /proc/partitions #View hard drives and partitions
Mount | column -t #View the mounted partition status
    • Nic Related
Lspci | grep -i ‘eth‘ #View NIC hardware information
Ifconfig -a #View all network interfaces of the system
Ethtool eth0 #If you want to view the details of a network interface, such as eth0 detailed parameters and indicators


Software article


    • Kernel-related





Uname-a #View version of the current operating system kernel information)
Cat/proc/version #View current operating system version information
Cat/etc/issue #View version of current operating system release information
Cat/etc/redhat-release #同上
Can be used under Cat/etc/suse-release #suse system
Lsb_release-a # is used to view the release information of linux compatibility.
Lsmod # listing loaded kernel modules





    • Internet
Ifconfig #View the properties of all network interfaces
Iptables -L #View firewall settings
Service iptables status #View firewall status
Service iptables stop #close the firewall
Route -n #View routing table
Netstat -lntp #View all listening ports
Netstat -antp #View all established connections
Netstat -s #View network statistics process
Netstat -at #list all tcp ports
Netstat -au #list all udp ports
Netstat -lt # only lists all listening tcp ports
    • System Management
Top #View detailed information about all processes in the system, such as CPU, memory, etc., a lot of information!
Df -lh #View hard drive size and usage
Mount #mount remote directory, NFS, local shared directory to linux
Hostname #View/Modify computer name
w #View active users
Id #View specified user information
Last #View user login log
Cut -d: -f1 /etc/passwd #View all users of the system
Cut -d: -f1 /etc/group #View all groups in the system
Crontab -l #View the current user's scheduled task service
Chkconfig –list #List all system services
Chkconfig –list | grep on #List all started system services
Rpm -qa #View all installed packages
Uptime #View system running time, number of users, load
/sbin/chkconfig --list #View system autostart list
/sbin/chkconfig –add mysql #Add MySQL to the system startup service group
    • File related
Ls -lht #List all files and sizes and access rights in a folder
Du -sh <dir> #View the size of the specified directory
Du -lh <dir> #View the size of the specified directory and each file
Ln -s #Create soft links

    • Process-related
Pstree -p pid #View all threads under a process
Pstree -a #Show all the details of all processes, and the same process name can be compressed.
Ps -ef #View all processes
Kill -9 pid #kill process
Kill all test #kill process
Kill -9 `pgrep test` #kill process
./test.sh & # Make the program run in the background
Nohup ./test.sh & #Make the program run in the background
    • Compression decompression
Zip -r dir.zip dir file #Compress the directory dir, file file, etc. into the zip package.
Zip -re dir.zip dir file #Create a zip package and encrypt it
Unzip dir.zip #unzip
Tar -zcvf dir.tar.gz dir file #Compress the directory dir, file file, etc. to the tarball
Tar -xf dir.tar.gz #uncompress
    • Screen command


The biggest benefit of the screen command group is that when your shell exits or shuts down, the service you run does not matter, that is, we can open a set of services in screen without being affected by the disconnection of the terminal.


Screen -S test #Create a screen named test
Screen -r test #open the screen named test
Screen -r pid #Open the screen with the process number pid
Screen -ls #list all screens
Ctrl + a,d # When exiting screen on a screen
Ctrl + a,n #When on a screen, switch to the next window
Ctrl + a, c # create a new window when in a screen
    • SCP command
Scp local_file remote_username@remote_ip:remote_dir #copy local files to a remote machine
Scp -r local_dir remote_username@remote_ip:remote_dir #copy the entire local directory to the remote machine
    • Package Installation Management Commands


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


//centos system, redhat system
Rpm -qa | grep app # Find if the app is installed on the machine;
Rpm -ivh app.rpm #Assuming you have the app's rpm package, install it directly
Sudo yum install app # Otherwise install online
Yum update app #update app
Rpm -e app #delete the installed app package
//suse, opensuse system
Zypper search app # Find if the app is installed on the machine;
Zypper install app #install
Zypper update app #update
Zypper remove app #delete
Zypper lr #List all defined installation sources.
Zypper ar #Add a new installation source.
Zypper rr #delete the specified installation source
Zypper mr #Modify the specified installation source
//ubuntu system
Apt-get install app #install
Apt-get update app #update
Apt-get remove app #delete
Apt-cache search app #search package
Dpkg -i app.deb #assuming you have the app's deb package, so install directly 





Please be aware that follow-up will continue to be updated as the usage progresses.


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.