Linux Common Commands 1

Source: Internet
Author: User

Find
F (normal file) d (directory)
Finding: Find directory-type-f
Delete: Find directory-type-f-exec rm-f {} \;
Finding: Find directory-type-d
Delete: Find directory-type-d-exec rm-f {} \;
Cat Viewing files
Cat-n Add line number (read only, do not change)
Cat-s combine multiple empty rows into one (read-only, unchanged)
Cat >> test.txt<<eof
Content
EOF exit
TAC Line Reverse View
Wc-c viewing the number of file bytes
Wc-m viewing the number of file characters
Wc-l viewing the number of file lines
Wc-w View file Word count (spaces and line breaks)
Wc-l viewing the length of the longest line
Sort by first character from small to large
Sort-r Sort by first character from large to small
Sort-h Sort by numbers from small to large
Sort-f ignoring case
Sort-b ignoring the preceding whitespace
Sort-u the same data only appears in one row
Uniq ignore or report duplicate rows
Date display time (I is 12-hour h for 24-hour system)
Date + "%y%m%d%h%m%s"
20160824 223856
Date + "%y-%m-%d%h:%m:%s"
2016-08-24 22:39:07
Date + "%y-%m-%d%i:%m:%s"
2018-04-11 02:09:26
Date-s Modify Date or time
Date-s 20180411//So time will change to 00:00:00
Date-s 16:59:59//Set time does not change
Date-s "12:12:23 2006-10-10″//so you can set the whole time
After you reset the time, you need to synchronize to the hardware, such as the following command:
Hwclock-w
Cal Displays the current calendar
Cal-y Show one year calendar
Cal 2017 displays the 2017 calendar
Tzselect Setting the time zone
passwd Change Password
passwd username Modify the username password
Logout logoff
Reboot restart
Shutdown shut down the machine
Shutdown-r now//Immediate Restart
Shutdown-r +5//5 minutes after restart
Shutdown-r 12:12//12:12 Restart
Shutdown-h now//immediately shut down the machine
Shutdown-h +5//5 minutes after shutting down the machine
Shutdown-h 12:12//12:12 shutdown
shutdown-c//Canceling the shutdown operation
CD Switch Directory
CD back to current user home directory
Cd.. Switch to the previous level directory
CD-Switch to the previous catalog
PWD View current directory path
mkdir Creating a Directory
Mkdir-p a/b/c/d Creating a directory recursively
Man View Help
Man-k Fuzzy Lookup
Man-f Exact Search
Touch changes the time of the file or directory, and the file does not exist to create a new file
Touch-c do not create files
Touch-r test1 test2 test3 change test2 and test3 time to coincide with Test1 time
Touch-t 201804100922.08 Test1
RM Delete
Rm-f Force Delete
Rm-r Deleting a directory and its directories and files
RM-RF forcibly deleting directories and their directories and files
MV Move or re-command directory files
MV Test.log test.txt file renamed
MV Test1.txt girl/Moving files
MV Test1 test2 test3 girl/Moving multiple files
CP Replication
Cp-r recursively copy folders under all
Cp-i will prompt when you need to overwrite
Cp-p at this time, the CP will also copy the modification time and access rights to the new file in addition to the contents of the source file.
Stat View file related information
Stat filename
# Access Time (Atime): Refers to the timing of the use of the file, the so-called access, the common operation is: Use the editor to view the contents of the file, using the Cat command to display the contents of the file, using the CP command to copy the file (that is, the source file) to other files, or on this file using grep sed More less tail head and other commands, usually read without modifying the file's operation, equalization changes to the file's access time.
# Modify Time (Mtime): Refers to the change in the content of the file, as long as the contents of the file changes (such as the use of the switch to the output or the way to attach) or save the operation, it will change the Modify of the file, usually when we use Ls–l to view the file, Modify time is displayed.
# change Time (CTime): Refers to the timing of file attributes or file location changes, such as the use of the CHMOD,CHOWN,MV instruction set to use LN to do a file with a obstinately connected, it will be changed the file changes.
History view executed commands
History 5 last 5 commands
!number Execution History Command sequence number
!cat execute last Cat executed command
The Cut command extracts text columns from a text file or text stream.
-D: followed by delimited characters. Used with-F;
-F: Divides a piece of information into several paragraphs according to the delimiter character of-D, and uses-F to remove the meaning of the paragraph;
-C: Remove a fixed character range in units of characters (characters)
Tee reads the standard input data and outputs its contents to a file.
Cat Sec.log | Tee File1 # Read Sec.log and generate File1 file
Cat Sec.log | Tee-a File1 # reads Sec.log, and appends,
Cat Sec.log |tee file1 file2
More View file contents
Less View file contents
Head view top 10 lines of files
Head-n 5 File View files first 5 lines
Tail viewing the end of the file 10 lines
Tail-n 5 file to view the end of files 5 lines
Tail-f file Dynamic Monitoring files
Which finding additional command locations
LS Query
Ls-a All
Ls-l Details
Ls-r English alphabetical order
Ls-t Time Sorting
File type: the
-Normal file
D catalog File
B-Block device files
C-Character device files
I link file
P Pipeline File
Sspcket file
File permissions
rwxrwxr--: Three sets of rwx, respectively, represent the rights of the owner, all groups, other people.
R: is readable and can be represented by a digital 4来
W: Logo writable, can be expressed in numbers
X: Indicates an executable, which can be represented by a number
-: Indicates that no corresponding permission can be represented by a number of
Ways to Modify Permissions:
chmod o+w File1
chmod g-w File1
chmod go-w File1
chmod u=rwx File1
chmod 755 file1 #-rwxr-xr-x (755) Only the owner has read, write, execute permissions, groups and other people only read and Execute permissions
chmod 644 #-rw-r--r--(644) Only the owner has read and write permissions, and the group and other people have only Read permissions
which
# U on behalf of owner (user)
# G for the group where the owner resides
# O stands for others, but not u and g (Other)
# A for all people, including U,g and O
Permissions on the directory:
R: Indicates whether the file name under the directory can be read
W: Indicates whether the modified file can be created under the directory
X: Indicates whether the directory can be searched
Once you have X permissions, you can execute the file using the./a.py method.
Chown: Change the owner of a file and all groups
Chown root:root File
Chown Root File
Chown:root file

Linux Common Commands 1

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.