Common basic commands for Linux

Source: Internet
Author: User
Tags touch command

1.touch: Modify the timestamp of the file

Format: Touch [options] ... FILE ...

Common options:

-C,--no-create: Do not create any files;

-A: Only modify the access timestamp of the file;

-M: Only modify the file's modified timestamp;

-T STAMP: Replace the timestamp of the file with the specified STAMP;

The format of the stamp is: [[CC]YY]MMDDHHMM[.SS]


Additionally, if the-C option is not specified, the touch command can create a file that is specified as a parameter and does not exist;


2.stat: Displays the status of the file or file system;

Format: stat [options] ... FILE ...

Common options:

-C,--format=format: Displays the specified state property of the file in the specified format;


3.nano: Full screen Editing tool in text mode;

Format: Nano [OPTIONS] [[[+line,column] FILE] ...

^: caret, indicating the CTRL key on the keyboard;

^+o: Save the contents of the document;

^+x: Exit the editing interface;


4.cat: Connect files and display in standard output

Format: Cat [OPTION] ... [FILE] ...

Common options:

-B,--number-nonblank: Number output for non-blank lines;

-N,--number: number output for all lines;

-S,--squeeze-blank: merge contiguous blank lines;

-E,--show-ends: Displayed at the end of the line in $ characters;


Tac-concatenate and print files in reverse

Format: TAC [OPTION] ... [FILE] ...


Note: The cat or TAC command, if no parameters are given, all of the content needs to be done through standard input (typed from the keyboard), and can then be exited with "^+c" or "^+d";


5.head: The starting part of the output file;

Format: Head [OPTION] ... [FILE] ...

Common options:

-C,--bytes=[-]k: Displays the content of the corresponding length in bytes;

-N,--lines=[-]k: Displays the content of the corresponding length in the behavior unit;

can be used-#K方式替换-n #K;


Note: If you do not use any of the options, the first 10 lines of the specified file contents are displayed by default, and if there are less than 10 lines in the file, all content is displayed;


6.tail: The final part of the output file;

Format: tail [OPTION] ... [FILE] ...

Common options:

-C,--bytes=[-]k: Displays the content of the corresponding length in bytes;

-N,--lines=[-]k: Displays the content of the corresponding length in the behavior unit;

can be used-#K方式替换-n #K;

-F,--follow[={name|descriptor}]: Monitor changes at the end of the file;


7.more: Pagination display of document content, filtering;

Format: More [options] file [...]

Interactive editing methods:

You can use "/" to search for filters based on subsequent string combinations;

You can use "n" to find the next match;

Use "Q" to exit more mode;

Using Enter, you can turn down one line;

Using space, you can turn down one page;


8.less:less-opposite of more

Format: less [options] file [...]

Interactive editing methods:

You can use the "/" or "?" Search filtering based on subsequent string combinations;

The next occurrence can be found using "n" or "n";

Use "Q" to exit more mode;

Using Enter, you can turn down one line;

Using space, you can turn down one page;



Date and time-related commands:

9.date: Operating system time, referred to as system time, clock recording time using software mode;

Format: Date [OPTION] ... [+format]

Date [-u|--utc|--universal] [MMDDHHMM[[CC]YY][.SS]]

Common options:

-S,--set=string: Sets the system time to the specified time;

Two types of formats:

1) MMDDHHMM[[CC]YY][.SS]

2) "Ccyy-mm-dd HH:mm:ss" or "Ccyy/mm/dd HH:mm:ss"

FORMAT:

%F: Represents the full date format, i.e.: YY-MM-DD

%T: Indicates the complete time-division-seconds format, and: HH:MM:SS

%Y: Represents the full year

%m: Indicates the month

%d: Represents the date

%H: Indicates hours

%M: Indicates minutes

%s: Indicates seconds

%s: Time stamp, from 1970-01-01 00:00:00 to the current system time the number of seconds experienced;

Note: January 1, 1970 as the Unix of the same;

This timestamp is represented by a 32-bit binary, so the maximum range of its representation is 0~4294967295;


10.clock/hwclock:hwclock-query or set the hardware clock (RTC)

Format: hwclock [function] [option ...]

Common options:

-S,--hctosys: Set the system time according to the hardware clock;

-W,--SYSTOHC: Sets the hardware clock according to the system time; (not recommended)


11.cal:

With shutdown, restart, logoff related commands:

Shutdown: Halt, Poweroff, shutdown-h time, init 0;

Restart: reboot, Shutdown-r time, init 6;

Logout: Exit, logout, ^+d;


12.cp:cp-copy Files and directories

Format: CP [OPTION] ... [-T] SOURCE DEST: Single source copy

CP [OPTION] ... SOURCE ... DIRECTORY: Multi-source replication

Attention:

1) The CP command must be connected to at least two parameters;

2) The last parameter, usually the target of this copy;

3) If the target given at the time of copying is the directory, copy the file directly to the specified directory, retain the original file name, and copy and rename the file if the target is not a directory when copying the non-directory file;

Common options:

-R,-R,--recursive: recursively copy directory files;

-d Same as--no-dereference--preserve=links

When the copied source file is a symbolic link file, the-D option preserves the symbolic link file as the source file is copied, and does not copy the file that the symbolic link file points to;

-p Same as--preserve=mode,ownership,timestamps

The permission bits, ownership, and timestamp attributes in the copied source file are preserved;

-A, --archive same AS-DR--preserve=all

Equivalent to a combination of-DPR;

-F,--force: If the target file already exists, then force the copy and do not prompt; To make this option effective, the CP command needs to be preceded by "\", i.e.: # \CP source_file destination_file


13.mv:mv-move (rename) files

Format: MV [OPTION] ... [-T] SOURCE DEST: Single source Mobile

MV [OPTION] ... SOURCE ... DIRECTORY: Multi-source mobile

Common options:

-F,--force: Move the file and force overwrite the file with the same name in the target location;

-N,--no-clobber: When moving a file, the source file does not move if it has the same name as the file in the target location;


This article from "13366421" blog, declined reprint!

Common basic commands for Linux

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.