2017.10.7 Linux Basic commands

Source: Internet
Author: User
Tags parent directory time and date

  1. Date Time command:

    Date

    Function: Displays or sets the time date.

    Show time or Date:

    Date [option] ... [+format] Displays the time and date in the specified format.

    Option: Options

    Format: Formatting symbols.

    Example:

    [Email protected]:~$ Date +%d
    10/07/17 Month/day/year
    [Email protected]:~$ Date +%f
    2017-10-07 year-month-day
    [Email protected]:~$ Date +%t
    09:01:37 hours: minutes: seconds
    Set the time or date:

    Date [MMDDHHMM[[CC]YY][.SS]]

    MM: DD: The number of HH: hours mm: minutes YY: Two-bit year CCYY: four-bit year. SS: Seconds

    Example:

    [Email protected]:~$ sudo date 123009182017.40//sudo is executed as Administrator
    [sudo] XXL password://need to enter a password
    Saturday, December 30, 2017 09:18:40 CST

    Two types of clocks for Linux:

System clock: The timing of the CPU's operating frequency by the Linux kernel.

Hardware clock

hwclock: Display hardware clock

-S,--hctosys

-W--SYSTOHC

cal: Calendar

Cal: Displays the calendar for the current month.

Cal Year: Displays the calendar for the current year.

2. Directory-related commands

Current directory or working directory

Home directory: Home

Root:/root

Normal User:/home/username:/HOME/XXL

~: User's home directory

For example:

[Email protected]:~$ whoami
xxl
[Email protected]:~$ CD ~
[Email protected]:~$ pwd
/home/xxl

CD: Switch directories

CD or CD ~: Back to the current user's home directory

CD ~username: Switch to the home directory where the user is being developed

CD-: Switch back and forth between the previous directory and the current directory

. Represents the current directory

.. Represents the parent directory of the current directory


ls : list displays the file listing under the specified path.

list [option] ... [DIR] ...

-A,--All: Displays all files, including hidden files;

-L: Long format

Example: Drwxr-xr-x 3 root root 4096 October 4 20:16 opt
Drwxr-xr-x:

Leftmost first bit: file type-, D, L, B, C, p, s

9 bits in the back: access rights

Number: The number of times a file has been hard-linked.

Left Root: Owner of File

Right root: Group of files

4096: Size of File

October 4 20:16 The time the file was last modified

Opt: file name or directory name.

-H, Unit conversion

-D, which displays the relevant properties of the directory itself, usually used with-l;

-R, Reverse display

-R, Recursive


Sata/path/to/somefile: Gets the metadata for the specified file


3. File View command cat TAC

Cat [option] ... [File] ...

-E: Display line terminator $

-N: Numbering each line displayed

4. Document Content View command: file

File/path/to/somefile

5. Echoing command: echo

-N: Prevent automatic line break addition

-e: Allow escape character (\ n: newline \ t: tab)

echo "$VAR _name": variable is replaced, double quotation mark table weak reference.

Echo ' $VAR _name ': The variable is not replaced by a strong reference.


which: Displays the file path for the command

which [option] COMMAND

--skip-alias: Disable alias display


Whatis : Create a database of all help manuals and corresponding keywords on the current system.

This article is from the "Technical Achievement Dream" blog, please be sure to keep this source http://xuxiaoliang.blog.51cto.com/10882951/1970581

2017.10.7 Linux Basic 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.