Home > Article > Operation and Maintenance > what is linux os
In Linux, OS refers to the operating system, which is a computer program that manages and controls computer hardware and software resources. It is the most basic system software that runs directly on the "bare metal". Any other software must be It can only run with the support of the operating system. The reason why OS exists: A pure hardware computer is extremely inefficient and difficult to operate.
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
Foreword: Learning OS (operating system) is very important. Learning the operating system here starts with Linux.
Linux is operated by instructions and is closer to the OS, making it easier for us to master the OS. When learning C, you generally work more on the backend, and Linux is very important for those who want to work on the backend. There is a high probability that LInux is the OS for work.
The operating system (Operating System, referred to as OS) is a computer program that manages and controls computer hardware and software resources. The most basic system software that runs directly on "bare metal". Any other software must be supported by the operating system to run.
The reason why OS exists: A pure hardware computer is extremely inefficient and difficult to operate.
OS is a software that is used to manage software and hardware resources. The purpose of management is to improve operation efficiency by matching up and down.
Real life operating system
Because all operating systems support command operations at the beginning, and the graphical interface only came later, the command execution is closer to the OS, which makes it easier for us to better master the OS.
1.ls command(1)
Syntax: ls [option] [directory or file] (The directory or file is not written as the current directory) (2)
Function: For a directory, this command lists all subdirectories and files in the directory. For a file to be listed, the file name and other information will be listed.
(3)
Common options① Use ls directly to only subdirectories and files
② -l lists the detailed information of the file (can be written as
ls -l, can also be written as ll) ③ -a List all files in the directory, including those ending with
. Hidden files starting with Files starting with . are called hidden files. In any directory, there will be two hidden files
. (current path) .. (Superior path)④ -i Output the index information of the i node of the file
⑤ -n Use numeric UID and GID instead of the name
( 4)
Examplels -al
##2.pwd command
(1)Syntax
: pwd(2)Function
: Display the user’s current directoryThe path separator for Linux is: / (slash)
The path separator for Window is: \ (backslash) (3)Example
pwd
3.cd command
We generally locate a file and find the file through path positioning. So why do we locate files through paths?
The directory structure of Linux is essentially a multi-tree (1. Each child node can be either a directory (then put a directory or an ordinary file, recursively defined), or an ordinary file 2 . The leaf node of this multi-tree must be an ordinary file or empty directory) Therefore, any node can have multiple child nodes, but any child node has only one parent node. So conventional path positioning is unique (Absolute paths are unique
)In addition to relative paths, there are also absolute paths (relative to the current The path where it is located)
If it is for daily use, the relative path is recommended - simple
If it is adding a configuration file, the absolute path is recommended - no error(1)
Syntax
: cd [directory name](2)Function
: Change the working directory, change the current working directory to the specified directory . (Enter the input directory)(3) Common options
① cd .. Return to the upper-level directory (. is the current directory, .. is the upper-level directory)
② cd absolute path③ cd relative path④ cd - Return to the recently visited directory
⑤ cd ~ Enter the user’s home directory (/home/hb)
(4) Example
cd .. : Return to the upper directory
cd /home/hb/code : Absolute path
cd ../test : Relative path
cd - : Return to the recently visited directory
cd ~: Enter the user’s home directory
4.touch command
If we If an empty file is created, will it take up space on the disk?
The file to be occupied has attribute data, which is also data
File = file content file attribute
All the file operations we need to learn are nothing more than two categories:
①Operation on the content of the file
②Operation on the attributes of the file
(1)Syntax: touch [option][file]
( 2) Function : The touch command parameters can change the date and time of the document or directory, including access time and change time, or create a new file that does not exist,
(3) Common options
① Use touch directly to create a file
(4)Example
touch test.c
5.mkdir command
(1)Syntax: mkdir [option] [directory name]
(2)Function: Create a directory under the current directory
(3)Common options
-p [path name] Yes is a path name. If some directories in the path do not yet exist, after adding this option, the system will automatically create those directories that do not yet exist, that is, multiple directories can be created at one time
( 4) Example
mkdir dir: Create a directory
mkdir -p dir1/dir2/dir3: Create multiple directories recursively
6.rmdir command && rm command
rmdir is a command relative to mkdir, mkdir is to create a directory, and rmdir is to delete Directory
(1)Syntax:rmdir [option] [directory name]
(2)Function: Delete empty directory
(3)Common options
① -p When the subdirectory is deleted, if the parent directory also becomes an empty directory , delete the parent directory together
(4)Example
rmdir dir
rmdir -p dir
(1)Syntax: rm [option] [directory name]
(2)Function: Delete files or directories
(3)Common options
① Use rm directly to delete a file or directory (all files can be deleted, but only Can delete empty directories)
② -r Delete the directory and all files under it (can delete non-empty directories)
③ -f Forcefully delete files, even if the file attribute is read-only (i.e. Write protection)
④ -i Ask for confirmation one by one before deleting
(4)Example
rm dir: Delete directory
rm test: delete files
rm -r dir: delete all files in the directory
rm -rf dir: forcefully delete all files in the directory
rm -ir dir: Ask in sequence when deleting all files in the directory
* Wildcard: matches anything in the current directory
rm *: Delete all files in the current directory (equivalent to rm ./*)
./ Current directory: Inform the system that the resources to be accessed are in the current directory. If omitted, in some cases, the default is the current directory
7.man command
(1)Syntax: man [option] command
(2)Function: man is equivalent to an online manual. Linux commands have many parameters, and we cannot remember them all. At this time, you can use man to get help.
(3)Common options
① -k Search online help based on keywords
② man man You can search for related operations of man
③ Enter the corresponding number and search for different commands
man manual:
1 is a common command
2 is a system call, such as open (through this you can easily find out how to call this function and the required header file)
3 is a library function, such as printf
4 is a special file, that is, various device files under /dev
5 refers to the format of the file, such as password, which will describe the functions of each field in the file.
6 is reserved for games and is defined by each game.
7 is an attachment. And some variables, such as global variables like environ are explained here.
8 are commands for system management. These commands can only be used by root. For example, ifconfigman is equivalent to an online manual, a Linux command There are many parameters, and we can't remember them all. At this time, you can use man to get help.
(4)Example
man 1 ls
man 3 printf
8.cp command
(1)Syntax: cp [option] Source file or directory Target file or directory
(2) Function: Copy files or directories
(3)Common options
① Use cp directly to copy a file
② - r Recursive processing, copy files and subdirectories in the specified directory
③ -f Forced copy of files or directories, regardless of whether the destination file or directory already exists
④ -i Before overwriting Ask
(4)Example
cp file.txt file2.txt
cp -r dir1 dir2
cp -rf dir ..
##9.mv command
The mv command is the abbreviation of move and can be used to move files or Rename files, often used to back up files or directories. (1)Syntax : mv [option] Source file or directory Target file or directory
(2)Function :
Depending on the type of the second parameter in the mv command (whether it is a target file or a target directory), the mv command renames the file or moves it to a new directory. ①When the second parameter type is the source file (source directory), the mv command completes the file renaming. At this time, there can only be one source file, and it will rename the given source file or directory. For the given target file name②When the second parameter type is an existing directory name, there can be multiple source files or directory parameters, and the mv command will move all the source files specified by each parameter to (3)Common options in the target directory
① Directly use mv to move or rename a file or directory② -f If the target file Already exists, you will not be asked to overwrite it directly③ -i If the target file already exists, you will be asked whether to overwrite it(4)Example
mv file.txt a.txtmv file.txt ..mv dir1 dir2 dir
10.cat Command##(1)
Syntax:cat [option][file](2)
Function: View target Contents of the file(3)
Common options① -n Output line number
(4)
Examplecat file.txt
cat -n file.txt
Except cat, There is also tac, view from back to front
tac file.txtRedirect:
, similar to printf, output information to the monitor. For example: echo "hello world"
(1) Output redirectionCreate a file touch file.txt, and then you can pass
echo "hello world" > file.txt, so that the content that should be written to the display is written to the file (the content of the original file will be read and rewritten each time)
(2) Append redirectionecho "hello Linux" >> file.txt
, similar to the above output redirection, but here is Two>, and it will not clear the original content, but will write new content at the end of the original file
(3) Input redirectioncat , input redirection is to change the way data should be read from the keyboard file to read from the specified file
11.more command(1)
Syntax: more [option][file](2)
Function: The function is similar to cat, but you can manually scroll down (3)
Common options① -n output line number
② q Exit more
(4)
Examplemore file.txt
12.less command (1)
Syntax: less [option] File(2)
Function: Similar to cat and more, But the function is more powerful, you can turn up and down (less is generally used)(3)
Common options① -n Output line number ② q Exit less (4)Example 13.head command Syntax: head [option] [file] Function: Display the beginning of the file (the first 10 lines are displayed by default) Common options Example 14.tail command(1) : rm [option][file](2) : Display the beginning of the end (the last 10 lines are displayed by default)(3) ① -n (4) tail -20 file.txt ①Create a temporary file Through head -5030 file.txt > temp.txt, first get a temporary file, and then tail -30 temp.txt, we can see [5000 , 5030]. quite complicated. | This is the pipeline Write like this You can complete the viewing through the pipeline . 15.date command (time-related command) (1) : date [option] [format ](2) : Specify the format to display time or display timestamp(3) ① In the display, the user can set the format they want to display. The format is set to a mark followed by a mark. The list of commonly used marks is as follows: %M: Minutes %S: Seconds %X: Equivalent to %H:%M: %S ## %d: Day %m: Month %Y: Year %F: Equivalent to %Y-%m-%d ② Timestamp date %s Timestamp->Timedate -d@Timestamp The timestamp is the time since January 1, 1970 number of seconds, regardless of leap seconds Example date %Y-%m-%d_%H:%M:%S (1)Syntax :cl [Option] [Year] (2)Function: Display calendar (3)Commonly used options ① Direct use is the current month ② -3 Display the previous month, current month, and next month’s calendar ③ -y Display the current year’s annual calendar (4 ) cal -3 ##17.find command The find command searches for files in the directory structure and performs specified operations The find command under Linux provides quite a few search conditions and is very powerful. Because find has powerful functions, it also has many options. Syntax Function: used in the file tree Search for files in and perform corresponding processing (may access disk) Common options (4)Example find /usr/include/ -name stdio.h 18.grep command (1) Syntax : grep [option] Search string file Function : In Search for strings in the file and print out the found lines (use regular expression search) Common options ② -i Ignore the difference in case and treat upper and lower case as the same ④ -v Reverse printing, print out those lines that do not have the string you want to search for (4)Example grep 'hello ' file.txt grep -i 'HeLlo' file.txt grep -iv 'HeLlo' file.txt 19 .zip/unzip command ## 1.zip: Syntax:zip defines the compressed file name. zip [Directory or file] Function: Compress the directory or file into zip format Common options Example (1) : unzip compressed file(2) : Decompress( 3) ① Use unzip to decompress directly ② -d specifies which path to compress (4) unzip test.zip unzip test.zip -d /home 20.tar command (1) : tar [options] [file or directory](2) : Compression File or decompression(3) ① -c Create a compressed file ② -z Determine whether it has the gzip attribute, Do you need to use gzip compression? #⑤ -t View the files in the compressed package ⑥ -v Display the files during the compression process ⑦ -C Extract the files to the specified directory (4) tar xzf test.tgz -C /home // Decompress to the specified directory : bc [number] [symbol] [number] (2) Function : Calculator (3)Commonly used options ① Directly use bc to calculate (4) bc 1 2
22.uname command : uname [option] (2)Function: Used to obtain relevant information about the computer and operating system (can be used to display basic information such as the version of the operating system used by the Linux host, hardware name, etc.) (3)Common options ① -r Display kernel version② -a Output all information in detail, in order: kernel name, host name, kernel version number , kernel version, hardware name, processor type, hardware platform type, operating system name (4)Example
: Command auto-completion② Ctrl c: Terminate the runaway program ③ Ctrl d: Quickly exit the account ④ Ctrl r: Search history commands 24. Shutdown command (1) : shutdown [option](2)Function: Shutdown (3)Common options ① -h After stopping the system service, shut down immediately ② -r Restart the system after stopping the service ③ -t Add the number of seconds after -t to indicate how many seconds it will take to shut down the system( 4) 3. Shell command and operating principle 2. Function From a technical point of view, the simple definition of Shell: The command line interpreter includes: ①Translate the user's commands to the kernel for processing ②At the same time, the core processing results are translated to the user In Linux, the shell is the command line interpreter. In Window, the shell is the graphical interface The command line interpreter (shell) commonly used in centos 7 is called bash There are two kinds of users under Linux: ①Super user (root) ②Ordinary user ①Super user: can do anything under the Linux system, Unrestricted ②Ordinary users: Do limited things under Linux ③The command prompt of the super user is "#", and the command prompt of the ordinary user is "$" Command: su [user name] Function: Switch user To switch from a normal user to a root user, use su root Or su - , to switch from the root user to the ordinary user user, use su user Example: Related recommendations: "Linux Video Tutorial 》##less file.txt
Pipeline:
If we want to view the middle part of the file, such as a 10,000-line text, and we want to view the information of [5000, 5030] lines, what should we do?
date %s
##16.cal command
zip test.zip packagezip -r test.zip tar_packagezip -r test.zip -d tar_package
## 2. unzip
21.bc command
(1)
Syntax
(1)
Syntax23. Hotkey
①
Tab
1. Introduction
## Strictly speaking, Linux is an operating system, which we call the "kernel". However, ordinary users cannot use the kernel directly. Instead, it communicates with the kernel through the kernel's "shell" program, that is, the shell. (Shell is a shell program)
4.Linux permission concept
su -
su user
The above is the detailed content of what is linux os. For more information, please follow other related articles on the PHP Chinese website!