编程知识 cdmana.com

Basic commands of Linux

1、cd

Full name :cange directory

effect : Toggle directory

Format :cd Target directory

Example :# cd /etc

Switch to the parent directory :# cd ..

2、pwd

Full name :print working directory

effect : Display the current working directory

Example :# pwd

3、ls

Full name :list

effect : Display the files in the specified directory

Format :ls [ Options ] [ Catalog ]

Options :

-a: Show all files 【 Usually used to show hidden files 】

-l: Show file properties

-h: Display the size of the file in an easy to read way

-d: Just show the directory itself

Example :# ls /root

4、mkdir

Full name :make directory

effect : Create directory

Format :mkdir [ Options ] Catalog

Options :

-p: You can create the parent directory first , Create subdirectories again

-v: Displays the support process information for the command

Example :

Current directory :# mkdir a1

stay home Create :# mkdir /home/a1

5、touch

effect : Modify the time of the file or create an empty file

Format :touch file name

Example :

Create in current directory :# touch a1

stay home Create :# touch /home/a1

6、rm

Full name :remove

effect : Delete file

Format :rm [ Options ] file / Catalog

Options :

-r: Recursive delete , First delete the files in the directory, and then delete the directory itself

-f: Mandatory deletion

Example :

Delete home Under the a1:# rm -rf /home/a1

Deleting the suffix is txt The file of :# rm -rf /home/*.txt

7、cp

Full name :copy file

effect : Copy files or directories

Format :cp [ Options ] Source The goal is

Options :

-a: Keep the properties of the file unchanged when copying

-r: recursive 【 You must use this option when copying directories 】

-v: The information replication process shows

-f: When copying, if there is a file with the same name under the target location , Force coverage

-i: When copying, if there is a file with the same name under the target location , Ask if you want to overwrite

8、mv

Full name :move file

effect : Moving files

Format mv Source The goal is

9、cat

Full name :concatenate

effect : Link and display the contents of the file 【 Only for viewing files with less content 】

Options :

-n: According to the line Numbers

10、more

effect : Be similar to cat, But it will be displayed page by page , More convenient for users to read page by page , And the most basic instruction is to press space (space) The next page shows , Press b The key will go back one page , It also has the function of searching for strings ( And vi be similar ), Documentation in use , Please press h

11、less

effect : Split screen display of the contents of large files , And moer similar , But use less You can browse files at will , and more Move forward only , But can't move back , and less The entire file will not be loaded until it is viewed

operation :

enter : Show the next line

Space : Flip down one screen

b: Turn up one screen

q: sign out

ctrl+c: sign out

/ character string : Search for the specified string

     N: Search forward

     n: Continue searching backward

12、head

effect : Show the first few lines in the file

Format :

head -n# file (n# Change to the number of lines you want to display )

Before default display 10 That's ok

 

13、tail

effect : Show several lines at the end of the file

Options :

-f: Real time monitoring of file content changes

Format :

tail -n# file

Default display last 10 That's ok

14、grep

  effect : Filter the contents of the file

    Execute the filter tool

    Filter out the lines containing the specified string

Format :grep [ Options ] “ The goal is ” file

Options :

-v: Take the opposite

--color: Color matching results

-o: Just show matching results

-c: Count how many lines meet the criteria

Example :

Filter out a1 It contains strings ike The line of :# grep “ike” a1

Filter out a1 There is no string in it ike The line of :# grep -v “ike” a1

15、mount

effect : External devices will , Mount to linux Under a certain directory of

Format :

mount [ Options ] Device file Mount point

Compact disc / The device file corresponding to the CD :/dev/cdrom、/dev/sr0

Example :

Mount the CD /mnt:# mount /dev/cdrom/mnt

Add :

Short options :- Letter , Short options can be combined

Long options :-- word

版权声明
本文为[Sword killing]所创,转载请带上原文链接,感谢
https://cdmana.com/2020/12/20201224214721823u.html

Scroll to Top