Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

5. Common command operations of Linux

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Date +% / Y:%m:%d

Date +% / Y--%m--%d

Date-u

Hwclock displays hardware clock time

Cal View Calendar

Uptime is used to view the uptime of the system

Man uptime View help documentation

Q is used to exit the man command

View hardware information

Lspci-vPCI equipment

Lsusb-vUSB equipment

Lsmod to view loaded modules (drivers)

Ls

-an all files

-l display details

-R is displayed recursively

-ld displays directory and link information yum

Cp,mv,rm,scp

Pwd to view current directory information

[admin@localhost Desktop] $pwd

/ home/admin/Desktop

Copy files, directories

Cp

Cp file1 file2

Cp. / path / file1. / path / file2

-r copy folder (copy the entire directory tree recursively)

-v display details

Move, rename files and directories

Mv

Create and delete files

Time when touch created or updated the file

Rm deletes a file

Rm-r deletes folder and file contents (recursively)

Rm-I interactive deletion

Rm-f forced deletion

Scp

SCP function: can copy files between 2 linux hosts

Basic format of the command:

Scp [optional parameters] file_source file_target

Scp local user name @ IP address: file name 1 remote user name @ IP address: file name 2

Vi,vim

Both vi and vim are multi-mode editors (graphical interface is added to vi)

Vim + destination file path

: set nu displays the line number

: set nu! Cancel the line number

Introduction to commands in command line mode

I: start inserting before the character where the cursor is located

A: start inserting after the character where the cursor is located

O: insert a new line below the line where the cursor is located

S: delete the character where the cursor is located and start inserting

I: insert at the beginning of the line where the cursor is located. If there is a space at the beginning of the line, insert after the space.

A: start inserting at the end of your line where the cursor is located

O: start inserting with another line above the line where the cursor is located

S: delete the line of the cursor and start inserting

In addition, u undo the operation of the previous step Ctrl+r reverses the operation that was undone in the previous step

In EX mode

W save the current changes

Q exit

: q! Force exit without saving changes

: X save and exit, which is equivalent to: wq

: set number displays the line number

:! System command executes a system command and displays the result

Sh switch to the command line, use ctrl+d to switch back to vim

Find

Command format: find path-command parameter [output form]

-ctime n to find the files in the system whose state was changed in the last 24 hours

-atime n to find the files accessed by the last 24 hours in the system

-mtime n to find the files in the system that were changed in the last 24 hours.

. -name * linuxtest*

/-name * .conf

/-perm 777

/-type d

B-block device file.

D-directory.

C-character device file.

P-pipe file.

L-symbolic link file.

F-ordinary file.

. -name "a *" exec ls-l (here commands are variable, others are in fixed format)

-user looks for files according to their owners.

-group looks for files by the group to which they belong.

Find files that have been modified within a specified time

Find-atime-2

Look up according to keywords

Find. -name "* .log"

Find a file according to the permissions of a directory or file

Find / opt/soft/test/-perm 777

Find by type

Find. -type f-name "* .log"

Find all current directories and sort

Find. -type d | sort

Find files by size

Find. -size + 1000c-print

Grep,cat,less,more,tail,head

Cat displays the contents of the file

Head-n displays the first few lines of the file

Tail-n displays the last few lines

-f tracking shows file updates (usually used to view logs, commands will not exit,)

More turns the page down

Less turns the page up

Grep finds the contents of a file: it can be specific to a line that looks for some information

For example: in the file day, look for the line that contains un

Grep un day # un is the keyword, and day is the file found.

Mount,df,du,cron

The mount command is used to load the file system to the specified mount point. The most common use of this command is to mount cdrom so that we can access the data in cdrom

-V: displays the version of the program

-l: displays a list of loaded file systems

-h: display help information and exit

-v: verbose mode, outputting the details of instruction execution

-n: loads a file system that is not written to the file "/ etc/mtab"

-r: load the file system in read-only mode

-a: loads all file systems described in the file "/ etc/fstab".

The dfdf command displays the available disk space on the disk partition. The default display unit is KB. You can use this command to get information such as how much space the hard disk is occupied and how much space is left.

-an or-- all: contains all file systems

-- block-size=: displays the number of blocks at the specified block size

-h or-- human-readable: displays information in a highly readable manner

-H or-- si: same as the-h parameter, but calculated in 1000 Bytes instead of 1024 Bytes

-I or-- inodes: displays information about inode

-k or-- kilobytes: specify a chunk size of 1024 bytes

-l or-- local: show only local-side file systems

-m or-- megabytes: specify a chunk size of 1048576 bytes

-- no-sync: do not execute the sync instruction before getting the disk usage information. This is the default value.

-P or-- portability: use the output format of POSIX

-- sync: execute the sync instruction before getting disk usage information

-t or-- type=: displays only disk information of the specified file system type

-T or-- print-type: displays the type of file system

-x or-- exclude-type=: do not display disk information of the specified file system type

-- help: show help

-- version: displays version information.

The dudu command also looks at the usage space, but unlike the df command, whether the Linux du command looks at the space used by the file and directory disk, or whether it is different from the df command.

-an or-all displays the size of individual files in the directory.

-b or-bytes displays the directory or file size in byte.

-c or-- total displays not only the size of individual directories or files, but also the sum of all directories or files.

-k or-- kilobytes output in KB (1024bytes).

-m or-- megabytes output in MB. -s or-- summarize displays only the total and lists only the last plus value.

-h or-- human-readable is in the unit of KMagazine GetWord ("G"); to improve the readability of information.

-x or-- one-file-xystem is based on the file system at the beginning of the processing, and will be skipped in case of other different file system directories.

The source file size of the symbolic link specified in-L or-- dereference display options.

When-S or-- separate-dirs displays the size of an individual directory, it does not include the size of its subdirectories.

-X or-- exclude-from= is in the specified directory or file. -- exclude= skips the specified directory or file.

-D or-- dereference-args displays the source file size of the specified symbolic link.

The parameters of-H or-- si are the same as-h, but the conversion unit of K _ ~ ~ M ~ G is 1000.

-l or-- count-links repeatedly calculates hardware-linked files.

Cron

Gzip,zip,unzip,tar

Compression: gzip FileName

Decompress 1:gunzip FileName.gz

Decompress 2:gzip-d FileName.gz

Compress

Zip linuxtest.zip myfile

Unzip linuxtest.zip

Gzip linuxtest.net

Archiving (packing)

The-z parameter compresses the archived archive file with gzip to reduce the size (call the gzip command)

[root@linux ~] # tar-cvf / tmp/etc.tar / etc

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report