Basic Linux Usage

Source: Internet
Author: User

Partition
1./Root Partition
2. Swap swap partition (size recommendation is twice as long as memory)
3./home Partition
4./boot boot file (boot load) partition
5./var

And so on, the minimum must have the first 2 partitions, preferably have a home partition, because there is no this may be installed after the software will be a little bit of a problem

The environment is the CentOS in the VM virtual machine
Crtl+alt+enter Virtual machine full-screen or not switch
Shutdown-h now immediately shuts down the machine
Reboot=shutdown-r now restart
Logout logoff
VI Editor most basic use
1. VI a.txt If no a.txt is created, open it.
2. Input small I enter the input mode to start editing open files
3. Press ESC to enter the command line after editing
4. Enter: (colon) Wq (save and exit) the latter q! Direct exit
Linux run level [0~6]
0: Turn off the machine
1: Single-user mode
2: Multi-user status No NETWORK service
3: Network Service with multi-user status
4: System not used reserved to user
5: Graphical interface (boot default to graphical interface)
6: System reboot (reboot immediately after boot)
The common runlevel is 3,5
Modifying the run-level method
Log in as root (normal user does not have permission to modify)
To/etc/inittab with VI open edit find
Id:3:initdefault

Modify the corresponding number to
If you accidentally set to 6, reboot will restart immediately after
How to modify the error configuration
Enter e when entering the Grub boot interface
There will be three options to select the second item

Enter e after entering an interface after the last input space 1 (indicates boot into single-user mode, in this mode boot startup will not read Inittab files)

Enter return to GRUB interface

then enter B
When the system starts, it goes into single-user mode, it can change the password or retrieve the forgotten password.
Because no password is required when single-user mode is entered (directly into the root directory)
Then go to modify the configuration of the inittab corresponding location can be

other basic Commands
PWD Displays the current working directory
CD Switch Directory
LS lists files and directories
ls-l listing files and directories in long list format
ls-a lists files and directories including hidden files and directories can also be combined using Ls-al
mkdir Building a directory
mkdir a B C will be established in the current directory A,b,c three directories prompt if directory already exists
If you create a directory recursively, use the parameter p such as Mkdir-p a/b/c (the directory you want to create does not exist)
RmDir a b C will delete a, b,c directory rmdir Delete directory This directory must be empty
recursively delete empty directories
RM Delete files and directories do not add parameters can only delete non-empty directories
Delete files or directories and directories when Rm-r deletes a recursive deletion that is forced without prompting when RM-RF is first confirmed
Rmdir-p a/b/c The empty parent directory of C and C is also deleted, that is, A/B/C will be deleted
touch creates an empty file to create multiple files at the same time, such as Touch a.txt b.txt
MV Command
1. Format
mv[option] source file or directory destination file or directory
2. Command function
depending on the second parameter (catalog file or directory), the MV command renames the file or moves it to a new directory.
when the second parameter is a file, the MV command finishes renaming the file, at which point the source file can only have one (or the source directory name) .
It renames the given source file or directory to the specified directory file name. When the second parameter is in the name of the directory that exists,
there can be more than one source file or directory parameter, and the MV command moves the source files specified by each parameter to the destination directory. When moving files across file systems
The MV is copied first, the original file is deleted, and the link to the file is lost.
3. Command Parameters
-B: Overwrite the previous backup if you need to overwrite the file.
-f:force Mandatory Meaning, if the target file already exists, will not be asked and directly covered;
-I: If the target file (destination) already exists, you will be asked to overwrite it!
- u: If the target file already exists and source is newer, update (update)
-T:--target-directory=directory move all SOURCE arguments to directory, which is the target directory for the specified MV,
This option is useful when moving multiple source files to a directory, when the destination directory is in front of the source file.
CP Replication
cp-r dir1 dir2 recursive replication (replicating directory and its subdirectory information)
Ln establishes symbolic links (such as shortcuts under Windows)
ln-s Source Target
ln-s/etc/inittab Inittab (Inittab pointing to the actual file/etc/inittab)
tab Auto-complete
Create a user
Useradd user1
passwd user1
Password

More Displays the contents of the directory or file with pagination (press the space next to the Shift+pageup page)
such as a file a.txt content is long more a.txt can be paged display
Less Displays the contents of the file with pagination
grep queries the file for content
Grep-n ' What to look for ' file name plus n will display the line number of the item you are looking for in the file location
copy and paste revocation of files in VI
in the same file.
Alt+v Enter but mode move cursor Select the text you want to copy
then press Y
after I enter insert mode, press Alt+p to insert the pasted text to the cursor
Full Row replication
input I into insert mode
cursor is positioned to the row to be copied
Press Alt+v to enter visual mode
input yy Copies the row of the cursor to the Clipboard (buffer area)
move to the place where you want to insert the cache (paste the contents of the Clipboard at the cursor) by pressing ALT+P where you want to insert it

Basic Linux Usage

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.