Notes on Linux commands

Source: Internet
Author: User
Tags clear screen gz file memory usage disk usage

-------------------------------Linux Directory-------------------------------

/: root directory, only directory under the general root directory, under Linux there is only one root directory. Everything starts here. When you enter "/home" in the terminal, you are actually telling the computer to start with the/(root directory) and then go to the House directory.
/bin:/usr/bin: A directory of executable binaries, such as common commands ls, tar, MV, Cat, and so on.
/boot: Place some files used by Linux system startup, such as kernel files of Linux:/boot/vmlinuz, System Boot Manager:/boot/grub.
/dev: Store the device files under the Linux system and access a file in that directory, equivalent to accessing a device, which is commonly used to mount the optical drive mount/dev/cdrom/mnt.
/etc: the directory where the system configuration file is stored, the executable file is not recommended in this directory, the important configuration files are/etc/inittab,/etc/fstab,/ETC/INIT.D,/etc/x11,/etc/sysconfig,/etc/ Xinetd.d.
/home: The Default User house directory, add user account, the user's home directory is stored in this directory, ~ represents the current user's home directory, ~edu represents the user Edu home directory.
/lib:/usr/lib:/usr/local/lib: A directory of libraries used by the system, which requires the assistance of a function library to invoke some additional arguments during execution.
/lost+fount: When an error occurs with the system exception, some missing fragments are placed in this directory.
/MNT:/media: CD-ROM default mount point, usually the disc is mounted under/mnt/cdrom, or not necessarily, you can choose any location to mount.
/OPT: A directory for the host to install additional software.
/proc: This directory data are in memory, such as system core, external device, network status, because the data are stored in memory, so do not occupy disk space, the more important directory has/proc/cpuinfo,/proc/interrupts,/PROC/DMA,/proc /ioports,/proc/net/* and so on.
/root: Home directory for system administrator root.
/sbin:/usr/sbin:/usr/local/sbin: Place executable commands that the system administrator uses, such as Fdisk, Shutdown, Mount, and so on. Unlike/bin, these directories are commands for the root of the system administrator, and the average user can only "view" and not be set up and used.
/tmp: The directory where files are temporarily stored by the general user or the program being executed, accessible to anyone, and important data cannot be placed in this directory.
/SRV: The data directory that needs to be accessed after the service starts, such as the Web page data that the WWW service needs to store within/SRV/WWW.
/usr: The application holds the directory,/usr/bin stores the application,/usr/share stores the shared data,/usr/lib storage cannot run directly, but is necessary for many programs to run some library files. /usr/local: Store the software upgrade package. /usr/share/doc: System description file storage directory. /usr/share/man: Program description file storage directory.
/var: Place files that change frequently during the execution of the system, such as log files that change at any time/var/log,/var/log/message: All login Files directory,/var/spool/mail: Mail storage directory,/var/run: After the program or service starts, its PID is stored in the directory.


------------------------------Common Linux Commands------------------------------
#ls--help: You can view the Help document
#man ls: The user manual can be viewed
SPACEBAR: Displays the next screen of the man page
Enter key: One line of the scroll man page at a time
B: Roll back one screen
F: Roll forward one screen
Q: Exit the man command
H: List all function keys
/word: Searching for word strings
#history: Enumerate the executed commands
#ssh IP Address: Make the corresponding remote connection
#cd: Jump Path
Relative path: How to jump based on the current directory
Absolute path: Path starting from/directory

。。 Parent's Directory
。 Current directory
-Return to the same directory as the previous level
~ Returns the directory where the current user is located
#ls: Lists the current files and folders
-A: Displays all subdirectories and files in the specified directory, including hidden files
-L: Displaying file details in a list
-H: Display file size in a humane way with-l
*: file represents all characters in filename
? : Represents any character in a file name
[]:[] and "] enclose character groups, which means that you can match any one of the character groups. "-" is used to represent the range of characters.
\: If you want to use wildcards as normal characters, you can precede them with escape characters. “?” and "*" in square brackets without the use of escape characters to lose the role of a wildcard character.

#more: Split screen display
#>: redirect
#>>: Redirect (append)
#pwd: View your current path
#touch: Create an action for the corresponding file
#mkdir: Create an action for the corresponding folder
#rmdir: Delete an empty folder operation
#rm: Not only can delete files, but also delete folders (is not empty)
#|: Piping
#clear: Perform clear screen operation
#ps: Perform the corresponding performance in the corresponding operating system view operation
-A: Displays all processes on the terminal, including other users ' processes
-U: Displays the detailed status of the process
-X: Show process without control terminal
-W: show widening to show more information
-R: Show only Running processes
#top: Dynamic display process, performance consumption List view operation
M: Sort by memory usage
P: Sort by CPU share
T: Sort According to the length of the process run time
U: The process can be filtered based on the user name entered later
K: The process can be killed according to the PID entered later.
Q: Exit
H: Get help
#kill [-signal] PID: Terminate process-9 force Terminate process operation
#date: Time-viewing operation to reset the corresponding time
Date [MMDDHHMM[[CC]YY][.SS]] +format
#cal: The view of the corresponding date-y corresponding year and the display of the log
#df: Detects disk space usage and availability of the file system and can display all file system usage of nodes and disk blocks
-A: Displays disk usage for all file systems
-M: Displayed in 1024-byte units
-T: Displays disk space usage for each specified file system
-T: Display file system
#du: Used to count the size of the disk space occupied by a directory or file, the command performs the same as DF, and Du is more focused on disk usage.
-A: Recursive display of data blocks in files and subdirectories in the specified directory
-S: Displays data blocks occupied by the specified file or directory
-B: Display disk usage in bytes
-L: Calculates all file sizes and computes multiple times for hard-linked files
#shutdown: Shutdown operation
-H now shuts down
#reboot: Restart the operating system
#shutdown –r Now: Restart the operating system, shutdown will prompt other users
#shutdown-H Now: Shut down immediately, where it is equivalent to 0 state
#shutdown-H 20:25: The system shuts down at 20:25 today
#shutdown-H + 10: The system shuts down automatically after 10 minutes
#init: 0 Shutdown 6 Restart
#ping: Check whether the IP address network channel is unblocked
#ifconfig: View the IP address of the current operating system
#ifconfig ens33 192.168.12.118: Modify the IP address of the current system
#sudo: Extract User rights
#ln: Establish connection file (ln source file link file)
-S: Soft connection identification (ln-s source file link file)
#which: View the location specified by the command


----------User, Rights Management----------
#whoami: View the user name of the current system account. System user information can be viewed through cat/etc/passwd.
#who: View user information for all currently logged on systems
-M or am: Displays only the username, logon terminal, and logon time of the WHO command
-Q or--count: Displays only the user's login account and the number of logged-in users
-U: Displays the user's last action to the current time interval after logon time
-U or--heading: Show column headings
#ping IP Address: Determine if the network can ping through
#exit: Sign out of your account
If it is a graphical interface, exit the current terminal
If you are using SSH telnet, log out of the login account
If it is the logged-in user after the switch, exit to return to the previous login account
#su: Switch Users
-: Switch working directory
Root: Switch to root user
Normal User: Switch to normal user

#groupadd: Adding actions for user groups

#groupdel: Delete operations for user groups

#usermod: Modify user group (using: USERMOD-G user Group user name)

#useradd: Add user account
-D: Specifies the home directory when the user logs on to the system, and if this parameter is not used, the system automatically establishes the directory with the same name as the user name
-M: Automatic Directory Creation
-G: Specify Group name
useradd-d/home/abc abc-m: Create the ABC user, if the/HOME/ABC directory does not exist, automatically create this directory, and users belong to the ABC Group
useradd-d/home/a a-g test-m: Create a user name called a, home directory in/home/a, if the home directory does not exist, automatically create the home directory, while the user belongs to the test group
CAT/ETC/PASSWD: View system Current user name
#passwd: Superuser can use the passwd command to set or modify a user's password for a normal user
#userdel Delete a user
-R: Force Delete
#sudo-s switch directly to super admin

#usermod: change user group usermod-g WH

#chmod: User u Group G other O to assign actions for the corresponding users permissions (chmod o+w file adds write permissions to other users of file files:)
U:user represents the owner of the file
G:group indicates that the owner of the file belongs to the same group, which is the user group
O:other means other people.
A:all said that all three of them are

+: Increase Permissions
-: Revoke Permissions
=: Set Permissions

R:read is readable, and for a directory, if there is no r permission, it means that the contents of this directory cannot be viewed through LS.
W:write means writable, and for a directory, without the W permission, you cannot create a new file under the directory.
X:excute is executable, and for a directory, if there is no X permission, it means that the directory cannot be accessed by CD.

#chown: Change action for directory or file owner
#chgrp: Changes in the group of directories and file owners

----------File Operation----------
#cat: View or merge file contents
#cp: The function of the CP command is to copy the given file or directory to another file or directory
-A: This option is typically used when copying a directory, preserving links, file attributes, and recursively copying directories, simply to preserve the original properties of the file.
-F: A target file that already exists without prompting
-I: Interactive replication, which prompts the user to confirm before overwriting the target file
-R: If the given source file is a directory file, the CP will recursively replicate all subdirectories and files in that directory, and the destination file must be a directory name.
-V: Show copy Progress
#mv: File Cut operation (File/folder rename operation possible)
-F: Disables interactive operation and does not prompt if overwrite is available
-I: Confirm the interactive operation, if the MV operation will result in overwriting the existing target file, the system will ask whether to rewrite, ask the user to answer to avoid overwriting the file by mistake
-V: Show Move Progress


----------File Search----------
#grep: grep [-option] ' Search content string ' file name
-V: Displays all lines that do not contain matching text (equivalent negation)
-N: Display matching lines and line numbers
-I: Ignore case
#find: Typically used to search for a qualifying file under a specific directory, or to search for a specific user's owner's file.
Find./-name test.sh: Finds all files named test.sh in the current directory
Find./-name ' *.sh ': Finds all files with the suffix. Sh in the current directory
Find./-name "[a-z]*": Finds all files in the current directory that begin with uppercase letters
Find/tmp-size 2M: Find files equal to 2M in/tmp directory
Find/tmp-size +2m: Find files larger than 2M in the/tmp directory
FIND/TMP-SIZE-2M: Find files less than 2M in the/tmp directory
Find./-size +4k-size-5m: Finds files larger than 4k and less than 5M in the current directory
Find/-perm 0777: Look for a file or directory with permission 777 in the current directory


----------Tar: Archive management----------
#tar: Archive management, TAR using format tar [parameters] package file name file
-C: Generate archive file, create package file
-V: Lists detailed procedures for archiving files, showing progress
-F: Specify the file name, and F must be the. tar file, so the option is the last
-T: Lists the files contained in the archive
-X: Unlocking the archive file
File Compression Decompression: gzip
-D: Unzip the GZ file
-C: The selection of the specified path after the file decompression
Method 1
First, create a tar package to compress the specified package file. Get the corresponding file tar.gz
TAR-CVF gzip
Unzip the specified tar.gz file into the specified package file tar, and open the tar file to release the content
Gzip-d TAR-XCF

Method 2
Compresses the specified file directly into a tar.gz file
TAR-ZCVF (GZ)
Unzip the specified tar.gz file directly
Tar-xcvf

Method 3
Compresses the specified file directly into a bz2 compressed file
TAR-JCVF (BZ2)
Extract the specified bz2 compressed file
Tar-jxvf

Method 4
Compresses the specified file into a zip-format package
Zip Xxx.zip *.py
Unzip the files in the zip-format tarball
unzip-d XXX Xxx.zip

Notes on Linux commands

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.