[Linux] Basic commands and directory structure in Linux (first draft)

Source: Internet
Author: User
Tags diff echo command readable touch command

Basic commands and directory structure directories in Linux
    • First, the Linux basic directory structure
    • II. basic Commands
    • Third, browse the directory
    • Iv. Intermediate Command
    • Five, change the password
    • VI. environment variables and shell variables
    • Vii. Command Path
    • Eight, text editor
    • Ix. Get online Help
    • X. Shell input and output
    • Xi. Process of operation
    • 12. Change file permissions
    • 13. Archive and Compress

First, the Linux basic directory structure

II. basic Commands

1.shell command line interface, one of the most important parts of Unix.
2.shell is the application that runs the command line, which is a command that the user enters.
The 3.shell script, also an important part of Unix, resembles the. bat batch file in MS-DOS.

2.1 Shell window prompt: [email protected]:p ath$ (user name @ hostname: PATH $)

Input/output (I/O). The process reads data from the input stream and writes out data to the output stream. The input stream can be a file, device, terminal, or even an output stream from another process.

2.2 ls Command: Displays the contents of the specified directory, the default parameter is the current directory.

Parameter-l Displays a detailed list,-f displays file type information.

$ ls-l

2.3 CP command: Copying files
$ CP [FILE1] [file2]

"Comment" copies file1 to File2

$ CP [File1] ... [Filen] [Dir1]

"Note" Copies multiple files to the specified directory

2.4 mv Command: Renaming files
$ MV [file1] [file2]

"Comment" renames the file name from File1 to File2

$ MV [File1] ... [Filen] [Dir1]

Notes moves multiple files to the specified directory

2.5 Touch Command: Create a file

If the file already exists, the command updates the timestamp of the file.

$ touch [File1]

2.6 rm Command: Delete files
$ RM [File1]

2.7 echo Command: Display parameters to standard output
$ echo Hello again.

Third, browse the directory

1.UNIX directory structure from/start, also known as the root directory, directory with/separate, not Win in the \.
2. Take/start the path with a WOW to the path, such as:/user/lib.
3. ". (two points) "represents the upper level directory of a directory, such as: The current directory is/user/lib, that ... On behalf of the/USER directory,. The/bin represents/user/bin.
4. Do not start with/To call the relative path.

3.1 CD: Set the current working directory
$ CD [Dir1]

3.2 mkdir command: Create a new directory
$ mkdir [Dir1]

3.3 rmdir command: Delete directory
$ rmdir [Dir1]

3.4 Shell wildcard: Match file name and directory name
$ echo *

Notes lists all the files in the current directory.

  

Wildcard characters:

(1) * represents any character and number;

(2)? Match one character;

(3) "Do not expand wildcard characters, such as: ' * ' will display a *;

(4) ...

Iv. Intermediate Command 4.1 grep command: Displays the lines in the file and input stream that match the parameters
$ grep root/etc/passwd

All lines in the notes file/etc/passwd that contain the text root

$ grep root/etc/*

"Comments" to see all files containing root in directory/etc


Options:-I (case insensitive),-V (reverse match, show all unmatched rows)

4.2 Less command: Split screen display
Less/usr/share/dict/words

4.3 pwd command: Output only the current working directory name

4.4 diff command: View the differences between two files
$ diff [File1] [file2]

4.5 File Command: View the format information for a document
$ file [File1]

4.6 Find and Locate commands: Finding files
$ find [Dir1]-name [file1]-print

Locate command: Finds files from the index.

4.7 Head and Tail command: Display the contents of a file

Head command: Displays the first 10 lines of the file;

Tail Command: Displays the contents of the following 10 lines of the file

head/etc/passwdtail/etc/passwd

4.8 Sort command: Quick sorting in alphabetical order

Option-n Sort by number,-R reverse Sort

Five, change the password

passwd Command: Change password

VI. environment variables and shell variables

Shell variables: Temporary variables saved in the shell
=: Assign Value

$ STUFF = blah

Promote to environment variable:

$ Export STUFF

Vii. Command Path

PATH a special environment variable:

$ echo $PATH

Eight, text editor

VI, EMACS

Ix. Get online Help

If you want to understand the use of the LS command:

$ man ls

  

X. Shell input and output

redirect character;:

$ command > [file1]

"Comment" outputs the execution result to a file. If the file does not exist, it will be created and will empty the original content.

$ command >> [file1]

Note If you do not want to overwrite the original file, you can use >> to output the result to the end.

Xi. Process of operation

Terminate a process

$ kill PID

  

 Pausing a process

$ kill-stop PID

Continue to execute Process

$ kill-cont PID

12. Change file Permissions 12.1 chmod command: Change file permissions

For user groups G and O with readable permissions R:

$ chmod g+R [file1]$ chmod o+r [file1]

To simplify, use one line of commands:

$ chmod go+r [file1]

Remove permissions: Go-r.

Four characters corresponding permission information: R: Readable; w: writable; x: executable;-: none.

13. Archive and Compress
13.1 gzip Command: Compress individual files

13.2 tar command: Compress and archive multiple files and directories
$ tar cvf archive.tar [file1] [file2] ...

Extract:

$ tar xvf Archive.tar



"Bo Master" anti-bone Aberdeen

"Original" http://www.cnblogs.com/liqingwen/p/6804028.html

"GitHub" XMind download

"How Linux Works"

[Linux] Basic commands and directory structure in Linux (first draft)

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.