Linux common commands (echo, date, LS, CD, history, CAT)

Source: Internet
Author: User
Tags echo command

I. Linux common commands There are a lot of today we'll summarize the common entry commands:

1.linux Shimonoseki command: Poweroff, init 0, Halt, Shutdown-h now

2.linux Restart command: Reboot, init 6, Shutdown-r now

3.shutdown command:

Format: Shutdown options time

Among the options are the following:

-R: Performing a restart

-C: Cancel Shutdown command

-H: Perform shutdown

There are several of the following:

Now: That means

+m: Relative time notation, from how long after the command is submitted: for example: +3

HH:MM: Specifies the absolute time, indicating the specific time.

Example:

Shutdown-h now #现在关机

Shutdown-r now #表示现在重启

4.ls command: Displays a list of files under the specified path

Format: ls [OPTION] ... [FILE] ...

Parameters:

LS: Displays a list of files under the specified path.

Ls-a|--all: Shows all files including hidden files.

Ls-a: Displays additional files that do not include hidden files.

Ls-l: Displaying a list of files in a long format

Ls-h: Displaying file sizes in a human-readable way

Ls-d: Displays the directory's own related properties, usually with-l

Ls-r--reverse: Using reverse display

Ls-r: Recursive display

Ls-t: Sort by modified time, latest time in front

5.CD Toggle Command:

Format: CD [-l|-p] [dir]

Common commands:

CD ~: Back to the user home directory

CD ~username: Back to the specified user home directory

CD-: Go back to the user's last directory

CD: Back to User home directory

CD.: Switch to the current directory

Cd.. : Switch to the top level directory of the current directory

6. File View command: Cat,tac,file

Cat: View file contents in sequence, TAC view file contents in reverse order, File View content format

7.echo command: Print, echo command

Format: Echo [short-option] ... [STRING] ...

Echo long-option

Parameter:-N: Prevent automatic line break addition

-e: Allow escape characters to be used

\ n: Line break

\ t: Tab

"": Indicates a weak reference

': Indicates a strong reference

8.date Command: Date view command

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

Where format format refers to formatting symbols

Parameters:

%A: Displays the current time full day of the week

%a: Displays the current time abbreviation day of the Week

%d: Display the current time month Date:/month/day/year format

%F: Show Current time month Day: format is Year-month-day

%T: Displays the current time, seconds and minutes: format hour:minetus:seconds

%y-%m-%d-%h:%m:%s: Show Current time

Example:

[Email protected] test]# date +%a

Wednesday

[Email protected] test]# date +%a

Wed

[Email protected] test]# date +%d

09/13/17

[Email protected] test]# date +%f

2017-09-13

[Email protected] test]# date +%t

08:00:52

[Email protected] test]# date +%y-%m-%d-%h:%m:%s

2017-09-13-08:01:15



Settling time format: Date [-u|--utc|--universal] [MMDDHHMM[[CC]YY][.SS]]

MM: Month

DD: Day

hh: Hours

MM: Minutes

YY: Year abbreviation

CCYY: Full year name

. SS: Sec

Date-s "Year-mouth-day hour:minites:seconds"

Example:

Method One:

[Email protected] test]# date 091916452017.59

Tue Sep 16:45:59 CST 2017

Method Two:

[[email protected] test]# date-s "2017-09-19 16:46:40"

Tue Sep 16:46:40 CST 2017

9.linux system Clock:

There are two types of clocks in a Linux system:

System clock: The timing of the CPU operating frequency by the Liunx core.

Hardware clock: The timing of the hardware's own transistor vibration frequency.

View hardware clock: Clock, hwclock command.

Clock synchronization command:

Hwclock:

Parameters:

-S,--hctosys: Establish system clock synchronization hardware clock

-W,--SYSTOHC: Establish hardware clock synchronization system clock

10. Calendar View Commands:

Cal: Represents a calendar command

Cal 2017

11. View Historical Command method: History: Log in to the system will read the historical command file/root/.bash_history; the command executed after logging into the shell exists in the cache, and the cache command is saved to the history command file after exiting the system.

Parameters:

-A manually append this session's command to the history command file

-d Deletes the command specified in the command history (specifies the number of methods for the history command)

-C Empty History command

Shortcut action for command:!n: Invoke the nth command in history

!! Invokes the previous execution command.

!string calls the last string-compliant command in the history, in reverse order.

Hash-r/-d the hash cache used by the empty command

Example: [[email protected] test]# hash

Hitscommand

4/bin/cat

2/bin/ls

[Email protected] test]# Hash-r

[[email protected] test]# hash

Hash:hash Table Empty


12. Common Find command:

Which: Displays the path of the program file corresponding to the command

Format: which [option] command

Parameter:--skip-alias: Disable alias display

Whereis is the same as the which command

echo $PATH: The path that the shell program searches for executable files is defined in the PATH variable. Look for the order from left to right. Cache the results of the search in the store (K-V)

Whatis: View the help documentation for the specified command

Whatis COMMAND

Use the Mkwhatis command to create a database of all help manuals and corresponding keywords for the current system.

13. Check the system login user status:

Who: Displays all sessions of the current system

W: Displays all sessions and actions of the current system

WHOAMI: Show active users currently logged in

[email protected] test]# who

Root pts/0 2017-09-13 07:36 (192.168.80.1)

Root tty1 2017-09-12 10:47 (: 0)

[email protected] test]# who

Root pts/0 2017-09-13 07:36 (192.168.80.1)

Root PTS/1 2017-09-19 17:16 (192.168.80.1)

Root tty1 2017-09-12 10:47 (: 0)

[Email protected] test]# W

17:16:21 up 1 day, 8:04, 3 users, Load average:0.00, 0.00, 0.00

USER TTY from [email protected] IDLE jcpu PCPU

Root pts/0 192.168.80.1 13sep17 0.00s 0.10s 0.00s W

Root pts/1 192.168.80.1 17:16 11.00s 0.01s 0.01s-bash

Root tty1:0 12sep17 7days 2:03 2:03/usr/bin/xorg:0-nr-verbose-audit 4-auth/var/run/gdm/auth-for-gdm-ptcg9t/database-nolis Ten TCP VT1

[Email protected] test]# WhoAmI

Root

This article is from the "11701241" blog, please be sure to keep this source http://11711241.blog.51cto.com/11701241/1966904

Linux common commands (echo, date, LS, CD, history, CAT)

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.