Linux Console Quick Guide
Level: primary
Chris Walden (cmwalden-at-us.ibm.com) e-commerce architect, IBM Developer Relations 2004 January
IBM e-commerce architect Chris Walden will pass him
The nine series of articles published on DeveloperWorks guides you how to use your Windows operation skills in your Linux environment. This section will introduce a variety of different shells and some of the most basic Linux commands.
All management tasks in Linux can be done in the console. In many cases, the use of console is faster than using graphical programs, and additional features may also be implemented. Not only that, all console tasks can be written in the script so that you can do it automatically. In order to truly control your Linux environment, you will hopate how to work in the console. If you have used DOS / Windows, this article will boot you to start using the Linux console.
Enter the console If your system boots into text mode (in order to reduce service overhead, the server is usually configured such that you are already in the console after logging in in text. In a typical Linux system, you can switch to another console by a combined key Ctrl Alt (F1 - F6). Each console is a fully independent session in the system, and different users can use simultaneously.
This multi-console characteristic is different from multiple desktops in Windows. In Linux, each console can be controlled by a completely different user. For example, you may be logged in as root in the console 1, and log in as JoeUser in the console 2. Two console runs different programs in their respective user spaces. Similarly, different users can log in remotely in the same Windows system. In this regard, Linux is more like a host instead of a simple server or workstation.
If you are in graphics mode, you can open a terminal to enter the console window. Typical buttons typically have a terminal on the desktop. You can also open the terminal from the context menu (right button on the desktop).
There are a lot of commands that can be used in the console. Some of them actually use only when writing scripts. Here you introduce some commands you most likely. Don't forget, all commands and options are case sensitive. -R is different from -r, which will perform different operations. The console command is almost all written.
CD Use the CD command we are familiar with to switch between the directory. It is important to note that a forward slash (/) is used in Linux, not the backslash (/) you are familiar with. The backslash is also used, but it is only used to explain the command to continue, which can improve the readability of a longer command.
The LSLS command is used to list all files in a directory. You can use many different switches to change the representation of the list:
List of files
LS -L lists files in a long format, including file size, date, and time, attribute LS -T pairs of files in terms of time sorting LS -S with a size sorting LS -R with a sort switch, in reverse order. LS -T Displays the latest file on the top of the list. LS -T Displays the latest file at the bottom. LS -H readable format. Use K, M, G or the like to identify the size of the file, not byte. LS -A Displays all files in the directory, including hidden files
CP uses the CP command to copy the file. This command is basically the same as the COPY command under DOS. The basic switch is as follows:
Copy file
CP -R recursively copy files; when you need to copy the entire directory, you will use the CP -F to force copy and override existing files, do not ask the user cp -l link file, not copy; see the following description
Creating a link with a copy command With a CP command to create a hard link to a file or the entire file structure. Use the -l switch to indicate that the operation is a link replication. All directories are still created as directory, but all files are set to hard links. CP -LR / DATA / Accounting / Payroll / Data / Management / HR The above command will copy the entire directory structure and the following files from / data / accounting / payroll to / data / management / hr / payroll. All files under the directory structure will be set to hard links. This allows a file to have different views in the same file system. This is also useful security technology that makes different access rights to the same file in different directories. MV uses the mv command to move and rename files. This command works basically as the Move command in DOS, but it can move the entire directory structure and all files.
CAT uses the CAT command to view the contents of the file. It is equivalent to the TYPE command in DOS. It will dump the contents of the file to another file, screen, or other command. Cat is a concatenate, you can also merge a series of files into a big file.
More Use the command more to view the file in a paging. It is basically the same as the more command in DOS.
The Lessless command is also used to view files, but it supports up and down and searches for text in the document.
VI Some people may say vi means "virtually impossible". It is a historic text editor in UNIX. Vi is not truly intuitive, but there are VIs in almost all of the Unix environments. For the version installed in Linux has a built-in tutorial, once you are familiar with VI, just a few keystrokes can complete the incredible tasks. To be honest, there is no editor to replace VI to edit your password and configuration file.
Man command to view the documentation of the command. MAN is the abbreviation of Manual. Almost every command has a corresponding document. To learn more about MAN, enter the following command:
Man Man
The infinfo command is similar to the man command, but it provides hyperlink text that can be more convenient to browse the document.
One of the most important differences between DOS / Windows and Linux is that the command shell of Linux is a layer separated from the operating system. Different shell environments have different features, such as editable command lines and historical command reviews, etc. The shell also determines the syntax of the function in the script. In DOS / Windows, only one case in writing a script, that is, the use efficiency is low .bat file. It can indeed complete a lot of features, but in addition to completing the basic tasks, complex tasks require script writers to have strong creativity. In Linux, there can be cycles in the script, not only the basic conditional statements can be performed, but many of the functions in the programming language are available. If you are good at writing the .bat file, the shell script will make your big spread.
The default shell is a parameter for each user account. Typical default shell in Linux is / bin / bash, but you can also use other shells. Each shell's Man document is actually very good, and all kinds of shells and their use have been described in detail. Just read the explanation below is not enough, you should select one from the shell listed below to see its Man document.
Bashbash shell is a free version of Bourne Shell, which is the earliest UNIX Shell, including many additional features. BASH has editable command lines, you can check the history command, support the Tab keys to use the user to avoid the user name.
The CSHC shell uses the "class C" syntax, drawing on many of the characteristics of the Bourne Shell, just the interior shell command set. The syntax of the Kshkorn Shell is the same as the Bourne Shell, and has the ease of use of C shell. Many installation scripts use KSH, even if you don't use it as your primary shell, you should also install it in your system.
TCSHTC shell is a enhancement version of C shell and is fully compatible with C shell.
Zshz Shell is a enhancement version of the Korn Shell, which has many features of the Bash Shell.
Shell rules You can only switch the shell at any time you only need to perform the appropriate commands in the console. As long as a well number (#!) Pointing at the top of the file, the script can specify the shell you want to run. When the script is running, regardless of the shell environment where the user is, it will run in the correct shell environment. This line of code in the following example points out that the script needs to run under the c shell: #! / Bin / csh
Let me make a link, which is safer! The most important feature of the Linux file system is its file link. The link is a reference to the file so you can make the files you have seen in the file system. However, in Linux, the link can be treated as the original file. The link can be performed, edited, and access as a normal file. For other applications in the system, the link is the original file it corresponds to. When you edit your files over the link, your editing is actually an original file. Link is not a copy. There are two types of links: hard links and symbolic links.
Hard link can only reference files in the same file system. It references the physical index (also known as inode) in the file system. When you move or delete raw files, hard links will not be destroyed because it is referenced by the physical data of the file instead of the file in the file structure. The hard link file does not require the user who has access to the original file, nor does it show the position of the original file, which helps the file security. If your deleted file has a corresponding hard link, then this file will remain until all of it is deleted.
The symbolic link is a pointer, pointing to the location of the file in the file system. Symbolic links can be across file systems and can even point to files in remote file systems. The symbolic link only indicates the location of the original file, and the user needs access to the location of the original file to use the link. If the original file is deleted, all symbolic links that point to it are ruined. They will point to a location that does not exist in the file system.
Both links can pass by command ln
Create. LN is created by default is a hard link. You can create a symbolic link using the -s switch.
# Create a hard link from MyFile in the current # directory to / YourDir / MyFileln MyFile / YourDir # Create a symbolic (soft) link from MyFile in # the current directory to / YourDir / YourFileln -s MyFile / YourDir / Yourfile
In the above example, MyFile, / YourDir / MyFile and / YourDir / YourFile will be seen as the same file.
Going out your shell for Linux management, you must learn to work in the console environment. Although there are some tools to avoid using console, you will be subject to many of those tools. It is easy to access the console very easy to use the Man and Info command to access the command document.
Reference
Read the other parts of Windows to Linux Tour Series (DeveloperWorks, November 2003). Follow the Tutorial "VI Getting Started - Clearing Works Unilateral Act" to start using the VI editor. "Basic tasks for Linux development newbies" (DEVELOPERWORKS, July 2001) Introduction to how to work under Linux, including the topics involved to open the Shell window, add users, and groups, and mount and load CD-ROM. "Linux User Technology FAQ" (DEVELOPERWORKS, July 2001) can also help you transition from Windows to Linux smoothly. "How much is the Linux client?" Tells the experience of the author's work environment by Windows to Linux. At the same time, there is also an article "Concise Linux Glossary for Windows User" is also useful reference materials. On the GNU Manuals Online page you can find a lot of online help web pages. From DOS / Windows To Linux Howto provides some quick start-up information for people with DOS or Windows background. Allcommands.com is a unique site that helps you reference the reference and cross-reference commands from a variety of operating systems. Tutorial "LPI CERTIFICATION 101 Exam PREP, PART 1: Linux Fundamentals" introduced Bash, standard Linux command, and so on. Learn the Shell script in depth by "Bash Instance" series. Although it is written for AIX users, SYSTEM User's Guide: Operating System and Devices - Shells Reference Chapter, including AIX Commands Reference - Man Command is equally applicable to Linux. To start using IBM software products on Linux, develop refueling for your Linux application will provide you with the best reference. You can find installation prompts and reference information about DB2, Lotus Domino, WebSphere Application Server, WebSphere Studio, etc. You can also log in to get the free Linux Software Evaluation Kit, with trial software and training materials. Learn Linux's basic concepts from here from here from here. More reference materials for Linux developers can be found in the developerWorks Linux zone. About the author Chris Walden is an e-commerce architect in IBM Developer Relations Technical Consulting (also known as Dragonslayers) in Austin, Texas, which provides education, implementation and consulting for IBM business partners. He is committed to Linux related work, and an opportunity to promote the benefits of Linux from people around you. In addition to completing his architect's responsibilities, he is also proficient in various fields of Linux infrastructure servers, including files, prints, and other application services in a hybrid platform user environment. Chris has 10 years of experience in computer industry, supporting Web application development and consultants from site, and he has been involved in various fields. You can contact CHRIS with CMWALDEN-AT-us.ibm.com.