How to Learn Linux batch Rename and basic Linux commands in Linux

Source: Internet
Author: User
Tags network function
Transferred from
Http://beterfly.blogbus.com/logs/23724282.html

Basic commands:

Logout: Logout

Log on to login again

Exit to exit the current user

Shutdown: shutdown + time
Example: shutdown now (shutdown now or immediately)

Shutdown-C cancel all shutdown settings (shortcut: Ctrl + C)

Restart the computer:
Shutdown-r restart time
Example: shutdown-R
Reboot (immediate restart) is the same as shutdown-R

In Linux, there are seven run_level_number running levels. You can use these seven runtime levels to perform character interfaces and graphic interfaces to switch:
Shutdown 0

Single User 1

Multiple users (no network function) 2

Multiple users (all functions) 3

Retain 4

Character Interface 3

Graphic Interface 5

Restart 6

Character interface command: init run_level_number
For example, init 5 enters the GUI

User Name Creation/modification/Deletion:

  • Create a new user:

Useradd Username

Adduser User Name

  • Set User Password: passwd Password
  • Change Username: usermod username before new username
  • Delete user: userdel [-R] Name (-r indicates deleting the user's default home directory along with deleting the user)


View help information:

Command -- Help

  • Get simple help information CP -- Help
    , Man command
  • Get detailed help information man CP
    , Info command
  • Get Detailed Help info CP

    Linux

View user login information

Whoami: displays the current user name

Who am I: displays the details of the current user

View System Information
Uname-A: All Information

Uname-S: Kernel name

Uname-N: node name

Uname-R: Release Version Number

Uname-V: Kernel release time

Uname-M: hardware name

Uname-P: processor type

Uname-I: hardware platform

Uname-O: OS name

CD command file modification, directory switch command
The CD command is similar to the doscommand in windws.
Common abbreviations:

  • Cd ~ : Enter the Home Directory
  • CD.: switch to the current directory
  • CD...: switch to the current directory
  • CD (Press ENTER): return to your home directory by default

Ls (list) command to list contents in the directory

Ls-L: long format. Only the file size and attributes are displayed.

Ls-A: List all files, including files to be stored (Note: Files starting with "." are hidden files)

Ls-R: displays directory content in hierarchies

Ls -- help: simple help for displaying ls commands

Ls -- color =? : File type display color ,"? "Indicates when to distinguish the file type by color.
The following options are available:

TTY: only displayed on the terminal

Auto: Default
Always: Always show color

None: never displayed
In the character interface, the file types are distinguished by colors as follows:

Gray: Common File

Green: Executable File

Blue: directory file

RED: compressed file

Light blue: link files (similar to shortcuts in Windows)

Pink: Image File

Yellow (orange): Device File

White on Red: incorrect file
 
Command for viewing File Content(Similar to the typec view and edit commands in Windows)

Cat: directly list files and so on.

More)

Less: displays the file content by PAGE (pages can be turned up or down through the Pagedown/Pageup key)

Head-N: displays the first n rows (N digits)

Tail-N: The last n rows (N digits)
 
View File System Information

Which: Display command alias and execution file name

Whereis: Display command documentation and execution file name

File Permission

In Linux, files must change their permissions by modifying properties.

Ls-l can list all information about a file.

Example: lrwxrwxrwx 1 Root 3 AAA-> ABC
File Attribute link count owner group file size modification time file name

WhereFile AttributesIndicates the file type and permissions.

The file attribute consists of 10 characters in the first place: L is the file type, and the remaining 9 characters are file permissions 9 = 3 (characters) * 3 (class Users)

File Type:

-: Common File

L: Link file

B: block Device Files (such as hard disks)

C: serial device file (for example, keyboard and mouse)
The three types of users are: file owner (owner) user, group member, and Other Persons Other.

The file has three permissions:
Read: R
Write: W
Run: x

No permission :-

For example, if the attribute of a file is lrw-r --, it indicates that the file owner has read and write permissions, and the group members and others are read-only.

Chmod command

The chmod command can modify the file attributes to change the file permissions.

Basic Format: chmod-r permission expression file name
-R is the option and can be ignored.

There are two types of permission expressions: symbolic expressions and numeric expressions.

Symbol Expression:
R w x: represents the corresponding permissions respectively.

+-=: Add, remove, and set (overwrite) permissions respectively.

U g o: represents the owner, group members, and others respectively.

For example, chmod u = RW-, G = r --, O = --- ABC indicates that the ABC file is set as the master for read/write, and the members of the group are read-only. Others do not have any permissions.

Numeric expression: R = 4 indicates that the read permission is expressed by a 4-digit number.
W = 2 indicates that the write permission is expressed by a 2-digit number.
X = 1 indicates that the execution permission is expressed by a 1 digit.
-= 0 indicates that you do not have the permission to use a number 0.

For example, chmod u = RW-, G = r --, O = --- ABC is the same as chmod 640 ABC.

Note: chmod 755 ABC (755 is the resource file applied to the website)

 
Ln command to create a link

There are two types of file links:

  • Soft link: Symbolic Link (shortcut in Windows)

Basic Format: ln-s Link Target connection name

  • Hard link: Two or more names (shortcut link names) are created for each disk. The relationship between the names is hard link.

Basic Format: ln connection target connection name


Other common commands

  • Copy: CP [-Option] source file target file

Option:

CP-f Source File target file: Forced overwrite, no information is prompted

CP-I source file target file: Forced overwrite with prompt information

CP-r source file target file: Copy command

  • Tonch: last modification date of the modified File
    If the file does not exist, create a new blank file (there is no special file creation command in Linux)
  • RM: Remove Delete directory/file (non-blank directory/file can be deleted permanently)

Rm-F: Force Delete, no prompt
Rm-I: Force Delete. A prompt is displayed.

Rm-R: delete a directory

  • MV: Move a mobile file (Extended Function: Rename, Linux system does not have a special RENAME Command)

Basic Format:

Move file: MV file name move destination file name

Renamed file: the modified File Name of the MV file.

  • Mkdir: Make dir create a directory

Mkdir-p a/B/C: create multi-level directory

  • Rmdir: delete a directory (non-empty directories cannot be deleted)
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.