Although the GUI desktop (such as KDE and GNOME) can help users use the Linux feature without the need for the functional knowledge of the command line interface, it is often necessary for more functionality and flexibility. Moreover, it is basically familiar with these commands to correctly automate certain functionality in the shell script. This article is a "fast tutorial" on Linux file commands, which is provided for users who just contact this operating system or just need to supplement this knowledge. It contains a concise overview of some more useful commands and guidance on their most powerful applications. The information contained below - combines some experiments - will enable you to easily grasp these basic commands. (Note: When involving a kernel combined with the Oracle Cluster File System (OCFS), the behavior of certain commands in these commands may be slightly different. In this case, Oracle provides an OCFS toolset, which The tool set can provide a better selection 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 in other systems, but if you have problems, you should view your documentation for possible changes. Background concept allows us to review some basic knowledge before deep research specification. Files and commands are in the Linux / UNIX operating system, all things are treated as a file: hardware devices (including keyboards and terminals), directory, command itself, of course, there are files. This strange practice is actually the basis for Linux / UNIX's ability and flexibility. Most (almost all) command forms are as follows: command [option] [Source File (s)] [Target File] Get one of the most useful commands is those that provide help (especially those who learn Linux In the words). Two important sources of information in Linux are online reference manuals, or the Man page and whatis tool. You can use the Whatis command to access a MAN page that is unfamiliar command. $ Whats Echo To learn more about this command, you can use: $ man echo If you don't know the command required for a special task, you can use man -k (also known as Apropos) and a topic to generate possible The command. For example: $ man -k files A very useful but often ignored commands provide information about using Man itself: $ man man You can use spaceBar to browse any MAN page; UP Arrow will roll up the file up. To exit, type q,!, Or ctrl-z. User category Remember the name of the sentence "An example of all animals, but some animals are more equal than other animals"? In the Linux world, root users have everything. Root users can log in with another username SU (originated from "Superuser"). To perform tasks such as adding a new user, printer, or file system, you must log in as root user or switch to superuser with the subscriber password. System files (including system files for control initialization) are owned by the root user. Although ordinary users may allow for their read operations, the rights of editing will be left to root users for system security. Although the Bash Shell provides other shells, Bash (Bash Again Shell) is the default shell of Linux. It combines the characteristics of Bourne Shell with its same name and the characteristics of Korn, C and TCSH shells.
Bash's built-in command History defaults to the last 500 commands. You can view them by entering History at the command prompt. To retrieve a specific command, press UP Arrow or Down Arrow at the command prompt, or enter its number in the historical list, and add "!", For example: $! 49 You can also pass A command to execute this command in the distance of the project in the historical list: If there are 53 events in the historical list, the event number 51 will be executed. Like other shells in UNIX / Linux, BASH uses special environment variables to facilitate system management. For example: HOME, user main directory PATH, Linux is used to search for the executable image of the command you entered HISTSIZE, the number of historical events saved by the system except these reserved keywords, you can define your own environment. variable. For example, Oracle uses Oracle_Home (and some other variable), to make Oracle installations successfully, you must set these variables in your environment. The variable can be temporarily set at the prompt: $ HISTSIZE = 100, or in / etc / profile, the system range is permanently set, or local permanent settings in .profile. You can access the value of an environment variable through the echo command, and use a $ symbol to view this value. $ Echo $ HOME / HOME / Bluher can use the ENV command to view all current environment variables. Regular expressions and wildcards Many Linux commands use wildcards * and to match any number of characters or match any single characters respectively; the regular mode matching expression uses a period (.) To match any of the "Retine". character. In both cases, square brackets ([]) are used to match the character groups other than the "*" number. However, * is similar but different in all situations: Although it matches one or more characters in the shell, in the regular expression, it matches the zero or more examples of the above characters. Some commands (such as EGREP and AWK) use a set of broader special characters to match mode matching. The file processing command analyzes a file list ls command to see a list of files in any directory with execution permissions, which has many interesting options. For example: $ ls -liah * 22684 -rw-r - r - 1 Bluher Uses 952 DEC 28 18:43 .profile19942 -rw-r - r - 1 scalish users 30 Jan 3 20:00 Test2.out925 - RWXR-XR-X 1 SCALISH USERS 378 SEP 2 2002 Test.sh list list Shows 8 columns: column 1 indicates the inode of the file, because we use the -i option. The remaining columns are normal display through the -L option. Line 2 shows file type and file access. The number 3 shows the number of links, including the directory. The owners and group owners of the files are displayed in paragraphs 4 and 5. Here, owner "Bluher" belongs to group "users". Seating 6 shows the file size (in units of the unit, not the default byte, because we use -h option. Seventh column shows the date (it looks like three columns), including month, day and Year, and the day of the day. The file name is displayed on page 8.
Using -A in the list of options will enable a list of hidden files (such as .profile). Processing files can be moved (MV), replicated (CP) or delete (RM) files and directories. Use the -i option in wise to get a good idea. $ cp -i ls.out ls2.outcp: OverWrite `ls2.out '? mv command allows the -b option, which will make a backup copy before moving the file. RM and CP accept the powerful but dangerous -r option, which will be recursively executed on a directory and its file. $ RM -IR TESTRM: DESCEND INTO DIRECTORY `TEST '? Y can use MKDIR to create a directory, with RMDIR to delete the directory. However, since RMDir cannot be used to delete the contents of the file containing the file, it is usually more convenient to use the RM plus -R option. For security reasons, all files have all rights and protection. File Access Permissions (or file mode) contains the same 10 characters as previously mentioned: The first character indicates that the file type. The most common thing is - represents files, D represents a directory, and l represents links. The next 9 characters are access to three user categories: file owner (character 2-4), user group (5-7), and others (8-10), where R represents read rights, W represents write access , X indicates execution permissions on a file. Dash - If any of these nine locations appears, indicate that this operation is forbidden to use the category. You can use the chmod command to set access to the character symbol or binary mask. To use a binary mask, you must convert the characters of the three permissions groups into a binary format, then convert to an octal format: User category: Owner user group other characters Representation: RWX RX R - binary Representation: 111 101 100 octic : 7 5 4 Give the write permissions to the user group, you can use: ChMod G W Test.sh or chmod 774 test.sh with umask commands, in the /etc/init.dev file, or in. Local file permissions in the Profile file default settings. This command indicates that the number is subtracted with 777 to get the default permissions: $ umask 022 This will generate a default file permission 755 for all new files created by the user. You can use Chown to modify the ownership of the file: $ Chown Bluher Ls.out, Bluher is a new file owner. Similarly, group members will be modified as follows: $ ChGRP devgrp ls.out, DEVGRP is a new user group. LS does not provide which files are text, which files are binary information. To understand this information, you can use the file * command. The renaming file gives two popular ways to multiple names to use the link and alias commands. Alias can be used to re-a more convenient name for a longer command: $ alias ll = 'ls -l' $ ll pay attention to the use of single quotes, which makes BASH to pass the item to alias, not to estimate it . Alias can also be used as a longer path name abbreviation: $ alias jdev9i = / jderv9i / jderv / bin / jdev for more information on Alias and its reverse command UNALIAS, see "shell Builtin Commands" of Bash's Man page Sub portion.
In the last example, an environment variable is defined to achieve the same result. $ export jdev_home = / jdev9i / jdev / bin / jdev $ Echo $ jdev_home / jdev9i / jdev / bin / jdev $ jdev_home link allows several file names to reference a single source file, the format is as follows: ln [-s] fileyouwanttolinkto newname separate The ln command creates a hard link to the file, and use the -s option to create a symbolic link. Briefly, a hard link is hardly separated from the original file area (except for the inode of the two files). The symbolic link is easier to distinguish because they appear in a long file list, and use-> to indicate the source file, l indicate the file type. The commands that view and find file file filters are used to read file content and execute operations on file contents are sometimes referred to as 1Y filters. The SED and AWK commands are examples of two filters because they have their detailed discussions in the previous OTN articles, which will be slightly here. Commands such as Cat, More, and Less allow you to view the contents of a text file from the command line without calling the editor. CAT is an abbreviation of "concatenate", which will default to display the file content on the standard output (display). One of the most interesting options provided with CAT is the -n option, which displays the file content with the number output line. $ cat -n test.out1 this is a test. Because of all lines in the Cat in a single output file, you might prefer to use more and less, because they all output a screen content. Less is an enhanced version of more that allows you to enhance files with a key command from the VI text editor. For example, D forward is rolled forward, and B is turned backwards (if N is specified before D or B). The value of N-input becomes the default value of the subsequent D command. The MAN page utility uses LESS to display the contents of the instructions. Redirection and Pipe Redirection Allows the command output to redirect to the file, rather than standard output, or similarly, or redirect input. Returned Standard Symbol> Create a new file. >> Symbols Add to an existing file: $ more test2.outanother test. $ Cat test.out >> Test2.out $ cat test2.outanother test.this is a test. To file standard input can be used
The basic format is: grep [options] pattern [file ...] $ grep -r 'Subject' NSMAIL Ctrl-z will terminate the above or any other command. The most useful option of GREP may be -s. If you search the system file with any identity other than rooted users, an error message will be generated for each file you have no access. This command prohibits those messages. FGREP (also in grep -f call) only looks for a fixed string instead of GREP's regular expression. The EGREP receives a mode containing a larger range of special characters (such as "|", it indicates the condition OR operator). $ EGREP 'SUBJECT | MAILTO' * Find the GNU version of the file Find command is very powerful, flexible and more inclusive than the classic version existing on the UNIX system. It is very useful for tasks involving a directory structure, including finding and executing commands on a file. The basic format of the Find command is: $ FIND StartDirectory Options MatchCriteria [ActionOptions] If you know the name of the file, or even the name, you don't know what it is, you can do this: $ find.-name 'test * './test./jdevhome/mywork/empws/empbc4j/test is different from the classic UNIX system, do not need to add -print operation at the end in Linux, because if you do not specify other operational options, you will assume that this action will be assumed. One point (.) On the initial location of the directory will make the find starts searching in your working directory. Two points, .., start searching in the parent directory. You can start searching in any directory. Note that you can use wildcards as part of the search criteria (just enclose the entire project as long as single quotes). $ FIND.-name 'Test *' -print./test.out./test2.out Displays a series of files with the .Out extension: $ find / home -name '* .out' But remember, unless you are As a super user runs this command, you will have a lot of "permission denied" error messages. One of the most powerful search tools is to use with GREP - EXEC operations: $ find.-Name '* .html' -exec grep 'mailto: foo@yahoo.com' {} /; here, we let find command Start executing in the current directory, find an HTML file, *. HTML, and execute (-exec) grep commands on the current file, {}. When using the -EXEC operation, a semicolon is required; this is used to perform other operations when using the find command. Antilans / and quotes are required to ensure that these items are interpreted by Bash so that they are interpreted by the command rather than the shell. Master the Linux file command provides many useful commands in Linux and uses their powerful methods that cannot be explained here. In addition, there are usually many ways to complete many tasks. We have seen some of the most common and most inspirated Linux file commands. Mastering these foundations but Key tools will make your Linux to learn to go to the fast lane. With your man page, and the enthusiasm of the test, you now have enough information to start exploring the power of Linux file operations. In my next article, I will provide a similar description of the Linux system command.