Linux file command proficiency guide (1)

Source: Internet
Author: User

This article is a "quick tutorial" on Linux file commands. It is provided for users who are new to the operating system or who only need to add this knowledge. It provides a concise overview of some more useful commands and guidance on their most powerful applications. The following information-combined with some experiments-will allow you to easily master these basic commands. Note: When a kernel is involved in combination with the Oracle Cluster File System (OCFS), some commands in these commands may behave slightly differently. In this case, Oracle provides an OCFS tool set that provides a better choice for file command applications .)

Note that all examples included here are tested on SUSE Linux 8.0 Professional. Although there is no reason to believe that they will not work on other systems, if there is a problem, you should check your documents to understand possible changes.

Background

Let's review some basic knowledge before going into the specifications.

Files and commands

In Linux/UNIX operating systems, everything is processed as a file: hardware devices include keyboards and terminals), directories, commands themselves, and of course files. This strange practice is actually the foundation of Linux/UNIX capabilities and flexibility.

The command format is as follows:

Command [option] [source file (s)] [target file]

Get help

One of the most useful commands is those that provide help, especially for those who learn Linux ). Two important sources of information in Linux are the online reference manual, man page, And whatis tool. You can use the whatis command to access the man page of an unfamiliar command.

$ Whatis echo

To learn more about this command, you can use:

$ Man echo

If you do not know the commands required for a special task, you can use man-k, also known as apropos) and a topic to generate possible commands. For example:

$ Man-k files

A useful but often overlooked command can provide information about the use of man itself:

$ Man

You can use SPACEBAR to browse any man page. up arrow will roll UP the file .. To exit, enter q ,!, Or CTRL-Z.

User Type

Do you remember the famous saying "All animals are equal, but some animals are more equal than other animals? In the Linux World, root users are in charge of everything.

Root users can log on with another user name su from "superuser. To execute tasks such as adding a new user, printer, or file system, you must log on as the root user or use the su command and root user password to switch to the Super User. System files include system files that control the initialization process. Although normal users may be allowed to read them, the right to edit will be left to the root user for system security reasons.

BASH shell

Although other shells are provided, BASH (Bourne Again shell) is the default Shell of Linux. It combines the features of the Bourne shell with the same name as it and the features of the Korn, C, and TCSH shell.

The built-in BASH command history records the last 500 commands entered by default. You can enter history at the command prompt to view them. To retrieve a specific command, you can press up arrow or down arrow at the command prompt, enter its number in the History list, and add "! ", For example:

$! 49

You can also execute this command by running a command from the top project in the History List: if there are 53 events in the History List, $! -3 event number 51 will be executed.

Like other shells in the UNIX/Linux World, BASH uses special environment variables to facilitate system management. For example:

HOME, HOME directory

PATH, which is used by Linux to search for the executable image of the command you entered

HISTSIZE, number of historical events saved by the System

In addition to these reserved keywords, you can also define your own environment variables. For example, Oracle uses ORACLE_HOME and has other variables. To ensure successful Oracle Installation, you must set these variables in your environment.

You can set the variables temporarily at the prompt:

$ HISTSIZE = 100

Or, set the system scope permanently in/etc/profile with root user permissions) or in. profile.

You can use the echo command and a $ symbol to access the value of an environment variable and view the value.

$ Echo $ HOME
/Home/bluher

You can use the env command to view all the current environment variables.

Regular Expressions and wildcards

Many Linux commands use wildcards * and? To match any number of characters or match any single character respectively. The regular expression uses a period (.) to match any single character except the line break. In both cases, square brackets ([]) are used to match character groups. However, the * sign has a similar but different meaning in various situations: although it matches one or more characters in shell, in the regular expression, it matches zero or more instances of the preceding characters. Some commands such as egrep and awk use a wider set of special characters for pattern matching.

Related Articles]

  • Linux file command proficiency guide (1)
  • Linux file command proficiency Guide (2)
  • Linux file command proficiency Guide (3)

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.