Summary of frequently-used CentOS commands

Source: Internet
Author: User

Summary of frequently-used CentOS commands
Some terminal commands are often used in centos or ubuntu linux. The following is a summary:

◆ Installation and logon commands: login, shutdown, halt, reboot, install, mount, umount, chsh, exit, and last;
◆ File processing commands: file, mkdir, grep, dd, find, mv, ls, diff, cat, ln;
◆ System management commands: df, top, free, quota, at, lp, adduser, groupadd, kill, and crontab;
◆ Network operation commands: ifconfig, ip, ping, netstat, telnet, ftp, route, rlogin, rcp, finger, mail, and nslookup;
◆ System security related commands: passwd, su, umask, chgrp, chmod, chown, chattr, sudo ps, who;
◆ Other commands: tar, unzip, gunzip, unarj, mtools, man, unendcode, and uudecode.

1. view the disk mounting status of the current linux system:

-S: the total number of data blocks occupied by each Names parameter.
-A: recursively displays the number of data blocks occupied by each file in a specified directory and Its subdirectories. If neither-s nor-a is specified, only the disk blocks occupied by each directory and Its subdirectories in Names are displayed.
-K: Used to list disk space usage in 1024 bytes.
-X: Skipping directories on different file systems is not counted.
-L: calculates the size of all files, and computes hard-linked files multiple times.
-I: displays inode information instead of block usage.
-H: print out the file system size in an understandable format, such as 136KB, 254 MB, and 21 GB.
-P: Use the POSIX output format.
-T: displays the file system type.

[Java] view plaincopy
  1. $> Df-k
The system displays the current linux disk Mount list.
Filesystem           1K-blocks      Used Available Use% Mounted on/dev/xvda1            20641404   1720784  17872096   9% /tmpfs                  4029128         0   4029128   0% /dev/shm

View File System Types

[Java] view plaincopy
  1. $> Df-T
File System Type capacity available in use % mount point
// Dev/hda7 reiserfs 5.2G 1.6G 3.7G 30%/
/Dev/hda1 vfat 2.4G 1.6G 827 M 66%/windows/C
/Dev/hda5 vfat 3.0G 1.7G 1.3G 57%/windows/D
/Dev/hda9 vfat 3.0G 2.4G 566 M 82%/windows/E
/Dev/hda10 NTFS 3.2G 573 M 2.6G 18%/windows/F
/Dev/hda11 vfat 1.6G 1.5G 23 M 99%/windows/G

2. View partition information and USB disk Information

[Java] view plaincopy
  1. $> Fdisk-l
View fat32 partition information [java] view plaincopy
  1. $> Fdisk-l | grepFAT32
3. view the file or directory list in the current directory [java] view plaincopy
  1. $> Ls-l
View hidden files or directories [java] view plaincopy
  1. Ls-al
4. Mount cdrom [java] view plaincopy
  1. $> Mkdir/mnt/cdrom
  2. $> Mount/dev/cdrom/mnt/cdrom
  3. $> Cd/mnt/cdrom
  4. $> Ls
Mounting an iso disk image file [java] view plaincopy
  1. $> Mount-oloop/image/v. iso/mnt/cdrom
Attach a Usb disk [java] view plaincopy
  1. $> Mount-tvfat-oiocharset = utf8, codepage = uft8/dev/sdb1/mnt/usb

Uninstall cdrom

[Java] view plaincopy
  1. $> Umount/mnt/cdrom -- unmount cdrom. You can simply use umount/mnt/cdrom.
5. display process information in the system
The java Process is displayed in BSD format.
$> Ps-aux | grep java
Display java Process in standard format
[Java] view plaincopy
  1. $> Ps-ef | grepjava
6. Common Networks
Ifconfig is a command line tool used to set and configure the NIC. To manually configure the network, this is a required command. The advantage of using this command is that you do not need to restart the machine. To assign the eth0 interface IP address 207.164.186.2 and activate it immediately, run the following command:
[Java] view plaincopy
  1. $> Ifconfigeth0210.34.6.89netmask?255.128broadcast210.34.6.127
Netstat
It is mainly used for Linux to view its own network conditions, such as the opened port, the user services, and the service status. It also displays the system route table and network interface status. It can be said that it is
A comprehensive network status inspection tool. By default, netstat only displays the ports with established connections. To display all listening ports, use the-a parameter:
[Java] view plaincopy
  1. $> Netstat-
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
Tcp 0 0 *: 32768 *: * LISTEN
Tcp 0 0 *: 32769 *: * LISTEN
Tcp 0 0 *: nfs *: * LISTEN
Tcp 0 0 *: 32770 *: * LISTEN
Tcp 0 0 *: 868 *: * LISTEN
Tcp 0 0 *: 617 *: * LISTEN
Tcp 0 0 *: mysql *: * LISTEN
Tcp 0 0 *: netbios-ssn *: * LISTEN
Tcp 0 0 *: sunrpc *: * LISTEN
Tcp 0 0 *: 10000 *: * LISTEN
Tcp 0 0 *: http *: * LISTEN

7. Add the link command

-B: delete the file, overwrite the previously created link.
-D allows the superuser to create hard links to directories.
-F Force Execution
-I interaction mode. If a file exists, the system prompts the user to overwrite the file.
-N indicates the symbolic link as a general directory.
-S soft link (symbolic link)
-V: detailed handling process

A hard Link means that a file can have multiple names.

[Java] view plaincopy
  1. $> Lnlog2013.logln2013
The soft link method generates a special file. The file content is directed to the location of another file and is a shortcut. [Java] view plaincopy
  1. $> Ln-s/usr/local/linux/work/local/linkwork
Delete the link rm-rf symbolic_name. Note that it is not rm-rf symbolic_name /.
[Java] view plaincopy
  1. $> Rm-rf/local/linkwork
8. Add users and groups

The groupadd command is used to add a new group to the system.
Format
-G gid: Specifies the group ID.
-O: The group ID is allowed. It does not need to be unique.
-R: ID of the group to be added, which is lower than the 499 SYSTEM account.
-F: When you join an existing group, the development program exits.

Create a new group and set the group ID to the system:
[Java] view plaincopy
  1. $> Groupadd-g344mysql
The useradd command is used to create a user account and the starting directory of the user. The permission is used by the super user to create a new user account and set the ID and group:
[Java] view plaincopy
  1. $> Useraddmysql-gmysql-u544
9. SEARCH Command

Search by file name
For example, to find a file named lilo. conf, run the following command:

[Java] view plaincopy
  1. $> Find/-namelilo. conf
"/" After the find command indicates searching the entire hard disk

Search by partial file name
Sometimes we know that only one file package contains the four characters of abvd. To find all the files containing the four characters in the system, run the following command:

[Java] view plaincopy
  1. $> Find/-name '* abvd *'
After entering this command, the Linux system will find all the files containing the four characters abvd in the/directory (where * is a wildcard ), for example, all files that meet the conditions, such as abvdrmyz, can be displayed.

10. Decompression command

.Tar.gz and. tgz Extract

[Java] view plaincopy
  1. $> TarzxvfFileName.tar.gz
.Tar.gz and. tgz compression [java] view plaincopy
  1. $> TarzcvfFileName.tar.gz DirName
11. Change command

Chmod permission to change files or directories

[Java] view plaincopy
  1. # Chmod + rfile/dir <Add read permission>
  2. # Chmod + wfile/dir <write permission>
  3. # Chmod + xfile/dir <add execution permission>
  4. # Chmod-R + rwxfile/dir <add all permissions and recursively process all files and subdirectories in a specified directory>
  5. # Chmod-R777file/dir <add all permissions and recursively process all files and subdirectories under the specified directory> cancel Permissions
  6. # Chmod-rfile/dir <cancel read permission>
  7. # Chmod-wfile/dir <cancel write permission>
  8. # Chmod-xfile/dir <cancel execution permission>
  9. # Chmod-R-rwxfile/dir <cancel all permissions and recursively process all files and subdirectories in a specified directory>
  10. # Chmod-R0file/dir <cancel all permissions and recursively process all files and subdirectories under a specified directory>

Change the owner or group of a file or directory.

Pattern: A: chown-R-h user name file/directory
The-R option means that the same operation is performed on all files in all subdirectories. The-h option means that the target file to which the link is directed is not affected when the owner of the symbolic link file is changed.
Note: Once the ownership of the file is handed over to another user, the ownership of the file cannot be retained, and the system administrator can only seek help.

B: chown User name: User Group: File/Contents

If all contents are changed, add the-R parameter for recursion.

For example, chown-R root/etc/config. cfg

Chown-R root: root/home

[Java] view plaincopy
  1. # ChownuserNamefile/dir
  2. # Chown-RuserNamefile/dir <recursively stores all files and subdirectories in the specified directory
[Java] view plaincopy
  1. # Chkggroupnamefile/dir
  2. # Chgrp-RgroupNamefile/dir <recursively process all files and subdirectories in the specified directory together>
  3. # Chgrp-RvgroupNamefile/dir <display Command Execution Process>

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.