Common shell Command records in Linux and linuxshell commands

Source: Internet
Author: User
Tags scp command

Common shell Command records in Linux and linuxshell commands

Hardware

  • CPU Problems
Lscpu # view cpu statistics. cat/proc/cpuinfo # view CPU details, such as the Model and clock speed of each CPU.
  • Memory-related
Free-m # view the memory in brief. The unit here is MBcat/proc/meminfo # view the memory details.
  • Disk-related
Lsblk # view disk and Partition Distribution, intuitive display df-h # view the usage of each partition cat/proc/partitions # view the hard disk and partition mount | column-t # view the status of the mounted Partition
  • Nic Problems
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, for example, detailed parameters and indicators of eth0

Software

  • Kernel-related
Uname-a # view the kernel information of the current operating system) cat/proc/version # view the current operating system version cat/etc/issue # view the current operating system version information cat/etc/redhat-release # Same as cat/etc/SuSE -release # lsb_release-a # is used to view the linux compatibility distribution information lsmod # list the loaded kernel modules in suse.
  • Network
Ifconfig # view attributes of all network interfaces iptables-L # view firewall settings service iptables status # view Firewall status service iptables stop # disable firewall route-n # view route table netstat-lntp # view all listening port 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 list all listening tcp ports
  • System Management
Top # view detailed information about all processes in the system, such as CPU and memory! Df-lh # view hard disk size and usage mount # mount remote directory, NFS, local shared directory to hostname in linux # view/modify computer name w # view active user ID # view specified user information last # view User Logon log cut-d: -f1/etc/passwd # view all user cut-d in the system: -f1/etc/group # view all system groups crontab-l # view the current user's scheduled Task Service chkconfig-list # list all system services chkconfig-list | grep on # list all startup system Service Program rpm-qa # view all installed software packages uptime # view the system running time, number of users, load/sbin/chkconfig -- list # view the system Automatic startup list/sbin/chkconfig- add mysql # add MySQL to the startup Service Group of the system
  • File-related
Ls-lht # list all files and sizes in a folder, and have the access permission du-sh <dir> # view the size of the specified directory du-lh <dir> # view the specified directory and files ln-s # create soft link
  • Process Problems
Pstree-p pid # view all threads under a process pstree-a # display all the details of all processes. If the process name is the same, it can be compressed and displayed. Ps-ef # view all processes kill-9 pid # kill all test # kill-9 'pgrep test' # kill process. /test. sh & # make the program run nohup in the background. /test. sh & # run the program in the background
  • Compression and decompression
Zip-r dir.zip dir file # zip the directory dir and file to the zip package, zip-re dir.zip dir file # create a zip package, and encrypt unzip dir.zip # decompress tar-zcvf dir.tar.gz dir file # compress directory dir and file to tar-xf dir.tar.gz # decompress
  • Screen command

The biggest benefit of the screen Command Group is that after your shell exits or closes, the services you run will not be related. That is to say, we can enable a group of services in screen, it is not affected by the disconnection of the terminal.

Screen-S test # create a screenscreen-r test with the name test # Open the screenscreen-r pid with the name test # Open the screenscreen-ls with the process number pid # list all screenctrl + a, d # exit screenctrl + a, n # In a screen, switch to the next window ctrl + a, c # In a screen, create a new window
  • Scp command
Scp local_file remote_username @ remote_ip: remote_dir # copy the local file to the 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

Suppose the software package you want to install is called app. Note that the command here usually requires sudo or root permissions.

// Centos system and redhat system rpm-qa | grep app # Check whether the app is installed on the local machine; rpm-ivh app. rpm # suppose you have the rpm package of the app, directly install the sudo yum install app # Otherwise, install the yum update app online # update the apprpm-e app # Delete the installed app package // suse and opensuse system zypper search app # search for the Local Machine whether the app is installed; zypper install app # install zypper update app # update zypper remove app # Delete zypper lr # list all the installed sources that have been defined. Zypper ar # Add a new installation source. Zypper rr # Delete the specified installation source zypper mr # modify the specified installation source // apt-get install app in the ubuntu system # install apt-get update app # update apt-get remove app # delete apt-cache search app # search package dpkg-I app. deb # assume that you have the deb package of the app.

In linux, what is the path of the Shell history Command record file?

Bash shell in "~ /. Bash_history "(" ~ /"Indicates the user directory.) The file contains 500 used commands, which makes it easy to enter the used long commands. Each user with an account in the system has a ". bash_history" file in his directory.

Bash shell should save a small number of commands and delete these historical commands every time the user logs out.
Step 1:
The "HISTFILESIZE" and "HISTSIZE" lines in the "/etc/profile" file determine that all users can retain
Number of old commands saved. We strongly recommend that you set the values of "HISTFILESIZE" and "HISTSIZE" in the "/etc/profile" file to a smaller number, for example
30. Edit the profile file (vi/etc/profile) and change the following line:
HISTFILESIZE = 30
HISTSIZE = 30
This means that each user's ". bash_history" file can only save 30 old commands.
Step 2:
In the "/etc/skel/. bash_logout" file, add the following line "rm-f $ HOME/. bash_history ". In this way, the ". bash_history" file will be deleted every time you log out.

In linux, what is the path of the Shell history Command record file?

Bash shell in "~ /. Bash_history "(" ~ /"Indicates the user directory.) The file contains 500 used commands, which makes it easy to enter the used long commands. Each user with an account in the system has a ". bash_history" file in his directory.

Bash shell should save a small number of commands and delete these historical commands every time the user logs out.
Step 1:
The "HISTFILESIZE" and "HISTSIZE" lines in the "/etc/profile" file determine that all users can retain
Number of old commands saved. We strongly recommend that you set the values of "HISTFILESIZE" and "HISTSIZE" in the "/etc/profile" file to a smaller number, for example
30. Edit the profile file (vi/etc/profile) and change the following line:
HISTFILESIZE = 30
HISTSIZE = 30
This means that each user's ". bash_history" file can only save 30 old commands.
Step 2:
In the "/etc/skel/. bash_logout" file, add the following line "rm-f $ HOME/. bash_history ". In this way, the ". bash_history" file will be deleted every time you log out.

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.