Common Linux command collection and collation

Source: Internet
Author: User
Tags chmod file system zip file permissions iptables port number pkill dmesg

Shutdown: Poweroff or shutdown-h now or init 0

Reboot: Reboot or Shutdown-r now or init 6

Close X-window:init 3

Start X-window:init 5 or start X

View IP Address: ifconfig

Linux kernel version: Uname-r

Basic command

1, view a port number, command: Netstat-pan|grep 80

2, check the Linux version is CentOS or Redhat, command: cat/etc/redhat-release

3, Zip folder compression command: Zip-r compressed final file name. zip folder name to compress

Firewall

1, start the Firewall, command: Service iptables start or/etc/init.d/iptables start

2, shut down the firewall, command: Service iptables stop or/etc/init.d/iptables stop

3, restart the firewall, command: Service iptables restart or/etc/init.d/iptables restart

Tomcat

1, start Tomcat, into the Tomcat installation directory under the Bin directory execution./startup.sh

2, stop Tomcat, into the Tomcat installation directory under the Bin directory execution./shutdown.sh

3, delete the log command, into the Tomcat installation directory under the Logs directory execution RM-RF *.*

1. Termination Order: CTRL + C

2. End Input: ctrl+d

3. View file system: Df-h Linux How to view the file system (disk usage)

4.LAMP Series:

Restart Mysql:/etc/init.d/mysqld restart

Restart Apache:/etc/init.d/httpd start

Apache configuration file path:/etc/httpd/conf/httpd.conf

PHP configuration file path:/etc/php.ini

Restart Network services: Service Network restart

Modify Site Directory Permissions:

Chmod-r 777./ecshop

Chown Apache:apache./ecshop

Bin Basic Command

boot loader files, Linux kernel

Dev device files

ETC System configuration file

Home User Master Directory

INITRD initial RAM Disk boot support (used during boot)

Lib shared library, kernel module

Lost+found storage of recovered files (if such files are found after a file system check)

Media removable mount points for media (such as DVDs and floppy disks)

Mnt typically as a mount point for local file systems, remote file systems

Opt for additional packages added

Proc kernel information, Process Control

The home directory of root super User (root user)

Sbin system commands (most can only be used by the root user)

SRV saves the data for the system service, where some of the data for the system service is currently stored in Var

SYS real-time information related to devices used by the kernel

Tftpboot Network boot support

TMP temp File

USR the second major software file hierarchy

var variable data (such as logs); buffered (spooled) files

#hostname View computer Names

#dmidecodegrep Manufacturer View Server manufacturer

#dmidecodegrep product Name To view the server model

#grep model name Proccpuinfo View CPU Information

#getconf Long_bit to see if the CPU is 32-bit or 64-bit

#cat Proccpuinfogrep Physical Idsortuniqwc-l View the number of physical CPUs

#cat Proccpuinfogrep CPU Coresuniq to see the number of cores in each physical CPU (that is, the kernel number)

#cat proccpuinfogrep Processerwc-l View the number of logical CPUs, if their value is not equal to (number of CPUs x cores), to support Hyper-Threading.

#dmidecode-T Memory view memory details

#cat Procmeminfo View memory information

#swapon-S To view all swap partitions

#free-M view total memory, usage, number of idle, total memory shared by multiple processes, total used memory, total available memory, swap partition.

Note:-+bufferscache equals used-buffers-cachedfree+buffers+cached. If the swap partition is used too much, it means that physical memory needs to be increased.

#dmesg grep ' Vendor ' to see the hard drive, optical drive, and other information

#hdparm-I DEVSDA display the hard drive parameter information

#fdisk-L View hard drive Total capacity

#df-ht View the usage of each partition

#du-sh etc View the size of the specified directory

#du-CSK Sort-rn head-n 10 to find the top 10 files or directories in the system that occupy the most space.

#isostat-X 1 5 View hard disk IO performance (yum-y install sysstat)

Note: If%util is close to 100%, there are too many IO requests, the IO system is full and the disk may have a bottleneck. If the idle is less than 70%, there is more wait,io pressure in the reading process.

#uptime view the system's current time, the host's elapsed time, the number of user connections, the system's last 1, 5, and 15-minute average load.

#vmstat 1 4 View the system's process status, memory usage, virtual memory usage, disk IO, interrupts, context switches, CPU usage.

Note: If R is often greater than 3 or 4, and the ID is often less than 50, the CPU load is heavy. Bi, Bo is not equal to 0 for a long time, indicating insufficient memory. Disk is often not equal to 0, and queues in B are greater than 2 or 3, indicating that IO is not performing well.

#uname-A To view kernel operating system CPU information.

#cat procversion Display kernel version

To view the operating system and version #head Etcissue

#file Sbininit to see if the system is 32-bit or 64-bit.

#lsmod View related modules that the system has loaded

#lspci List all PCI devices

#lsusb List all USB devices

#cat procloadavg View system load disks and partitions

#hdparm-I devhda View disk parameters (for IDE devices only)

#env View environment variable resources

#mount column-t View the partition status of a hook

#mount devcdrom Mntcdrom Mounted optical drive

#dmesg grep IDE View IDE device detection network at startup

#w View Active Users

#whoami View Current User

#id root to view the specified user information

#finger root View root user details

#runlevel View current running status

#ps-EF View All Processes

#top display process status in real time

#last View User logon log

#lsof-i22 to see which programs are occupied by 22 ports

#cut-D-f1 etcpasswd View all users of the system

#cut-D-f1 etcgroup View all groups of the system

#crontab-L View the scheduled task service for the current user

#kill-9 3820 force end of process with ID 3820

#killall Apache to end the process of Apache

#xkill kill the process in the graphical interface

#skill (pkill)-kill-u root Log off all root logins

#pkill (skill)-kill-t pts2 Log off pts2 users of this type of logon

#chkconfig--list List all system services

#chkconfig--list grep 2on lists all initiated system services

#ifconfig eth0 10.8.1.2 netmask 255.255.255.0 temporarily configure IP and subnet masks

#ifconfig eth0 Down, disable the NIC.

#ifconfig eth0 hw ether 000c2888fd26 Modify MAC Address

#ifconfig eth0 up to enable the NIC

#vi Etcsysconfignetwork-scriptsifcfg-eth0

Device=eth0

Bootproto=static

broadcast=192.168.1.255

Hwaddr=000c292c2ae2

Ipaddr=192.168.1.101

netmask=255.255.255.0

network=192.168.1.0

gateway=192.168.1.1

Onboot=yes

#sudo etcinit.dnetwork Restart

#cat Etcsysconfignetwork View hostname

#cat etchosts View Host hosts

#cat etcresolv.conf View DNS servers

#route Add default GW 10.8.1.1 configuration Gateway

#route add-net 172.16.6.0 netmask 255.255.255.0 GW 172.16.2.25 temporarily add static routes

#echo 172.16.6.024 via 172.16.2.25etcsysconfignetwork-scriptsroute-eth0 permanently add static routes

#iptables-L (netstat-r) view firewall settings

#route-n View the routing table

#netstat-LNTP View all listening ports

#netstat-ANTP View all connections that have been established

#netstat-S To view network statistics

#nslookup (Dig www.baidu.com)

Etcgroup and ETCPASSWD and Etcshadow group information and account information and password information

#useradd-D homeadmin-s binbash-u 33-g root-m Admin Add admin Group user admin

#usermod-G roots aa adding AA to Roots Group

#userdel-R admin Deletes the admin user and its home directory

Change Password #passwd admin

#passwd-L Admin Locks users

#passwd-u admin Unlocking user

#groupadd roots Create a group roots

#groupdel roots Delete a group roots

#groupmod Nroot Roots Modify the group name

#gpasswd-A root roots Add root to Roots Group

#gpasswd-D root roots to move root out of roots group

Modify sudoers file Permissions #chmod 777 Etcsudoers

#chown adminroot Install.log Modify Install.log owner for admin, group as root

#chgrp Admin Install.log Modify Install.log Group to admin

passwd in fact, only Root has permission to run, because its permission RWS s, so ordinary users have the right to run it.

The last three bits of TMP's permissions are RWT, which represents sticky-bit permissions that any user can write to, but does not allow to delete other people's data

If a file is set to a suid or sgid bit or sbit bit, it is displayed separately on the executable bit of the owner or the same group of users or other user's permissions. For example:

1,-rwsr-xr-x (4755) indicates that the executable bit is set in Suid and owner permissions

2,-rwsr--r--(4644) indicates that the suid is set, but the executable bit in owner permission is not set

3,-rwxr-sr-x (2755) means that the Sgid and the same set of user permissions are set to execute bits

4,-rw-r-sr--(2644) indicates that the Sgid is set, but the executable bit in the same group of user rights is not set

5,-rw-rw-r-t (1665) indicates that the executable bit is set in sbit and other user rights

6,-r--r--r-t (1444) indicates that the sbit is set, but the executable bit in other user rights is not set.

Suid,sgid,sbit are represented by 4,2,1, where they are placed at the front.

#chmod u±s filename Set or remove suid bit

#chmod g±s filename Set or remove Sgid bit

#chmod o±t tmp to set or remove sticky bits

#chattr +a tmpsb.sh files are only allowed to increase, not allowed to be modified and deleted.

#chattr +i tmpsa.sh files are not allowed to add, modify, and delete operations.

#lsattr tmpsb.sh

#umask 002

File default permissions are 666, directory default permissions are 777, and umask default permissions are 0022, so files and directories create default permissions of 644 and 755

Ubuntu

#apt-get update download but not update

Download and update #apt-get upgrade

#apt-get dist-upgrade Intelligent Update Software

#apt-get Install xipmsg install the Flying Pigeon biography book

#apt-get Install wine1.2 installation wine

#apt-get Install (NVIDIA-GLXXORG-DRIVER-FGLRX) (Nvidia-settingsfglrx-control) to install Nvidia or ATI display driver

#sudo gedit etcx11xorg.conf file content: Driver Fglrx or Driver nvidia

#glxgears或fgl_glxgears测试3D加速功能

#apt-get Remove Apache out of the package but contains a configuration file

#apt-get Remove--purge Apache removal Package and configuration file

#apt-get Clean Purge cache pack

#apt-cache-n Search games grep KDE games related KDE packages by package name

#apt-cache-n Search ^kde The name of the package that starts with KDE ($ put the end of the package with the KDE end)

#apt-cache showpkg mysql-server-5.0 View the information about the package

#rpm-qa to view all installed packages

#rpm-IVH apache.rpm Installation

#rpm-UVH apache.rpm Upgrade

#rpm-e Apache Uninstall

#rpm-va to verify that all RPM packages have been tampered with

#tar CZVF dirname.tgz dirname Compressed dirname directory

#tar TZVF dirname Display compressed file contents

#tar XZVF dirname.tgz-c ~source Unzip the file to the source directory

#.configure Configuration

#make Compile the Software

#make Install Installation

Executable files and configuration files compiled prior to #make clean cleanup

#make Distclean to clear all generated files

#make Uninstall Delete software

#vi Etcinittab to modify the login interface after startup

Remember to perform sync save cached data to hard disk before #poweroffshutdownhaltreboot execution

#shutdown-K now shutdown now!! Send a message to all users.

#init 0356 shutdown text mode graphics mode reboot

Log out of the computer #loginlogout login

#ls-la Homea

Create a file #touch filename

Create a directory #mkdir dirname

#rm-RF dirname Delete the directory and all its files

#last Show logon and logoff for all users

#lastb display all failed and incorrect logins

#cat ~.bash_history View the commands that the current user has run

#vi Etcsudoers Press I edit, join admin all= (All) and press ESC to enter wq!

Which through the user's path variable lookup, locate and Whereis are found by looking for a database, and find is directly searching for hard disk files.

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.