Linux commands that must be remembered when learning linux

Source: Internet
Author: User
All management tasks in Linux can be completed on the terminal. In many cases, using a terminal is faster than using a graphical program, and additional functions may be implemented. In addition, all terminal tasks can be written to scripts for automatic execution. To truly control your Linux environment

All management tasks in Linux can be completed on the terminal. In many cases, using a terminal is faster than using a graphical program, and additional functions may be implemented. In addition, all terminal tasks can be written to scripts for automatic execution. To truly control your Linux environment, you will want to know how to work in the terminal. If you have ever used DOS/Windows, this article will guide you to start using Linux terminals.

 Enter terminal

If your system directs you to the text mode (the server is usually configured in this way to reduce service overhead), you have logged on to the terminal as text. In a typical Linux system, you can switch to another terminal by pressing Ctrl + Alt + (F1-F6. Each terminal is a completely independent session in the system, which can be used by different users at the same time.

This multi-terminal feature is different from multiple desktops in Windows. In Linux, each terminal can be controlled by completely different users. For example, you may log on as root in Terminal 1 and on Terminal 2 as joeuser. The two terminals run different programs in their respective user spaces. Similarly, different users can remotely log on to the same Windows system. In this regard, Linux is more like a host than a simple server or workstation.

If you are in graphic mode, you can open a virtual terminal (terminal) to enter the terminal window. Usually there are terminal buttons on the task bar on the desktop. You can also open the terminal from the context menu (right-click on the desktop.

Command

There are many commands available in the terminal. Some of them are actually used only when writing scripts. Here are some of the most likely commands you can use. Do not forget that all commands and options are case sensitive. -R is different from-r, and different operations are performed. Almost all terminal commands are in lowercase.

◆ Cd

You can switch between directories using the cd commands we are familiar. Note that a forward slash (/) is used in Linux, rather than a backslash () that you are familiar (). The backslash is also used, but it is only used to indicate that the command needs to continue with the line feed, which can improve the readability of long commands.

◆ Ls

The ls command is used to list all files in a directory. You can use many different switches to change the list representation:

Ls-l lists objects in long format, including file size, date and time, and attributes.

Ls-t sorts files by time

Ls-S sorts files in ascending or lowercase order

Ls-r is used in combination with a sort switch for reverse sorting.

Ls-t displays the latest file on the top of the list.

Ls-t displays the latest file at the bottom.

The ls-h format is easy to read. Use k, M, G, and so on to identify the file size, rather than in bytes.

Ls-a displays all files in the directory, including hidden files.

◆ Cp

Use the cp command to copy files. This command is basically the same as the copy command in DOS. The basic switch is as follows:

Cp-R is used to recursively copy files. it is used to copy the entire directory.

Cp-f forcibly copies and overwrites existing files without asking users

Cp-l link file instead of copying; see the following description

◆ Mv

Use the mv command to move and rename a file. This command basically works in the same way as the move command in DOS, but it can move the entire directory structure and all files.

◆ Cat

Run the cat command to view the file content. It is equivalent to the type command in DOS. It will dump the file content to another file, screen, or other commands. Cat is short for concatenate and can combine a series of files into a large file.

◆ More

You can use the more command to view files by page. It is basically the same as the more command in DOS.

◆ Less

The less command is also used to view files, but it supports up/down scrolling and text search in documents.

◆ Vi

Some may say that vi is "always ally impossible ". It is a historical text editor in Unix. Vi is not really intuitive, but now almost all Unix-like environments have vi. There is a built-in tutorial for the version installed in Linux. once you are familiar with vi, you only need to press a few times to complete incredible tasks. To be honest, no editor can replace vi to edit passwords and configuration files.

◆ Man

Run the man command to view the command documentation. Man is the abbreviation of manual. Almost every command has corresponding documents. To learn more about man, enter the following command:

Man

◆ Info

The info command is similar to the man command, but it provides hyperlink text to view documents more conveniently.

Link

One of the most important features of a Linux file system is its File link. The link is a reference to the file, so that you can see the file in the file system. However, in Linux, links can be treated as original files. Links can be executed, edited, and accessed like normal files. For other applications in the system, the link is the original file corresponding to it. When you edit a file through a link, you actually edit the original file. The link is not a copy. There are two types of links: hard link and symbolic link (soft link ).

Hard links can only reference files in the same file system. It references the physical indexes (also known as inode) of files in the file system ). When you move or delete the original file, the hard link will not be broken because it references the physical data of the file rather than the position of the file in the file structure. A hard-linked file does not require the user to have the permission to access the original file or display the location of the original file. this helps the file security. If the deleted file has a hard link, the file will still be retained until all references to it are deleted.

A soft link is a pointer pointing to the position of a file in the file system. Symbolic links can point to files in a remote file system across file systems. The symbolic link only specifies the location of the original file. you must have access to the location of the original file to use the link. If the original file is deleted, all symbolic links pointing to it will be damaged. They point to a location that does not exist in the file system.

Both links can be created using the ln command. By default, ln creates hard links. You can use the-s switch to create a symbolic link.

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.