Strictly speaking, Linux is not an operating system, but a kernel in the Linux system, which is the platform for communication between computer software and hardware.
Some organizations or manufacturers integrate the Linux kernel with GNU software (system software and tools), and provide some installation interfaces and system setting and management tools, thus forming a hair package, such as Ubuntu、Red Hat、Centos、Fedora、SUSE、Debian、FreeBSD
etc.
Features of Linux
Openness: The system follows standard specifications, especially the Open Systems Interconnection (OSI) international standard.
Multi-user, multi-tasking: Multi-user means that system resources can be used by different users. Each user can have independent permissions on the resources of his own system without affecting each other. Multitasking means that the operating system can run multiple programs at the same time, and each program can run independently without interfering with each other.
Good user interface: Linux provides two interfaces to users: user interface and system calls. Linux also provides users with a graphical user interface. It uses facilities such as the mouse, menus, windows, and scroll bars to present users with a friendly graphical interface that is intuitive, easy to operate, and highly interactive.
Device independence: The operating system treats all external devices as files. As long as the driver is installed, any user can manipulate and use these devices just like files. Linux is a device-independent operating system with a highly adaptable kernel.
Strong portability: The so-called portability refers to the ability to cross from one platform to another. Linux is a highly portable operating system. When the system is moved from one platform to other platforms, it can still run stably without any modifications to the system. That is to say, whether it is a handheld computer, a personal computer, or a minicomputer, Medium-sized machines, even mainframes, can run this system.
High security : Linux has adopted many security technical measures, including read and write control, protected subsystems, audit trails, core authorization, etc., which provide necessary security guarantees for users in multi-user network environments.
High stability : The source code of the Linux kernel is optimized for standard 32-bit (64-bit on 64-bit CPU) computers, ensuring the stability of the system. It is precisely because of the stability of Linux that some hosts with Linux installed on them can be left on all year round without any downtime, just like Unix machines.
Rich network functions: Complete built-in network is a major feature of Linux. Linux is superior to other operating systems in terms of communication and network functions. Other operating systems do not include the ability to connect to networks so tightly integrated into the kernel, nor do they have the flexibility to have these networking features built into them. Linux provides users with complete and powerful network functions.
Good portability: The ability to move an operating system from one platform to another so that it still runs in its own way. Linux is a portable operating system capable of running in any environment and on any platform, from microcomputers to mainframe computers.
File Directory
linux
-
/bin
It is the abbreviation of Binaries (binary file). The storage directory of traditional unix commands such as ls, rm, mv, etc. -
/dev
Device file storage directory. -
/boot
Stored here are some core files used when starting Linux, including some connection files and image files. -
/etc
Configuration file storage directory, such as user password file /etc/passwd, this directory is actually a link to /private/etc. -
/home
The user's home directory. In Linux, each user has his own directory. Generally, the directory name is named after the user's account. -
/sbin
Contains superuser (root) executable files, such as fdisk, ifconfig, etc. -
/usr
It is the abbreviation of Unix shared resources (shared resources). This is a very important directory. Many user applications and files are placed in this directory, similar to the program files directory under Windows.The shared library dynamic link library is stored in the /usr/lib directory.
/usr/bin Applications used by system users.
/usr/sbin More advanced management programs and system daemons used by super users.
/usr/src : The default directory where the kernel source code is placed
-
/tmp
The temporary file storage directory has permissions for everyone to read and write. This directory is actually a link to /private/tmp. -
/var
Store frequently changing files, such as log files. This directory is actually a link to /private/var. -
/opt
Normally this folder is used to store installation packages, such as homebrew
Mac
-
/Applications
Application directory, all GUI applications are installed here by default, such as WeChat, QQ, etc. -
/Library
System data files, help files, documents, etc. -
/Network
Network node storage directory. -
/System
Contains most system configuration and operating system files. -
/Users
Store user's personal information and configuration, each user has its own separate directory. -
/Volumes
File system mount point storage directory. -
/cores
The directory where kernel dump files are stored. When a process crashes, a dump file will be generated if the system allows it. -
/private
The subdirectories inside store the target directories of /tmp, /var, /etc and other link directories.
File Permissions
There are three different types of users who operate files or directories: file owners, group users, and other users. The highest bit represents the permission value of the file owner, the middle bit represents the permission value of the group user, and the lowest bit represents the permission value of other users.
permissions | permission value | binary | introduce |
---|---|---|---|
r | 4 | 00000100 | read, read. The current user can read the file contents, and the current user can browse the directory. |
w | 2 | 00000010 | write, write. The current user can add or modify file contents, and the current user can delete or move directories or files within directories. |
x | 1 | 00000001 | execute, execute. The current user can execute files and the current user can enter directories. |
Then all the permissions are as follows
# | permissions | rwx | binary |
---|---|---|---|
7 | Read+Write+Execute | rwx | 111 |
6 | read + write | rw- | 110 |
5 | Read+Execute | r-x | 101 |
4 | read only | r– | 100 |
3 | write + execute | -wx | 011 |
2 | just write | -w- | 010 |
1 | Execute only | –x | 001 |
0 | none | — | 000 |
chmod 777 demo.txt
chmod -R 777 demo // -R表示为所有 demo目录下的文件夹和文件
sudo chmod -R 777 demo // 如果是 ubuntu,需要加sudo
ssh
SSH is a network protocol used for encrypted logins between computers. If a user logs in to another remote computer from the local computer using the SSH protocol, we can think that this login is safe. Even if it is intercepted halfway, the password will not be leaked. SSH is just a protocol, and there are many open source implementations. , such as openssh , mac has built-in ssh.
ssh -p 2222 user@host
ssh-keygen
Generate, manage and convert authentication keys for ssh. The ssh-keygen command is used to generate, manage and convert authentication keys for "ssh". It supports both RSA and DSA authentication keys. SSH keys are kept in ~/.ssh
the directory by default, if this directory does not exist, the ssh-keygen command will create one with the correct permissions.
-b: Specify the key length;
-e: Read the private key or public key file of openssh;
-C: add comments;
-f: specifies the file name used to save the key;
-i: Read the unencrypted ssh-v2 compatible private key/public key file, and then display the openssh compatible private key/public key on the standard output device;
-l: Display the fingerprint data of the public key file;
-N: provide a new passphrase;
-P: provide the (old) passphrase;
-q: silent mode;
-t: Specifies the type of key to create.
ssh-keygen -t rsa -C '[email protected]' -f ~/.ssh/github_id_rsa
file transfer
scp command, also known as secure copy, can copy files and directories across machines, based on SSH
scp local_file remote_username@remote_ip:remote_file
file transfer protocol
The FTP protocol (File Transfer Protocol) is based on the TCP protocol to transfer files. It transmits user information and data in clear text. The default port is 21.
SFTP (Secure File Transfer Protocol), default port 22.
The SFTP protocol can perform operations such as "remote file acquisition, file content transmission, and file management". Its control signals and data signals are transmitted through secure data channels. Generally, this secure data channel is provided by an SSH connection, that is, the SSH connection tunnel serves as a secure data channel.
Compared with the SCP protocol, which can only transfer simple file content, the SFTP protocol is more like a remote file system protocol.
The SFTP protocol is divided into two ends, namely SFTP Client and SFTP Server. The transmission of control signals and file contents between SFTP Client and SFTP Server must be carried out through a secure data channel. The secure data channel can be provided by protocols such as "Transport Layer Security (TLS)" and "SSH". Generally, it is provided by the SSH protocol. .
Once the connection between the SFTP Client and the SFTP Server is established, the remote file system function can be realized through the transmission of control signals and file contents between the two.
GUI tools, Windows has filezilla, macos has cyberduck (little yellow duck).
Common commands
// 查找文件
find /opt -name "nginx.conf"
// 显示所有进程
ps -A
// 杀死进程
kill 12345
// 带行号显示文件内容
cat -n demo.txt
// 显示前2行
head -n 2 keyboard.txt
// 显示后2行
tail -n 2 keyboard.txt
// 寻找程序位置
which nginx
// 3dd 删除3行
vim data.txt
// 打包文件
tar -czvf demo.tar.gz ./demos
References
https://blog.csdn.net/words8/article/details/113066602