Common Linux commands and basic operations

Source: Internet
Author: User
Tags i18n
The basic idea of Linux: 1. everything is a file. 2. it consists of a single program with a short cut purpose. 3. Combine the applet to complete the big task. 4. try to interact with users as little as possible. 5. Save the configuration information of all software in the form of a text file. Shell: Shell refers to providing the user interface to save the user's life...

 

Linux:

1. everything is a file.

2. it consists of a single program with a short cut purpose.

3. Combine the applet to complete the big task.

4. try to interact with users as little as possible.

5. Save the configuration information of all software in the form of a text file.

 

Shell:

Shell refers to providing the user interface to convert the user's command into binary form and hand it over to the application software.


Shell classification: Graphical User Interface shell (GUI shell );

Command Line Interface shell (CLI shell ).


The main types of shell in UINX are sh, ksh, and bash.

 

Basic Linux commands and operations:

Linux internationalization ("i18n ")

 

[Root @ server55 ~] # Cat/etc/sysconfig/i18n

LANG = "en_US.UTF-8"

SYSFONT = "latarcyrheb-sun16"

 

Change the language environment of linux by modifying LANG = "en_US.UTF-8.

 

Locale displays the name and value of the current language:

 

[Root @ server55 ~] # Locale

LANG = en_US.UTF-8

LC_CTYPE = "en_US.UTF-8"

LC_NUMERIC = "en_US.UTF-8"

LC_TIME = "en_US.UTF-8"

LC_COLLATE = "en_US.UTF-8"

LC_MONETARY = "en_US.UTF-8"

LC_MESSAGES = "en_US.UTF-8"

LC_PAPER = "en_US.UTF-8"

LC_NAME = "en_US.UTF-8"

LC_ADDRESS = "en_US.UTF-8"

LC_TELEPHONE = "en_US.UTF-8"

LC_MEASUREMENT = "en_US.UTF-8"

LC_IDENTIFICATION = "en_US.UTF-8"

LC_ALL =

 

Display the language packs supported by all systems:

[Root @ server55 ~] # Locale-

 

Logout:

[Root @ server55 ~] # Logout

 

Each linux can provide multiple terminals, which are switched by Ctrl + Alt + Fn. 1 ~ 6 is the command line interface, and 7 is the graphical interface.

 

When the graphical interface is not started:

[Root @ server55 ~] # Startx &

 

To start more:

[Root @ server55 ~] # Startx --: 1

 

On the command line interface, go to Shift + PgUp/PgDn.

 

On the command line interface, copy/paste the shortcut key: Ctrl + Shift + c copy; Ctrl + Shift + v paste.

 

Change to open to default page:

[Root @ server55 ~] # Vim/etc/inittab

Id: 3: initdefault: Enter the text interface by default

Id: 5: initdefault: Enter the GUI by default

 

Change user password:

[Root @ server55 ~] # The old password must be provided when passwd is used to modify the root password

[Root @ server55 ~] # Passwd + user: You do not need to provide the old password when modifying the password of a specified user as root.

 

Switch user SwitchUser:

[Root @ server55 ~] # The su student su does not directly fail to completely switch with any options

[Student @ server55 root] $

[Root @ server55 ~] # Su-l student su followed by-l or-plus the user to switch completely

[Student @ server55 ~] $

 

View all previously executed commands:

Eg:

[Root @ server55 ~] # History

1 mount/dev/cdrom/mnt

2 cd/mnt

3 ls

4 reboot

5 ls/mnt

6 mount/dev/cdrom/mnt

7 ls/mnt

8 rpm-ivh/mnt/VMwareTools-6.0.2-59824.i386.rpm

9 cd ..

10 wm

11 cd ..

12 umount/dev/mount

...

Zookeeper switches the recently executed commands.

[Root @ server55 ~] #! + Num indicates the num command;

[Root @ server55 ~] #! + String indicates the command to match the string closest to the current time;

[Root @ server55 ~] #!! Indicates executing the previous command;

 

Reference the parameters in the previous command (that is, the command object ):

Eg:

[Root @ server55 ~] # Cat/etc/sysconfig/i18n

If you still want to edit/etc/sysconfig/i18n by vim, enter

[Root @ server55 ~] # Vim! $

Or

[Root @ server55 ~] # Vim press and hold Alt +.

Or

[Root @ server55 ~] # Vim short press Esc +.

 

Use the environment variable HISTCONTROL to set the record rules of history:

[Root @ server55 ~] # Export HISTCONTROL = commands starting with a space in ignorespace are not recorded in history;

[Root @ server55 ~] # Export HISTCONTROL = ignoredups commands that appear more than twice in history are recorded only once;

[Root @ server55 ~] # Export HISTCONTROL = ignoreboth space is not recorded and the command is recorded only once;

Undo HISTCONTROL:

[Root @ server55 ~] # Export HISTCONTROL =

Or

[Root @ server55 ~] # Unset HISTCONTROL

Clear history records:

[Root @ server55 ~] # History-c

 

Text editor nano:

[Root @ server55 ~] # Nano + file name open text document or create a text document

You can read, edit, and store text as prompted by the nano combination key.

 

Show file information ls (list ):

[Root @ server55 ~] # Ls + options + file path

-L displays details;

-A: displays all files (including hidden files );

-D: Display the attributes of the file instead of the files in the directory;

-R in reverse order;

-R recursive Display: displays the documents and their subdocuments in the target directory.

 

[Root @ server55 ~] # Tree + file path

Displays the file structure of the target document. See the following example.

 

Create directory:

[Root @ server55 ~] # Mkdir + option + path for document creation

-P simultaneously generates the target directory and its parent directory

-V display process during creation

Eg:

[Root @ server55 ~] # Mkdir-pv a/B/c

Mkdir: created directory 'A'

Mkdir: created directory 'a/B'

Mkdir: created directory 'a/B/C'

[Root @ server55 ~] # Tree

A

'-- B

'-- C

 

2 directories, 0 files

 

Delete directory:

[Root @ server55 ~] # Rmdir

Only empty directories can be deleted.

 

Move files:

[Root @ server55 ~] # Target path of the mv source file

Eg:

X moves to./a/y in the relative path. x indicates that directory y is not a directory file and cannot be overwritten.

[Root @ server55 a] # touch y

[Root @ server55 ~] # Mkdir x

[Root @ server55 ~] # Mv x./a/y

Mv: cannot overwrite non-directory './a/Y' with directory 'X'

 

Music videos can be summarized as follows:

File → directory to enter this directory

Directory → directory, as shown in this directory

File → The File prompts whether to overwrite (root default mv = mv-v, mv-f will not prompt overwrite information)

Directory → File system error

 

File Replication:

[Root @ server55 ~] # Cp + options + parameters

-P is copied to the new directory together with the attributes of the file.

-R,-R recursively copy the content of the recursive copy sub-directory

-I overwrite prompt

-A =-prd

The basic summary of cp is as follows: (the file directory cannot be cp directly)

Directory → directory, as shown in this directory

File → indicates whether to overwrite the file (cp: overwrite 'xxxx '?, Root cp = cp-v by default, cp-f does not prompt to overwrite information)

File → directory error (xxxx: Not a directory)

Directory → file error (cp: cannot overwrite non-directory 'C' with directory 'A ')

 

[Root @ server55 ~] # Mv a B c d

3 abc files are moved to the d Directory (Note that d must be a directory at this time; otherwise, an error is reported)

 

[Root @ server55 ~] # Mv a B

Using the mv command in the same path is considered as renaming a file.

 

View the three time attributes of the file:

[Root @ server55 ~] # Stat

File: 'A'

Size: 4096 Blocks: 16 IO Block: 4096 directory

Device: fd00h/64768d Inode: 1110922 Links: 3

Access: (0755/drwxr-xr-x) Uid: (0/root) Gid: (0/root)

Access: 21:53:12. 000000000 + 0800

Modify: 21:49:46. 000000000 + 0800

Change: 21:49:46. 000000000 + 0800

 

Atime: The Last access time;

Mtime: The last time the content was modified;

Ctime: the last attribute change time. (Permission and other attribute changes, and basic atime mtime changes will cause ctime changes)

 

Modify the Mtime and Atime of the file:

[Root @ server55 ~] # Touch + option + file name

-A sets the current system time to atime;

-M: set the current system time to mtime.

-T + time [CC] YY] MMDDhhmm [. ss] use custom time to modify atime + mtime at the same time

 

File deletion:

[Root @ server55 ~] # Rm + option + file

-I ask before deletion (root user rm = rm-I by default)

-R,-R recursively delete recursive delete all contents in the directory

-F force delete: force is not asked before deletion

Eg:

[Root @ server55 ~] # Rm-rf/surprise when you enter this command!

 

Change the directory ChangeDirectory:

[Root @ server55 ~] # Cd

[Root @ server55 ~] # Cd ~ The above two items are directly returned to the home directory

[Root @ server55 ~] # Cd .. go back to the upper level

[Root @ server55 ~] # Cd-back, similar to "back" of the TV remote control"

Eg:

[Root @ server55 ~] # Cd-

/Etc/sysconfig return to the previous Directory

[Root @ server55 sysconfig] # cd-

/Root returns to the home directory again

[Root @ server55 ~] # Cd-

/Etc/sysconfig return to the previous directory again

 

Display the current directory:

[Root @ server55 sysconfig] # pwd

/Etc/sysconfig

 

Common level-1 directories and functions:

/Bin

Bin is a binary file that can be directly executed. Commands under/bin can be used by the root and general accounts, including common commands such as cat, chmod, chown, date, mv, mkdir, cp, and bash.

/Boot

This directory is mainly used to store the files available for use, including Linux core files, boot menus, and boot settings. The common file name of Linux kernel is vmlinuz. if grub is used as the boot management program, the directory/boot/grub/will still exist.

/Dev

In Linux, any device or interface device is stored in this directory as an archive. You only need to access a file under this directory to access a device.

/Etc

The main configuration files of the system are almost stored in this directory, such as the personnel account and password files and various service start files. In general, the file attributes under this directory can be viewed by general users, but only root has the right to modify them.

/Home

This is the default home directory ). When you add a general user account, the preset user's home directory will be standardized here.

/Lib

System library files, while/lib is placed in the library files that will be used at startup, and commands under/bin or/sbin will call the library files, library files cannot be executed directly.

/Media

/Mnt

Floppy disks, CDs, DVDs, and other devices are temporarily mounted here. common file names include:/media/floppy,/media/cdrom, and so on. If you want to temporarily mount some additional devices, you can place them in this directory. The purpose of this directory is the same as that of/media, but after/media is available, this directory is used for temporary mounting.

/Usr

Third-party software help information after installation.

/Opt

This is the directory for third-party software installation. Eg: Oracle, etc.

/Root

The home directory of the system administrator (root.

/Sbin

Only the root user can call the executed commands. other users can only use the commands for "query" at most. Put it under/sbin as needed during the boot process, including instructions required for starting, repairing, and restoring the system.

/Srv

Srv can be abbreviated as a service. it is the data directory that needs to be accessed after some network services are started.

/Tmp

This is where the general user or the program being executed temporarily places the file.

/Proc

Files generated by programs that are being executed in the kernel.

/Sys

System generation and hardware information ing in the kernel are often used for system tuning.

/Var

Frequently-changed documents, user's mail queue, and print queue files.

 

 

This article is from "Welcome Amigo !" Blog

 

Related Article

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.