Linux Common Commands

  

In order to use Linux systems efficiently, it is essential to use Linux commands. There are many common Linux commands that must be mastered.

One, date and time 1, date View and set the date and time of the system

2,-u, to view UTC time (Greenwich Mean Time)

3 ,date +%y--%m--%d where “–” can customize the change, this is the display format of the change time

4,date -s set the time, this needs to be cut The root user can have permission to change

5, date is the time of the operating system
, he is from the hardware time, you can directly use clock (hclcok) to view

6,cal to print the calendar

7, uptime, to see how long the system has been running, the user of the system, the load of the system

Note: You can use man uptime to view the pair Uptime explanation

Second, output, view command

1, echo: display the input content, you will lose the output 给

2,cat: Display the contents of the file, it directly displays all the contents of the file, very unhumanized, trouble

3, in order to facilitate viewing, to avoid the inconvenience of cat, you can use the following commands

4,more: used to flip the page to display content, but not down Page

5,less: You can page up and down relative to more

6,head: display the first few lines of the file (default 10 lines)

-n: To specify the beginning of the n lines

7,tail: display the last few lines (default 10 lines)

-n: to specify the end of the display n lines

- f: Tracking the update of the display file. When we use the -f command, the command line will be stuck here, waiting for the file to be updated and then displaying the new content. Generally used to view logs, continuously display newly added content

3, view hardware information

1, lspci is used to view PCI devices (such as sound card network card, etc.)

- vView Details

These commands are quite the same as the Windows
midpoint property point device manager

2,lsusb View USB devices, such as cameras, etc.

-v is also displaying detailed information

3, lsmod View all modules currently loaded (module is equivalent to driver in windows)

Four, shutdown and restart

format :shutdown[Shutdown/Restart]Time

Shutdown immediately: shutdown -h now=poweroff

Restart now: shutdown -r now=reboot

N minutes after shutdown: shutdown -h +n

Timed shutdown: shutdown -h xx:xx

5, archive and compression

1,zip for compression:zip xxx.zip file The file source file is compressed into xxx.zip is the target file)

2, unzip xxx.zip is the decompressed file

3, gzip: is also a compression method

4 , tar: an archive command, which is to package many files into a file

-cvf out.tar liunxfile : put L The files in this folder of inuxfile are packaged and archived into a file with output out.tar format, which can be used for backup, but it is not compressed.

-cvf out.tar Release an archived tar file to the current file. Next

-cvzf: There is an additional z command under the cvf command, which is to archive and compress a file. Here is a gzip command called

format: tar -cvzf xxx.tar.gz/under the directory to be saved

The most useful one is the archive and compression command

Unzip: tar -zxvf FileName.tar.gz

Compress: tar -zcvf FileName.tar.gz DirName

Six, find commands (find files, folders)

Looking for a file in our operating system

1, the lactate keyword is a quick search

It needs to create a database in advance, for example, if you create a new file, then use locate to find the command. Not found (the database is updated once a day). At this time you can use the “updatedb” command to update the database first, and then look it up.

2, find supports a lot of search conditions, so called advanced lookup

format: find find location search parameters

find .-name*linuxcast* “.” In the current folder * represents 0 or more characters -name means to find the file, the name of the folder

xxx indicates the keyword. This sentence means that all keywords in the current folder contain the "Linuxcast" keyword. File

find /-name *.conf Find all files ending in .conf under the /root partition

find /-perm 777 Find all files with permissions on the hard disk is 777

find /-type d Find the directory type file. d means directory, you can also follow l to find all connections

find can also use the results of the search to execute some commands. Find .-name "a *" -exec ls -l {} \\;

This sentence means to find all files starting with "ld" and send them to “ls -l” Go to execute and display the details.

where {} \\; is a fixed format.

-exec is also a fixed format, the meaning of execution;

find has a lot of suffix parameters, you can directly find it in the network or help file

Copyright © Windows knowledge All Rights Reserved