Linux introduction and simple application examples

Source: Internet
Author: User

1. Account

Windows Administrator Administrator

Linux Administrator root

2. Graphics mode and character mode switch

CTRL+ALT+FN (n=1~6) switch from graphic to character

ALT+FN switching from character to other mode

Alt+f7 back to graphical mode

3. Command prompt

# on behalf of administrators

$ on behalf of ordinary users

[Login user @ hostname working directory]#

The color meaning of files under Linux

Blue-to-catalog

Green--Executable file

Red--Zip file

Light blue--linked files

White--Other files

-Device files

1. Linux command format

command word [options] [parameter 1] [parameter 2]

[] indicates that content is optional

Option: If it is a single character, use-# ls-l

If it's a word, use --# ls--color

Multiple single-character options can be combined with one-# ls-l-h = # LS-LH

2. Tab key

Command completion

Path completion

Determine whether commands and paths are wrong

3. Shortcut keys

Ctrl + u: emptying to the beginning of the line

Ctrl + K: Empty to end of line

Ctrl + L: Empty entire screen = # clear

Ctrl + C: Discard the currently edited command line

4. Get Help commands

Type: View internal commands and external commands

Help internal command

External command--help

Man command

# makewhatis Build Database

# man-f = # whatis See what format Help is supported by this command after the specific

Numbers can help us understand or directly query the relevant information

1 instructions or executable files

5 file formats

8 instructions available to system administrators

II. Basic management of directories and documents

1. Basic commands

# pwd shows me where I am now (directory)

Path

Absolute path: path in/start

Relative path: Path not in/start

Special Directories:

. Current Directory

.. Previous level directory

.. /.. Previous level of the previous level of the catalog

- Previous working directory

~"Current user status" in the home directory

~ Account name The home directory of this account

CD: Switch directories

# cd ~root = # cd ~ = # CD

# CD.

# CD:

# CD: /..

# CD-

ls: View files and directories

-A View all files (including hidden files)

-L = ll long format display

-ld long format display directory

-LH display information in byte units (K, M, etc.)

- R recursive display of content

Wildcard characters:

*: matches any number of characters

?: Match a single character

[N-m]: matches one of several consecutive characters

{a,x,y}: matches multiple characters that are not contiguous

# alias View System aliases

# alias Byebye= "Shutdown-h Now" custom Alias

# unalias Byebye de-alias

2. View the file directory size

Du-sh

3. Creating Directories and files

mkdir: New Directory

- P recursive creation

RmDir: Delete Empty directory

- P Recursive Delete

Touch: Create file, update timestamp

ln

- s Create soft links

Syntax: ln-s source target (the source must be an absolute path) (the target cannot be a directory, only a file name that is not used)

4, copy/delete/move operation

CP: Copying Files or directories

-A =-PDR

- F Mandatory

- P property to copy the past together

- R copy Directory

RM: Remove files or directories

- F Mandatory

- R Recursive Delete

MV: Moving files and directories, or renaming

III. Procedures and Document retrieval

1, execute the command path variable path

echo $PATH View the value of PATH

Role:

Executing any command will go through the value (path) of the path to search for the command. If you do, no, I'll tell you you can't find this command.


2, command and file query

Which specifically for finding commands

Whereis can find both commands and man files

Locate Find Fast, need to generate database through UpdateDB


Find

Format: Find [path] [condition]

The default path is not specified, which is the current path

-type Type

F file

Catalog D

L Link

B -block device files

C -character device files


-name Name


-size Size (unit C means byte,k represents 1024bytes)

+ greater than

- less than

- A multiple conditions simultaneously satisfy

- o multiple conditions to satisfy a single bar


-mtime File Content Modification

n N is a number, meaning a file that has been changed in "One Day" before N days

+n lists filenames that have been changed before n days (excluding n days themselves)

-N lists filenames that have been changed within n days (including n days themselves)

eg

+4 represents a file name greater than or equal to 5 days ago Find/var-mtime +4

-4 for filenames less than or equal to 4 days find/var-mtime-4

4 is the name of the day that represents Find/var-mtime 4

-exec command

Eg:find/boot-size +2048k-exec ls-l {} \;

{}find what is found

-exec to \; represents find extra command start to end

; special characters that need to be escaped


First, the Command Line Foundation

1. See if the CD and mkdir are internal or external commands a: type cd type mkdir

2, use Help to view the CD's helpful information A: helping CD

3, use Help to view mkdir's helpful information A: mkdir

4, use man to view the help information for the passwd command a: Man 1 passwd

5, use man to view the passwd file's help information A: Man 5 passwd


II. Basic management of directories and documents

1, show what position now answer: PWD

2, enter/etc/sysconfig/network-scripts next answer: cd/etc/sysconfig/network-scripts

3, long format and provides easy-to-read properties displays the file at the beginning of the Vmlinuz under/boot answer: ls-lh/boot/vmlinux*

4, List/etc Directory properties A: ls-d/etc

5, recursive display of files and contents in the/boot directory A: ls-r/boot

6, show root all files include hidden files A: ls-a/root

7, go to/tmp directory, delete all files and directories, create File1.txt file2.txt file3.txt file13.txt filea.txt fileab.txt

Answer: cd/tmp rm-rf/tmp touch file1.txt file2.txt file3.txt file13.txt filea.txt fileab.txt

8, showing the file beginning with a. txt ending with 2 characters a: Find/-name "" File??. txt

9, showing the file beginning with a. txt end, in the middle is a single number of files A: Find/-name "File[0-9].txt"

10, showing the file beginning with a. txt end, the middle part may be 1 3 a AB files A: Find/-name "File{1,3,a,ab}.txt"

11, define alias alias, set Myls=ls-lha answer: Alias myls= "Ls-lha"

12. See how much space the/boot and/etc/pki occupy respectively a: Du-sh/boot Du-sh/etc/pki

13, create/vod/movie/cartoon, recursive display/VOD directory structure A: mkdir-p/vod/movie/cartoon ls-r/vod

14, Link System-config-network-tui to/sbin/netconfig answer: Ln-s/system-config-network-tui/sbin/netconfig

15, copy/boot/grub/etc/host.conf to/root/desktop, add tag at tail to list contents of Desktop directory (LS-F)

Answer: Cp/boot/grub/etc/host.conf/root/desktop ls-f/root/desktop

16. Remove grub and host.conf under Desktop answer: rm-f/desktop/grup rm-f/desktop/host.conf

17. Create a/root/ls-man.txt file to move this file to the desktop a: Touch/root/ls-man.txt cp/root/ls-man.txt/root/desktop

18, renamed Ls-man.txt to manls.txt A: MV Ls-man.txt manls.txt


III. Procedures and Document retrieval

1,path function, view the value of PATH a: Echo $PATH

2, find shutdown absolute path to this command answer: which shutdown

3, search by Whereis rm A: Whereis RM

4, create the myhttpd.conf file, use locate to find, is it possible to find this file? A: Touch myhttp.conf locate myhttp.conf not found, the database is not updated

5, update the database/var/lib/mlocate/mlocate.db, use locate find, is it possible to find this file? Answer: Can find

6, delete the myhttpd.conf file, use locate find, is it possible to find this file? Answer: Can find, not update database

7. Find the link file under/boot a: Find/boot-type l

8. Find the directory under/boot a: Find/boot-type D

9, look for/etc under the name of Resol beginning, with. conf end of the file a: Grep-e "^resol|. conf$ "/etc

10, look for the character device file under/dev, and the name Tty1 tty2 tty3 A: Find/dev-name "tty[1-3]"

11. The file with the. img ending in the/boot is displayed in an easy-to-read property and in a long format answer: Find/boot-name ". img$" |ls-lh

12. Look for files with the. img ending in/boot and greater than 2M a: Find/boot-name ". img$"-a-size +2m

13. Find files that have changed within 24 hours of the system answer: Find/-mtime-1

14. Find filenames that are greater than or equal to 5 days before/var answer: Find/var-mtime +4

15, find the file name that is less than or equal to 4 days in/var a: find/var-mtime-4

16. Find the changed file name of 4–5 Day under/var. A: Find/var-mtime 4

17. Find files larger than 3M in/boot and display them in a long format answer: find/boot-size +3m |LS-LH


Related Article

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.