Previous words
This article will detail Linux common operations
Basic concepts
Linux is strictly case-sensitive, and all content is saved as files, including hardware
Linux does not have the concept of extension, and does not differentiate file types by extension. But there are some conventional extensions
Zip package:. gz. bz2. tar.bz2. tgz binary package:. RPM Web file:. html. php script file:. SH profile:. conf
[Note that programs under]windows cannot be installed and run directly in Linux
The advantages of the Linux character interface are as follows:
1. Less system resources are consumed
2, reduce the possibility of error, attack
"Partition Type"
Primary partition: Can only have up to 4
Extended partition: Up to 1, primary partition plus extended partition up to 4, cannot write data, only logical partition
"Hardware settings file name"
Hardware /dev/hd[a-d]scsi/sata/usb HDD/dev/sd[a-p] Optical drive /dev/cdrom or/dev/hdc floppy disk /dev/fd[ 0-1] Printer (25-pin )/dev/1p[0-2] Printer (USB )/dev/ usb/1p[0-[] mouse /dev/mouse
"Mount"
must partition / (root partition) swap partition (swap partition, memory twice times, not more than 2GB) recommended partition /boot (boot partition, 200MB)
Show
"Start Identification"
[Email protected] ~]#
Root indicates that the current logged on user is an administrator
Bogon indicates host name
~ Indicates the current directory
#是管理员的提示符
$ is a prompt for ordinary users
"Command Format"
When there are multiple options, you can write them together
Options include simplified options and full selection such as-a equals--all
command [options] [parameters]
[Note] Individual command use does not follow this format
File
"File Type"
Linux includes the following 7 file types, which represent the file type as the first bit of the file bit
- file D directory l soft link file
In addition to the above 3 types, there are block device files, character device files, socket files, and pipe files. These 4 files are special files in the Linux system.
"File Identity"
The file bit consists of 10 bits, except that the 1th bit represents the file type, and the last 9 bits are a group of 3 bits each, representing the owner of the file, the owning group, and others.
"File Permissions"
R Read W write X Execute
In the following example, this is a file, the owner has read and write permissions, and the owning group and others have only Read permissions
"File Information"
In the above example, after two root, the code file size, the last time the file was modified, and the file name
[Note that the file name in the]linux is a hidden file.
"Common level of directory role"
/ root directory /Bin Storage System command //usr system resource Save directory containing applications that do not normally need to be modified, command program files, libraries, manuals, and other documents /usr/ /usr/sbin Storing system commands that only administrators can perform
//
/lib Store Function Library
Home directory for user files, where user data is stored in this directory
/root Administrator's Home directory
/mnt empty directory, storage temporary mapping file system, often the floppy disk drive and CD-ROM mounted in the floppy and CDROM sub-directories here
/media empty directory, storing temporary mapping file system, old Linux no this directory
/misc empty directory, storing temporary mapping file system, old Linux no this directory /
/sys cannot operate directly, storing stored process and system Information
/
/var contains frequently changing files generated by the system
Shutdown
Shutdown
"Shutdown"
shutdown [Options] time options: -C: Cancel the previous shutdown command -H : Shutdown -r: Restart
Shutdown-h now immediately shuts down the machine
"Other shutdown Commands"
0
"Other restart command"
6
"Run Level"
The operating level of the system includes the following 7
0 turn off the machine 1 single user, Safe mode 2 not fully multi-user, no NFS service included 3 full multi-user 4 Not assigned 5 Graphical Interface 6 Restart
cat/etc/inittab# Modify system default Run level ID:3: initdefault:runlevel# query system RunLevel
Login
"View logged in user information"
"Sign Out"
Logout
"Who"
"Querying user information for current login and past logins"
"View last logon time for all users"
Shell
The shell is a command-line interpreter that provides users with an interface system-level program that sends a request to the Linux kernel to run the program, allowing the user to start, suspend, stop, or even write programs with the shell.
The shell is also a very powerful programming language, easy to write, easy to debug, flexible. The shell is the scripting language that interprets execution, and you can call Linux system commands directly in the shell
"Syntax Type"
Bourne Shell: The main file name is sh syntax type: sh, ksh, Bash, PSH, ZSHC Shell : mainly in the BSD version of UNIX systems using the syntax type: csh, tcsh
"View the shell type of the current system"
"Edit Script"
VI hellp.sh
"Exit Script"
After editing in Vim, press ESC, go back to normal mode, and then enter ": Wq" and return to execute
"Script Execution"
1, give the executive permission to run directly
755 hello.sh. /hello.sh
2, or, you can execute the script via bash call
Bash hello.sh
Vim
Vim is an editor in a Linux system, similar to Notepad in a Windows system
"Operating Mode"
There are three modes of the VIM editor:
1, Command mode (waiting for user input command)
2. Input mode (waits for the user to enter content into the text)
3, the bottom line mode (can enter some instructions)
Vim abc.sh Open or create and open a abc.sh file
I
After entering vim, Vim enters the command mode, then tapping the i key, can switch the command mode to the input mode, then can enter the content
Esc
After the input is completed, the ESC key can be switched to the input mode to the bottom line mode, enter: Wq to save the exit
"Command Format"
Vim + abc.sh Position the cursor to the last line of the file after opening the file
Vim +3 abc.sh position the cursor to the third line of the file after opening the file
Vim +/123 abc.sh after opening the file, position the cursor to the first occurrence of the 123 line, after entering the file, you can press the N key to make the cursor in more than 123 switch
"Common directives"
1, the bottom line mode
: w save : Q exit :! Enforcement : LS lists all files opened in the current editor : N switches to the next file: n switches to the previous file : cursor quickly navigates to 15 rows /XXX Search backwards from the cursor position for the first line of xxx ? XXX starts from the cursor position to search for the first time the line of XXX appears
2. Command mode
h Cursor Move left j cursor down k cursor up l cursor right shift Ctrl+F Page Down ( Front) Ctrl+b page up (back) Ctrl+D turn down half-pages (down) Ctrl+U up half page (UP) DD Delete cursor line o insert a row below the line of the cursor and switch to the input mode yy the line where the copy cursor is located p Paste P below the line of the cursor paste above the line where the cursor is located
Input/Output
"Output redirection"
"Input redirection"
WC [Options] [file name] options :- C Statistics bytes -W statistical number of words -l count rows
Command < file to input the file as a command
Command << identifier Enter the contents of the identifier as a command
Common Linux Operations