Basic Linux and basic linux
I. Introduction to Linux
1. Linux system definition: Linux is a free-of-charge and freely-spread Unix-like operating system. It is a POSIX and UNIX-based operating system with multiple users, multi-tasking, multi-thread and multi-CPU support.
2. the Linux system runs stably and is mainly used for servers.
3. Linux users are divided:
A. System User root: prompt #
B. normal user: prompt $
Su command: switch user
Exit command: exit A Common User
4. Linux terminal: a Linux terminal is also called a virtual console. Linux uses command lines to control the system by entering commands on the keyboard.
5. Linux provides 6 virtual terminals, Ctrl + Alt + F [1-6] to switch between different virtual terminals
6. Shut down the Linux system command: init 0 or shutdown-h now
Ii. Basic Linux operations
1. Linux command syntax format
Command [Option] [parameter]
Command: Tell the Linux system what operations to perform
[Option]: How to run the command. The option section starts with "-". Optional
[Parameter]: The object operated by a command, usually a file or directory. Optional
For example, ls-l/home # view the details of all files or directories in/home.
2. Common commands
A. whoami command: displays the users currently using Linux.
For example, the current user is a root user.
B. who command: displays which users are working on Linux.
C. date command: view system time
Modify system time: date "month, day, and year"
For example, change the system time to, January 1, August 26, 2018.
Extended: hwclock command
-S parameter: synchronize time to hardware
-W parameter: synchronize time to the System
D. cal command: View calendar
Example: view the month
E. clear command: clear screen, shortcut key Ctrl + l
F. su command: switch from current user to specified user
For example, switch from the root user to the heilong user.
G. passwd command: Change User Password
For example, modify the heilong user password.
H. man command: View command instructions. There are two methods: man command or command -- help
Example: view the ls command instructions
Man ls or ls -- help
I. useradd command: create a user
For example, if you create a tom user, the home directory of the tom user will be created under/home.
3. browsing, management and maintenance of directory files
1. Linux File System Tree Structure
In Linux, all files or directories are organized into an inverted tree structure starting with the root node.
The top-level root directory is expressed "/".
Two special directories in Linux: "." indicates the current directory, and "..." indicates the upper-level directory.
2. absolute and relative paths
Absolute path: it must start with a forward slash. The absolute path includes the name of each directory that must be traversed from the root node of the file system to the object to be searched (directory or file). It is the complete path of the file location, therefore, you can use the absolute path to find the desired file in any situation.
Relative Path: it does not start with a forward slash (/). The relative path can contain the name of each directory that must be traversed from the current object to the object (directory or file) to be searched.
3. directory file operation commands
A. pwd command: displays the current directory
B. cd command: Switch the current working directory
Cd or cd ~ : Directly return to the home directory of the current user
Cd.: returns the current directory.
Cd ..: return to the previous directory
Cd-: returns the last working directory of the user.
D. ls command: view the content in the current working directory
Ls-l: View Details of all contents in the current working directory
Ls-a: view all contents in the current working directory, including hidden files or directories. Note: Files starting with "." in Linux are hidden files or directories.
E. cp command: copy the file or directory from the Source Path to the target path
For example, copy the/root/a.txt file to the/home/heilong/directory.
Add-r option: recursively copy directories, including all directories or files under the Directory
For example, copy all files or directories in/etc to/home/heilong.
F. mv command: Move the file or directory from the Source Path to the target path
Example: Move the Python-3.5.2.tgz and Python-3.5.2 under/root/to/home/heilong
Mv command rename File
For example, rename the/home/heilong/a.txt file as heilong.txt.
G and mkdir commands: create a directory
For example, create another directory named heilong under the/home/heilong directory.
Mkdir-p: recursively create a directory
For example, create dir1/dir2/dir3 in/home/heilong.
H. touch command: Create an empty file or multiple Empty files at the same time
For example, create an empty file named new.txt under/home/heilong /.
I. rm command: Permanently delete files or directories under the Directory
-R option: delete a directory and recursively delete all files or directories under the Directory
-F option: Force Execution. Users are not asked before deletion.
Example: delete heilong.txt and/home/heilong/Python-3.5.2/Under/home/heilong/
G. cat command: View File Content
For example, view the content of the/home/heilong/new.txt file.
H. head command: the first 10 lines of file content are displayed by default.
-N: n indicates the specified number of rows.
For example, the first three lines of the/home/heilong/new.txt file are displayed.
I. tail command: the last 10 lines of file content are displayed by default.
For example, the last three lines in the/home/heilong/new.txt file are displayed.
J. more command: After the more command is used, each time a screen (one page) of file content is displayed on the screen, "-More -- (n %)" information will appear at the end of the screen, where n % is the file already displayed
Content percentage. The carriage return is displayed row by row, and the space is displayed on screen.
K. less command: the usage of less is more flexible than that of more. At the time of more, we could not flip forward, but we could only look at it later. However, if less is used, you can use the [pageup] [pagedown] and other buttons to access and view the file, making it easier to view the content of a file! In addition, you can have more search functions in less. You can not only search down, but also search up.