Common Linux Commands

Source: Internet
Author: User
Tags create directory diff cpu usage file permissions dmesg

Instructions Role Example Description
System Management Class commands
1 Cd Change the current directory cd/directory/ Converting the specified directory directories
CD- Return to last entered directory
CD ~ or CD Back to the user's home directory
2 ls (l) Displays the contents of the current directory or a specified directory ls/directory/ To display the contents of directory directories
l/directory/ Displays details about directory directories, relative to Ls-l/directory/
ls-lh/directory/ Displays detailed information about directory directories and displays them in a human form
3 Mkdir Create a new directory Mkdir-p/opt/directory To create directory directories under/opt/
4 RmDir Delete Empty Directory Rmdir/opt/directory Remove empty directories under/opt/directory
5 Cp Copy a file or directory CP File1/dir1/file2 Copy the file file1 to/dir1 and rename it to File2
Cp-rf/directory1/directory2 Copy all files of directory/directory1 to directory/directory2
6 Mv Move or rename a file MV file1/directory1/ Move file file1 under Directory directory
7 Rm Delete a file or directory RM file1 Delete files under current directory File1
rm-rf/tmpdir/ Delete directory Tmpdir and all content
8 Useradd Add user useradd-d/home/xxxx xxxx Add xxxx user, home directory is/home/xxxx
9 Userdel Delete User USERDEL-RF username Force Delete User and delete user's home directory
10 passwd Set User password passwd username Set User password
11 Su Switch from current user space to other user space SU username Switch to other user space
12 Date Displays or sets the current time of the system Date Query system time
Date [MMDDHHMM[[CC]YY][.SS]] Setting the system time
13 Hwclock Display or set hardware time Hwclock Query hardware Time
Hwclock-w Synchronizing the system clock to the hardware clock
Hwclock-s Synchronizing the hardware clock to the system clock
14 Uptime Displays the time the system is running and the system load Uptime Displays the time the system is running and the system load
15 Free Display system memory Usage Free Display system memory Usage

Vmstat (virtual memory)

Display Memory statistics Vmstat

Show statistical results once

Vmstat A Show a second display once
Vmstat a B Show a second display once, total display B
17 Ps Show system processes Ps Display the currently used shell
Ps-ef|grep keyword Checks if a process matching keyword exists
PS aux Show all processes for this system
18 Kill Sends a signal to the specified process Kill-9 PID To kill a process with a process ID of PID, first use ps-ef|grep keyword to find the PID of the process you want to kill.
Kill-l Displays a list of signals that can be sent
19 Top Show processes in the system running Top Dynamically display part of the process and manage it with a hotkey through the interactive interface it provides
Top-b Dynamic display of all processes, not provided interactive interface, can redirect display results
20 Uname Display System Information Uname-a Show all system Information
21st Hostname Show/Modify Host name Hostname Show host Name
Hostname name1 Modify Host Name
22 W.H.O. Show users who are currently logged on to the system W.H.O. Displays the user logged on to the system, showing only the user name, logon time, terminal type
W Displays the user logged in to the system, displays the user name, logon time, terminal type, CPU usage, current operation, and shows the total system uptime and load conditions
Who-r Displays the current RunLevel
23 Last Displays past and current users logged in to the system Last Displays past and current users logged in to the system
24 Halt Shutting down the system Sync;halt Shutting down the system
25 Reboot Rebooting the system Sync:sync:reboot Rebooting the system
26 Poweroff Shutting down the system Sync;sync;poweroff Shutting down the system
27 Shutdown Restarting or shutting down the system Sync;sync;shutdown-t 0-h Now Shut down the system immediately.
Sync;sync;shutdown-t 0-FR Now Restart the system now
28 Chkconfig Check/Set up the system's services CHKCONFIG-A Service Name Increase Service
CHKCONFIG-D Service Name Delete Service
Chkconfig- Enquiry Service
29 Crontab Query or set system timing tasks Crontab-e Edit the user's timer settings
Crontab-l List timer settings for this user
30 Dmesg Query system Boot Information DMESG >/dir/file Displays the boot process and kernel output information and redirects to a file
Storage Management class Commands
31 Fdisk System Partitioning Operations Tool Fdisk-l System Current Partition condition
32 Fsck File System Repair Fsck-a Automatic File system repair
33 Df File system disk space usage Df-h File system disk space usage
34 Mount/umount Mount/unmount a file system Mount Displays the current system mount status
Mount/dev/sdb/mnt/usb_dir Mount device/dev/sdb to directory/mnt/usb_dir
Umount/mnt/usb_dir Uninstalling/mnt/usb_dir
35 Du File space usage Du-a File space usage
36 Sync Write memory buffer contents to disk Sync Sync Init6 Write memory buffer contents to disk before system restart
Document Processing class commands
37 Stat View the details of a file Stat file View detailed information about the I-node and its structure of a file
38 Cat View text files Cat file View text files
39 Tail Tail of output file Tail-f file Always show file trailing 10 lines when the file keeps increasing
Tail-n num File Always show the end of file n lines when the file keeps increasing
40 More (less) pagination Display of text More file Pagination Display file
xxxxxx | More Pagination Display file
41 Vi Text Editor VI File Open or create Text
42 Tar Package a file TAR-ZCVF xxx.tar.gz XXX Package and compress files into. gz
43 File Identify file types File File1 Identify the type of file and give a hint
44 Diff Comparison of two file differences diff File1 File2 Compare the differences between File1 and File2
45 Find Search for files Find/Directory name-name file name Search for files under the specified directory
46 Whereis Search for files Whereis file1 Find files with file name File1 in a specific directory
47 chmod Change file permissions chmod Permissions File1 Change the permissions of File1
Chmod-r Permissions Dir1 Change Dir1 and its subdirectory permissions
48 Chown Change file Owner Chown main File1 Change the owner of File1
Chown-r Main Dir1 Change Dir1 and its sub-directory owner
Network Management class commands
49 Ifconfig Display or set up network devices Ifconfig To view the network card information that has been activated in the system
Ifconfig-a View all network card information in the system
Ifconfig EthX IP Configuring IP for NIC Ethx
Ifconfig EthX Down (UP) To activate (activate) the NIC Ethx
50 Ethtool Display or change network card settings Ethtool EthX View Network Port ETHX settings
Ethtool-i EthX View driver version information for the ETHX of the network port
Ethtool-s EthX Property settings Changing NIC configuration information
51 Netstat Show Network Connection parameters Netstat-rn To view the routing configuration in the system
Netstat-an View all network connectivity conditions in the system
52 Route Query or set Routing Route View the System routing configuration
Route add default GW Increase routing
Route Deldefault GW Delete route
53 Ping Detecting Network Connections Ping Detecting network connectivity between native and IP-address hosts
54 Ssh Telnet to a machine SSH [email protected]_address Log on to other machines from native SSH
55 Scp Remote Copy command SCP A.txt Copy files in the current directory on this side file1 to the Dir directory of the host IP address IP
SCP Copy files from the remote/dir2 directory with IP address file2 to the/dir directory on this Side
SCP Copy all files under the remote/DIR2 directory with IP address IP and its subdirectories to the/dir directory on this Side
Linux Package Operations
56 Rpm Package Operation Commands Rpm Queries whether the package is installed while querying its installed version.
Rpm-i scli-1.7.3-32.i386.rpm Installing the RPM Package
Rpm-e scli-1.7.3-32.i386.rpm Uninstalling RPM Packages
Drive Management

Modprobe/insmod (Rmmod)

Load (delete) driver/module Modprobe LPFC Load driver/Module
Insmod Driver (absolute path) Load driver/Module
Rmmod Driver Remove Driver/Module

Common Linux Commands

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: 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.