Features of Linux
-Free/Open source
-Multi-threaded/multi-user support
-Good safety
-Superior in memory and file management
shutdown Command
Shutdown-h now (shut down immediately) Shutdown-r now (restart the computer) reboot (restart the computer)
go to Desktop
StartX
User Login
log in as little as possible with the root account login, because it is the system administrator, the maximum permissions, unavoidable operation error. You can log in with a normal user, log in, and then use the "Su-" command to switch to system administrator status.
User Logoff
Enter logout at the prompt
Linux file system is a hierarchical tree directory structure , the top of this structure is the root directory "/", and then create another directory in this directory, a deep understanding of the Linux file directory is very important
- /
-Root, which holds the files of the root user
-Home, storing relevant files for ordinary users
-Bin, a directory of commonly used commands, such as Vi,su
-Sbin, you must have permission to use the command
-MNT, default mount directory for CD-ROM and floppy drive
-etc, storing the relevant files of the configuration
-Var, which stores frequently changing files, such as sock files for network connections
-Boot, store the boot system boot file
-usr, install the default directory for a software equivalent to the program files under Windows
Here are some of the more commonly used commands and how to use them:
pwd, showing which path is currently under
User Management for Linux
useradd user name, adding user
"Case" Useradd xiaoming
passwd user name, password for new user
"Case" passwd xiaoming, modify Xiaoming's password
Userdel user name, delete user
"Case" Userdel xiaoming, deleting the user but saving the user home directory
"Case" userdel‐xiaoming, deleting users and user home directories
logout, current user launch
Who am I, current user who
CD, change directory
ls, listing files and directories
Ls‐a, displays all files in the directory, including hidden files
ls‐l, display long list format
mkdir, creating a directory
rmdir, delete empty directory
Touchto create an empty file
cp, copy command
"Case" Cp‐r dir1 dir2, recursive copy command (copy subdirectory information)
mv, moving files and changing file names
rm, deleting files and directories
RM‐RF *, delete all content, including directories and files, R for recursion, F to force
Ln, creating a symbolic connection, similar to creating a shortcut to a file
ln‐s Source target
"Case" Ln‐s/etc/inittab inittab,inittab pointing to the actual file/etc/inittab Inittab
More, show file contents with paging, CTRL + PAGE UP, Sky grid down
Less, display file contents with pagination
grep, querying for content in text
"Case" assumes that there is a file test.cpp with the Hello keyword, you can use the grep name command to find, grep n "Hello" test.cpp,n indicates that the nth row appears
|, Pipeline command, on Linux and UNIX systems, give the result of the previous command to | command processing
"Case" ls‐l/etc/| More
Man [command], Helper, similar to help in DOS
Find, search for files and directories. In Linux, because file systems are composed of hierarchical structures, it is not easy to find specific files and directories throughout the system. and the "Find" command solves the above problem
search for and display files and directories of the specified name in a specific directory
"Case" Find/-name man: Meaning to start searching for a file or directory named man from the root directory
Search for files or directories that have been accessed/changed over time
"Case" find/home-amin-10: Files or directories accessed within 10 minutes
"Case" find/home-atime-10: Files or directories accessed within 10 hours
"Case" FIND/HOME-CMIN-10: Changed files or directories within 10 minutes
"Case" Find/home-ctime + 10: Changed files or directories 10 hours ago
Search for files of a specified size
"Case" find/home-size +10k: Meaning to find files of size 10k in the/home directory
REDIRECT command
ls-l > A.txt, the contents of the list are written to the file A.txt (overwrite write)
Ls-al >> Aa.txt, the contents of the list are appended to the end of the file Aa.txt
Enter information from the file: Database_program < Database_data
En, view environment variables
Compression and decompression
Processing. zip files in zip and unzip
Basic use of the zip command
Zip File.zip *:zip After the compressed file name, enter the file to be compressed after it
Automatically delete the original file after compression
"Case" Zip m file.zip to.txt: to.txt files are compressed into file.zip files, To.txt will be automatically deleted
To compress subdirectories together
"Case" zip‐r file.zip *: Compress subdirectories in the current directory together
Ignore contents of subdirectories
"Case" zip‐j file.zip *
Remove compressed or unnecessary compressed files
"Case" zip‐n. mpg:. jpg:. gif: The middle of the first file is separated by ":"
Compress files after a day
"Case" Zip‐t 080915 file.zip: File compression after August 9, 2015 in the current directory
Do not compress the original file of the linked file
"Case" Zip‐y file.zip *
Compression ratio problem, -1~-9, where-9 of the compression rate is highest
"Case" zip-9 file.zip *
Exclude files that do not need to be compressed
"Case" Zip File.zip * x file2.txt: Excludes file2.txt files in the current directory when compressing
Unzip the. zip file with the unzip command
Unzip files directly
"Case" unzip File.zip
Exclude files that do not need to be decompressed
"Case" unzip file.zip‐x file2: Except for the File2 file, all other files are uncompressed
View the contents of a compressed package
Case Unzip‐z File.zip: View the contents of the File.zip compressed package, or use "-l" "-V" to view the contents of the compressed package
Process. gz files with gzip and gunzip
Each user in Linux must belong to a group and cannot be independent of the group. In Linux, each file has the concept of owner, group, and other groups .
1) Owner: Generally the creator of the file, who created the file, becomes the owner of the file naturally. You can see the owner of the file with the Ls‐ahl command. You can also use the Chown user name file name to modify the owner of the file.
2) file group: When a user creates a file, the group in which the file is located is the group that the user is in, the Ls‐ahl command lets you see all the groups of the file, or you can use the CHGRP group name file name to modify the group in which the file resides.
3) Other groups: except for the owner of the file and the user in the group, other users of the system are other groups of files.
file Permissions
the contents shown in Ls-l are as follows:
-rwxrw-r‐-1 root root 1213 9 09:39 ABC
10 characters to determine what different users can do with a file
The first character represents a file (-), a table of contents (d), and a link (l)
The remaining characters are set per 3 (RWX), read (R), write (W), execute (x)
First set of rwx: The permissions of the file owner are read, write, and execute
Second set of rw-: Permissions for users of the same group as the file owner are read, write, but cannot be executed
Third group r--: permissions for other users who are not in the same group as the file owner are read and cannot be written and executed
Also available as a number: R=4,w=2,x=1 so rwx=4+2+1=7
1 indicates the number of files connected
Root indicates that the user
The second root indicates the group to which the user resides
1213 indicates file size (bytes)
9 09:39 indicates last modified date
ABC indicates file name
commands to change permissions
chmod Changing the permissions of a file or directory
chmod 755 ABC: Give ABC permission rwxr-xr-x
chmod U=RWX,G=RX,O=RX ABC: ibid. u= User Rights, g= group permissions, o= different groups of other user rights
chmod u-x,g+w ABC: for ABC to remove user-executed permissions, increase group Write permissions
chmod a+r ABC: Add read permissions to all users
Change owner (chown) and user Group (CHGRP) commands
Chown xiaoming ABC: Change the owner of ABC to Xiaoming
CHGRP Root ABC: Change the group that the ABC belongs to IS root
Chown root./ABC: Change ABC the owner of this directory is root
Chown‐r root./ABC: Change the ABC directory and the owner of all files and directories below it is root
Change the user group
When you add a user, you can specify which group to add the user to, as well as root administrative permissions to change the group in which a user resides
USERMOD‐G Group name User name
You can change the initial directory of the user login by using the USERMOD‐D directory name User name.
Linux Partitioning
The partition of the hard disk is mainly divided into basic partition (Primary portion) and extended partition (Extension portion) two kinds. Just for a hard disk, the sum of the basic and extended partitions cannot be more than 4, and the basic partition can be used immediately but cannot be partitioned. The extended partition must be partitioned before it can be used, meaning it must also be partitioned two times. So what's the extension partition going on? It is a logical partition (Logical portion), and there is no limit to the number of logical partitions
For Windows users, several partitions have several drives, and each partition obtains a letter identifier, which can then be used to specify the files and directories on this partition. Their file structures are independent and very well understood. But it's a bit annoying for these users to get started with Linux at first. Because for Linux users, regardless of a few partitions, to which directory to use, it boils down to only one root directory, a separate and unique file structure . Each partition in Linux is used to form part of the entire file system. Because it uses a processing method called "load" , its entire file system contains a set of files and directories, and a partition and a directory link together. The partition to be loaded will make its storage space available in this directory.
Here are a few important commands
mount Command
Mount [-parameters] [device name] [Mount Point]
Uninstall Command
Umount [Mount Point]
View disk usage
DF [-parameters]
Df-h
Df‐l
DF [Directory full path] to see which partition a directory is in
View Linux system partition specifics
Fdisk‐l
Shell Programming
The fact that the command language interactively interprets and executes user input commands is only one aspect of shell functionality. The shell can also be used for programming. It provides a means of defining variables and parameters, as well as a rich program control structure. Using shell programming is similar to a DOS batch file, called a shell script, also called a shell program or shell command file.
Shell script file:
is a text file
Collection of commands
have permission to execute
Execution mode (./file name)
With export you can temporarily add a system path, such as export path= $PATH home/bin:/root/test/t1, Output environment path, reference the original value $path, $HOME represents the working home directory, is the path delimiter
Shell wildcard characters
* represents multiple letters or numbers
? Represents a letter or a number
"Case" ls A * ls a? LS f080[1-6].tif
escape character \
"Case" ls/mnt/win1/my\documents
single quotation marks: Do not process any variables and commands
"Case" Echo ' Welcome $NAME, the date is date '
double quotes: Handling variables but not processing commands
"Case" echo "Welcome $NAME, the date is date"
Reverse quotation marks: Each word in the quotation mark as a command, if the variable is evaluated first and then treated as a command
"Case" echo "Welcome $NAME, the date is ' date '"
Check History
History, viewing the historical record of used commands
History 5, this note shows the 5 most recently used commands
!5, this description executes a command with a history number of 5
!ls, this note executes the last command that starts with "LS"
Linux Basics Summary