Linux basic commands (partial)

Source: Internet
Author: User
Tags parent directory

Help: Assistance commands
Use format:
Help plus the commands you need to see, such as help PWD
Will get a description of the relevant command
Command--help, such as LS--help
will see the use of related commands

Man: Help manual command
Man plus commands to look at, such as man file
Get the user manual for the file command

Export the Help manual to a text file for learning
Man Plus Command | Col-b > Export File name
For example, the use of the LS command to export to a T60.TXT file
Man ls | Col-b > T60.txt
The meaning of Col-b is to remove special characters.

PWD: View your current directory

CD: Switch directories
For example, enter the T60 directory: CD T60
Switch to Parent directory: CD.
Switch to directory: CD/
Switch to the host directory: CD ~
Return to previous directory: CD-

ls: Show directory contents
Parameters:
-L: Display directory contents in a detailed list
-A: Show hidden files
-D: Show only the current directory's own properties
-H: Displays the file size in KB and needs to be used with-l
-r: Displays the contents of all subdirectories in the directory
For example, view the size of files and folders in the current directory: LS-LH
View the size of the T60 file under the root folder: Ls-lh/root/t60
View procedure supports wildcard characters,? Represents a character that represents any character
For example, look at all files in the root folder that begin with S: ls-lh/root/s
. *

Du: Viewing the space consumption of directories and files
Parameters:
-A: All files are counted
-H: Display size in KB
-S: Total size of this directory
For example, view the total size of the root folder: Du-sh/root

mkdir: command to create a directory
Parameters:
-P: Creating nested Multi-level catalogs using
For example, create a/ROOT/T60/NB directory: Mkdir-p/ROOT/T60/NB

LN: Creating a Connection File
Parameters
-S: Create a soft link file
For example, linking/etc/httpd/conf/httpd.conf to/root/t60.conf
Soft: Ln-s/etc/httpd/conf/httpd.conf/root/t60.conf
Hard: ln/etc/httpd/conf/httpd.conf/root/t60.conf

CP: Copy command
Parameters:
-F: Overwrite file does not alert
-I: Overwrite file reminders
-P: Preserve file permissions before copying
-R: Add-r when copying directories
For example, copy the/etc/httpd/conf/httpd.conf file to/root/t71.conf
Cp/etc/httpd/conf/httpd.conf/root/t71.conf
For example, copy the/etc/httpd/conf/folder to/root/
Cp-r/etc/httpd/conf//root/

RM: Delete files or folders
Parameters:
-F: Direct Delete no reminders
-I: Reminders when deleting
-r: Delete entire directory tree
For example, delete the/root/conf/directory
rm-rf/root/conf/

MV: Moving files or directories
Effects similar to CP are used to rename files
For example, change T60 to S2t60
Mv/root/t60/root/s2t60

Which: Find the location of your Linux command file
For example, see where ls command file is
which LS

Find: Finding a file or directory
Parameters
-name: Search by file name, support wildcard characters?
-size: Search by file size, + number for file greater than XXK,-number is less than xxk file
-user: Search by file Owner
-type: Search by file type, F normal file, D directory, b device file (hard disk), C character device file (keyboard, mouse)
For example: Find any file with the file name "res" under/etc
Find/etc-name "Res
. "
Find all folders under the/root directory
Find/root-type D
Multiple conditional queries can be added as-a or-o,-a equivalent and relationship,-o equivalent or
Find all files that are larger than 1024k in the/root directory and begin with a file name of VM
Find/root-size +1024k-a-name "VM
. *"

Cat: Displaying and connecting the contents of a file
For example, view network card configuration
Cat/etc/sysconfig/network-scripts/ifcfg-eth0

MORE: Pagination View commands
Features like cat
More support for pipe breaks
For example
ls-lh/etc/*.conf | More

Head and tail View the beginning and end of a file
Parameters:
-N: View a few lines
For example, view the commands in the first four lines of the head-4/etc/passwd file.
-F: Use the end of dynamic trace file with tail
Tail-f/var/log/messages

WC: Statistics The amount of words in the contents of the file, the number of lines, and other information.
Parameters:
-C: The number of bytes in the file contents
-L: Number of rows in the statistics file
-W: Count the number of words in the content
Example: Query/etc/passwd number of rows wc-l/etc/passwd
Can be used in conjunction with other commands
For example, see how many. conf files are in/etc: Find/etc-name "*.conf" | Wc-l
If you do not enter parameters, they are automatically arranged in the order of-c-l-w.

Linux basic commands (partial)

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.