Operating System Overview
Linux operating system installation
Linux File System
Linux command operations
Linux Permission Management
Linux process management
Linux Other commonly used commands
Linux system software installation
Operating System Operating System, referred to as OS, is a piece of software in layman’s terms, but it is different from general software. The operating system is a computer program that manages and controls computer hardware and software resources. It is the most basic program that runs directly on "bare metal". System software, any other software must be supported by the operating system to run.
For information on Linux installation, read this article - Linux installation tutorial
“
- https://blog.csdn.net/huaijiu123/article/details/82083452
”
/var
: Contains files, spool files, log files, locked files, temporary files, page format files, etc. that are changed during normal operations. /home
: Contains user files: parameter setting files, personalized files, documents, data, EMALL, cached data, etc. Each time a user is added, the system will create a new and new file in the home directory based on its user name. A folder with the same name as other users to save their user configuration. /proc
: Contains phantom files. They do not actually exist on the disk and do not occupy any space (use ls-l to display their size). When viewing these files, they are actually Access information stored in memory that is used to access the system. /bin
: Contains executable files (binary) required when the system starts. These files can be used by ordinary users. /etc
: The configuration file directory of the operating system (firewall, startup items) /root
: is the home directory of the system administrator (also called super user or root user). /dev
: is the device directory. Devices under Linux are treated as files. In this way, the hardware is abstracted, convenient for reading and writing, network sharing, and needs to be temporarily loaded into the file system. Under normal circumstances, the device will have A separate subdirectory. The contents of these devices will appear in a separate subdirectory. View current directory command: **pwd
**
Open folder command: **cd
**
cd [directory name]
cd ~
cd …
cd -
cd /
Browse the file list command in the directory: **ls
**
ls -l
ls -a
ls -la
Create file directory command: **mkdir
**
mkdir Folder name
mkdir -p folder name
mkdir -p test/test1/test2/test3
How to recursively create a multi-level directoryDelete file directory command: **rmkdir
**
rmkdir directory name
rmdir -p directory name
There is no typo here, there is no letter kDelete file or directory command: **rm
**
rm -rf [directory or file]
rm -ri [directory or file]
rm -rf directory or file
rm -ri directory or file
“
Because the consequences of forced deletion are not very good, it is generally not recommended to use
rm -rf
to delete filesIf the r parameter is not followed by the rm command, the directory cannot be deleted, only the files can be deleted
”
Copy file or directory command: **cp
**
cp -r [directory 1][directory 2]
cp -ri [directory 1][directory 2]
Commands to move files and modify file names: **mv
**
mv file 1 file 2
(rename the file) mv directory 2 directory 2
(Move the files in directory 1 to directory 2)Create file command: **touch
**
View and edit file commands: **vi
**
The three modes of vi are as follows:
When the user uses the vi command to open a file, it enters the command mode, and the user can enter commands to perform various functions.
If the user wants to modify the file, he can use the following commands to enter the input mode. After the user enters the input mode, he can modify the file at will. Except for the Esc key, any characters entered by the user will be treated as The content is written into the file, and the user can perform related operations on the file by inputting Esc.
If the user completes the editing command, he can press esc ":" to enter the last line mode. The user can continue to search the file content, or enter ":wq!" to save the file and exit, or enter " :q!" Force quit file editing.
View and edit file commands: **cat
**
cat file name
cat > File Name
View the content at the beginning of the file Command: **head
**
head [parameter] [file name]
For example, use the head command to display the n lines of data starting from a file: head -n file name
View the end of file content command: **tail
**
tail -f file name
tail -n line number file name
“
Linux Permission Management
”
User refers to a collection of a series of permissions in an operating system. Operators can perform certain permitted operations in the system through user names and passwords. Different users can have different permissions. Each user in the Linux operating system has a unique identification UID. When using a command to create a user, if the user's UID is not specified, the system will automatically assign it a UID.
A user group is a collection of users with the same characteristics. In the Linux system, each user belongs to at least one user group. Each user group in the Linux operating system has a unique identifier GID. When using the command to create a user group, if the GID of the user group is not specified, the system will automatically assign it a GID. When using -u to specify a user ID, the user ID should be greater than 500 to avoid conflicts. Because after the Linux operating system is installed, some users will be created by default, so ID numbers within 500 may be occupied.
Linux permission mechanism has the following characteristics:
Switch user command: **su
**
su [username]
or su -[username]
su[username]
and su -[username]
can switch users. The former is similar to temporarily switching users. When using this command to switch to a new user, the user configuration will still be used. Original user configuration, such as environment variables, system variables, etc. When the latter switches users, the environment variables and system settings are all switched to the user configuration of the new user. View the current logged in user command: **whoami
**
View the group command to which the current user belongs: **groups
**
View current user UID and GID command: **id
**
Add new user command: **useradd
**
Add a user in the Linux operating system: useradd username
Add a user in the Linux operating system and specify the user UID: useradd -u
Specified UID user name
passwd
**For example: Modify the password of the current user named sang: passwd sang
After adding a user, the user can log in only if a password is set for him
Delete user command: **userdel
**
userdel username
userdel -r username
Modify user information command: **usermod
**
usermod [options] [parameters] [username]
usermod -l new username old username
usermod -g new group name user name
Add user group command: **groupadd
**
groupadd [options] [group name]
groupadd group name
groupadd -g group GID group name
The Linux operating system defines three permissions for files: read, write, and execute. Different users or user groups can have different permissions. The system uses "r", "w", and "x" to represent file reading respectively. , write, and execute permissions. Use the ls -l command to view the user's operation permissions on the current directory or file.
List:
drwxr -xr -x. 2 root root 4096 Sep 23 2011 bin
means the following meanings from left to right:
d
:代表 bin 数目目录而不是文件rwx
:代表拥有者具有读、写、执行的权限r -x
:代表同组用户具有读、执行的权限,但是没有写权限r -x
:代表其他组用户具有读、执行权限,没有写权限常用的变更权限命令为:chmod
语法:chmod [选项] [参数]
chmod 的参数可以分为两种,分别是权限模式和数字模式。
权限模式:
权限模式使用 u、g、o 分别代表拥有者、同组用户、其他组用户,使用 + 和一代表赋予和收回权限,使用 r、w、x 代表读、写、执行权限。
例如:将文件01的执行权限给当前用户,写权限赋给用户所在的用户组和其他用户。
chmod -r U+X,G+W F01
例如:将文件 f01 的读、写、执行的权限赋给当前用户,将读、写权限赋给用户所在的用户组和其他用户。
chmod -r u=rwx,g=rw,o=rw f01
数字模式:
为了简化授权步骤,用户也可以采用数字模式进行授权,使用二进制的形式代表 r、w、x 三种权限,如 101 (5) =r -x
,111 (7) =rwx
,100 (3) =r- -
例如:将文件 f01 的读、写、执行的权限赋给当前用户,将读和执行权限赋给用户组、将写和执行权限赋给其他用户。
chmod 753 -r f01
例如:将文件 f01 的读、写、执行权限赋给所有用户。
chmod 777 -r f01
在 Linux 的应用中,我们需要对进程进行管理,如查看某个进程是否启动、以及在必要的时刻,杀掉某个线程。
ps 命令是 Linux 操作系统中查看进程的命令,通过 ps 命令我们可以查看 Linux 操作系统中正在运行的过程,并可以获得进程的 PID(进程的唯一标识),通过 PID 可以对进程进行相应的管理。
ps -ef | grep [进程关键字]
根据进程关键词查看进程命令显示如下,显示的进程列表中第一列表示开启进程的用户,第二列表示进程唯一标识 PID,第三列表示父进程 PPID,第四列表示 CPU 占用资源比列,最后一列表示进程所执行程序的具体位置。
[shang@localhost ~]$ ps -ef|grep sshd root 1829 1 0 May24 ? 00:00:00 /usr/sbin/sshd shang 24166 24100 0 20:17 pts/2 00:00:00 grep sshd [shang@localhost ~]$
当系统中有进程进入死循环,或者需要被关闭时,我们可以使用 kill 命令对其关闭。
kill -9 [PID]
PID 为 Linux 操作系统中进程的标识
service sshd start
service sshd restart
service sshd stop
Linux is a remote server in most cases. Developers connect to Linux through remote tools and start the JAR of a certain project. Once the window is closed, the JAR stops running. Therefore, the JAR is generally started through the following command. :nohup java -jar jar-0.0.1-SNAPSHOT.jar &
There is nohup here, which means that the service will not hang when the current window is closed and will continue to run in the background
There are three commonly used software installation methods under Linux.
Common commands for software installation
tar
tar [options] [compressed package]
tar -zxvf [package name]
tar -jxvf [package name]
tar -xvf [package name]
Installation and uninstallation command: rpm
rpm [options] [package]
rpm -qa|grep [package keyword]
rpm -e Full name of software package
rpm -ivh package path
The above is the detailed content of The most commonly used Linux commands: can solve more than 95% of problems. For more information, please follow other related articles on the PHP Chinese website!