Enter your username and password. of course, enter root to obtain all management permissions! You really want to see the pretty graphic interfaces immediately, but maybe I want to disappoint you. Before using the graphic interface, I suggest you master the basic Linux life first.
Enter your username and password. of course, enter root to obtain all management permissions!
You really want to see the pretty graphic interfaces immediately, but maybe I want to disappoint you. Before using the graphic interface, I suggest you first master the basic Linux commands, which is a real Linuxer. Where can I start?
1. ls command for listing files and directories
You must be curious to know what is in your computer. now you can run the ls command. why is there nothing? Of course, this is the first time you log on to this system. your default location is your personal directory rather than the system root directory. You have not stored any personal files in this directory, of course, nothing. If you log on as a root user, your personal directory is the/root directory. if you log on as a common user, for example, kris, your personal directory is/kris. What does the previous/mean? It means "root", which is the first directory. There are many subdirectories under the root directory, which we have discussed in Chapter 1.
The ls command has many options, which are commonly used:
-Option A is used to list all objects, including hidden objects. Why do we need to hide files? The reason is the same as why you want to hide your love letter so that your parents won't discover it. It is for confidentiality. Execute ls-A now to see? Is there a hidden file ". bashrc" displayed? Clever, you must be surprised to find that there is a point in front of this file name, right! Remember, as long as the first character before the file name is a ".", this file is hidden. If the first character before a directory name is ".", the directory is hidden.
-L this option is used to display a list that contains a list of the vast majority of attributes of all files under this directory. You can set the size, owner, permission, modification date, and so on for each file.
-R indicates recursive recursion. Obviously, this option allows the system to display all files under this directory, but also the files under all subdirectories. That is, shake out all our fruit.
-- The color option is particularly useful. I guess everyone's display is colorful. what? Is your monitor still black and white? Oh, my God! Since it is a color display, we can make the ls command use different colors to represent different file types. For example, the executable file is green, the normal file is white, and the directory is blue. Maybe you will ask, is the directory also a file? Yes, everything in Linux is a file, and all hardware devices use a file instead. for example, your soft drive is replaced by/dev/fd0. Directory is also a file.
The -- help option is available in almost every Linux command to display the help information of the command.
2. change the directory where cd, mkdir, and rm are stored, create a new directory, and delete the directory command.
We talked about directories. each time we log on, we have a default directory, which is our personal user directory. How can we get to other directories? Cd is used to change the current directory. As we have said before, "/" indicates the root directory. then, run cd/to enter the root directory. Don't you try?
Let's take a look at the files and subdirectories under the root directory and execute ls. we found that there is a directory name under the root directory that is abnormal, called usr. let's go and see, cd usr, let's see what's in it? You will find a more psycho (abnormal) directory named src. go to the src directory and check it? Nothing fun. Now, how can we go back to the usr directory? Is it cd usr? Run the command and try again. The system reports an error cd: usr: No such file or directory. How did this happen? The problem is that our current directory is/usr/src. We execute cd usr to enter the/usr/src/usr directory instead of the/usr directory. The correct method is cd/usr.
Just like you can see a Sichuan basket in the basket of Chinese food, which contains a small basket of Chengdu, now, when you enter, you will find that there is a very spicy food in the basket in Chengdu. If you want to have some dessert, you are going to Fuzhou. Can you go to Fuzhou from the basket in Chengdu? Of course not. Fuzhou is not in the basket of Chengdu. you should enter "/chinese food/FUZHOU" instead of "/chinese food/Sichuan/CHENGDU/FUZHOU", right?
Okay, a problem arises. Should I use/usr/src... to express it every time I access a directory? Not necessarily. We use "..." to represent the previous directory. If you are in the/usr/src Directory, there are two ways to enter the/usr Directory: cd/usr and cd .. they are the same.
How can I know which Directory I am in? Run the command pwd. there is nothing to say about this command. you will know it once you execute it.
Now I want to create a directory named LoveLetter in my personal directory. First, I should go back to my own directory. here is a simple method, that is, directly run cd without any parameters, so that I can go back to my Directory, of course, you can also use cd/root or cd/home/kris to check which user you use to log on.
After entering my own directory, the command to create a new directory is
Mkdir new directory name
Run mkdir LoveLetter to create a new directory called LoveLetter. Go to this directory to see? Nothing. Don't worry, take it easy. I'm not worried. What are you worried about?
Suddenly I remembered that my parents would also use this computer. what should they do if they saw my love letter directory? You forgot what I just said, you can add a dot "." to hide the directory and file in the previous method? We can change the directory name, but I am going to talk about this command later. now we are using a very boring method to fulfill this requirement. This method is to delete the created oveLetter directory and create a new one. the LoveLetter directory is boring because we are doing experiments. if so, are you sure you want to delete your love letter? Is there another new joy? Haha.
The command for deleting directories can also delete files, that is, rm.
Rm file name/directory name to be deleted
I remember that Redhat will prompt you if you want to delete it. Press y to confirm, and press n to cancel. If Redhat does not prompt you, please modify the system according to the method I mentioned and let it prompt us. In the future. It is easy to delete an object. The trouble is to delete a directory. if a directory already contains files, rm will not allow direct deletion. you must first delete all the files in the directory before deleting the directory. But there is a parameter that can be changed, that is,-rf, which is risky, because even if the system has to remind you whether to delete the Directory, this parameter will not be prompted. Execute the rm Directory-rf will give your documents a lesson in a blink of an eye!
Now I will delete the LoveLetter Directory: rm LoveLetter-rf
Create a new directory mkdir. LoveLetter
Now let's check if the LoveLetter directory is invisible? But ls-A can still see it. Therefore, this hiding method can only be used by yourself. the method for truly securing your files will be discussed later.
3. mv command for changing the file name and directory name
Cp copy file and directory commands
Man command usage reference tool
Old mv file name new file name
Old mv directory name new directory name
You can change the name of a file or directory.
Now I want to put this directory. loveLetter is renamed, because this boring hidden method is abnormal. we have a more advanced method to do this: Don't tell your mom and dad your password !!!
Mv. LoveLetter
The cp command is used to copy a file into a new file,
Cp old file name new file name
If the old file and the new file name are under the same directory, the name must be different. it is very simple. if the file name is the same, why should we create two files? If the new and old files are in different directories, we can make them have the same name. The following example illustrates this:
Cp LoveLetter LoveLetter_yesterday the new file LoveLetter_yesterday is in the same directory as the old LoveLetter, so the name is different.
The new cp LoveLetter/home/LoveLetter file is under the/home directory, but the old file LoveLetter is under the personal directory of a user. of course, the two names can be the same.
The cp command can also copy the entire directory, but we are not talking about this complexity for the time being. In fact, cp and rm and ls commands are not only the basic commands of Linux, but also contain many functions. If you are interested, you can use man
Man command name
For example, man ls can see the detailed explanations of all ls commands and parameters, especially the man help of some commonly used commands has been translated by volunteers, and it seems easier for everyone.
A little humorous
Well, I have talked about a lot of things. I want to take a break and tell you something interesting. we have talked about a lot of commands and directories. do you think it is a bit strange. To be honest, I did not know what it meant when I first saw the usr directory, and then I found the following correspondence:
Usr->; user
Ls->; list
Mkdir->; make dir
Rm->; remove
Src->; source
Mv->; move
Cp->; copy
...
Isn't it interesting? in the UNIX world, including the Linux world, people's imagination is so invincible! It can be abbreviated as this. The general idea is to take the first three or the first four letters of a word as short words, but UNIX cool people just like to abbreviated move as music videos. they really don't know what they think. Let's explore it together.
4. commands for editing files with nano and vi and displaying text files with cat and more
Nano is a small, free, and friendly editor. I think nano is more suitable for beginners of Linux. Now we only learn how to edit a file and save it.
Nano file name
If the file name you wrote already exists, open and edit it; otherwise, a new file is created. Is the editing method still used? When you want to exit, press ctrl + x and nano will ask you if you want to save the edited file. Press Y to save, and press N to save.
The biggest advantage of nano is that you don't need to remember too many operation keys. most of the commonly used operation methods are listed on the screen. Note that "^ X" means holding down the ctrl key and then pressing X.
The following is a brief introduction to vi. Vi is a very powerful editing software. It is too huge. it is enough to write a book to explain it. Here we will talk about the usage of vi from the perspective of usage.
Vi has two modes: command mode and edit mode. After entering vi, it is in command mode by default.
Run vi LoveLetter. After entering, you can press the Insert function key or I key on the keyboard to enter the editing status. you can Insert characters and press Insert to change to the overwriting mode. the differences between the two modes are easily reflected, you can try it. Up, down, left, and right direction keys can move the cursor. There is no difference between basic editing commands and Windows. Is it easy? After you input the required content, we need to save it. press ESC to return to the command mode from edit mode. first, enter a colon ":", that is, press the SHIFT key and then press the semicolon ";" to enter a ":" First. Then, enter w and press enter to save the edited content to the LoveLetter file. Now we can click Insert to continue editing. Press ESC, enter ":", and then press w to save. But now we don't need to save it. if we want to quit without saving it, what should we do? When we enter w, it means write and save. then we input q to exit quit. OK. enter q and press Enter. vi prompts that the modification we just made has not been saved. so remember! Once we need to discard our changes, we cannot directly exit with the q command, but we need to use "q !" Command. Enter q !, Okay. quit.
We want to see if the LoveLetter we just edited is actually saved. then we can see vi LoveLetter and OK? Now, if you want to exit directly, you can simply enter ": q" without entering that "!". Because we have not modified the file content. If we modify this article, we can enter "ESC: wq" when exiting. You do not need to divide w and q into two inputs.
The most basic usage of vi is almost the same here. if you want to learn more about vi, you can press F1 directly after entering vi. you have detailed help and teaching.
In fact, just now we want to see if the edited LoveLetter is saved. we don't need to go in vi any more, just use the command
Cat LoveLetter
You can. Cat is a command used to display the content of a text file. If the text file is too long and the screen is incomplete, cat will not automatically pagination. We can replace the command
More LoveLetter
When the more command displays a text file, if there is too much content, it will automatically pause at the end of each page and wait until the user presses the space key to continue.
5. the most important command: halt reboot shutdown and restart command
In Linux, you cannot directly use the power button to shut down or use the reset button to restart the system, which has a great impact on the system, especially the hard disk. The shutdown command is halt, and the restart command is reboot. In fact, there are shutdown commands to complete similar functions. if you need them, use the man command learned today to learn how to use it.
It's hard to write this chapter. I hope the newcomers can read it well, which will help you. The following describes the XWindow configuration. This is a topic that everyone cares about.
Author: Birds"