1. log on, shut down, and log off
1. root-Super User Account (System Administrator), which can be used to do anything in the system.
2. Common users-this account is used by common users and can perform limited operations.
Generally, Linux users are common users, while System Administrators generally use superuser accounts to perform system management. If you only need to complete some tasks that can be completed by a common account, we recommend that you do not use a Super User Account to avoid accidental damage to the system. Affects the normal operation of the system.
User logon is divided into two steps: Step 1: Enter the user's login name, and the system recognizes the user based on the login name; Step 2: Enter the user's password, which is a string set by the user, other users are kept confidential and keywords used by the system to identify authentic and false users during logon.
After you enter the user name and password correctly, you can access the system legally. Screen Display:
Root @ loclhost/root] # ------- [user name @ host name main directory]
Note that the Super User prompt is "#", and the other user prompt is "$ ".
Log out, that is, switch the user, Enter logout, and press Enter to return to the logon interface.
Shut down the system and use the shutdown command. Only the root user can use this command.
Shutdown [options] when [message]
Options:-r indicates that the instance is restarted,-h indicates that the instance is shut down immediately after the system service is stopped (halt), and-f indicates that the instance is restarted quickly.
When specifies the shutdown time hh: mm: absolute time, + m: m minutes later.
Now = + 0;
Shutdown poweroff = shutdown-h now
Restart reboot = shutdown-r now
When a Super User or a common user needs to exit the system
Permission: All Users
Usage: cd [dirName]
Note: change the working directory to dirName. DirName can be an absolute or relative path. If the directory name is omitted, it is changed to the user's home directory (that is, the directory where the login is located ).
In addition ,"~ "It also indicates the home directory," .. "indicates the current directory, and" .. "indicates the previous directory at the current directory location.
Example: Skip to/usr/bin /:
Cd/usr/bin
Jump to your home directory:
Cd ~
Jump to the top two layers of the current directory:
Cd ../..
Permission: All Users
Usage: chmod [-cfvR] [-- help] [-- version] mode file...
Note: file access permissions for Linux/Unix are classified into three levels: file owner, group, and others. Chmod can be used to control how files are accessed by others.
Calculation:
Mode: permission setting string in the following format: [ugoa...] [+-=] [rwxX]...] [,...], u indicates the owner of the file, g indicates that the owner of the file belongs to the same group, o indicates that the owner of the file belongs to other people, and a indicates that all three are.
+ Adds a permission,-Indicates canceling the permission, and = indicates a unique permission.
R indicates that the file can be read, w indicates that the file can be written, and x indicates that the file can be executed only when the file is a subdirectory or the file has been set to executable.
-C: if the permission of the file has been changed, the change action is displayed.
-F: Do not display an error message if the file permission cannot be changed.
-V: displays details of permission changes.
-R: Change the permissions of all files and sub-directories in the current directory in the same way (that is, change one by one in the way of delivery)
-- Help: displays auxiliary instructions
-- Version: displays the version.
Example: Set the file file1.txt to readable by all users:
Chmod ugo + r file1.txt
Set file1.txt to readable:
Chmod a + r file1.txt
Set file1.txt and file2.txt as the owner of the archive, which can be written to the same group to which the archive belongs, but not to others:
Chmod ug + w, o-w file1.txt file2.txt
Set ex1.py to only the owner of the file to execute:
Chmod u + x ex1.py
Set all files and subdirectories in the current directory to be readable by anyone:
Chmod-R a + r *
In addition, chmod can use numbers to indicate permissions, such as chmod 777 file.
Syntax: chmod abc file
Each a, B, and c is a number, indicating the permissions of the User, Group, and Other respectively.
R = 4, w = 2, x = 1
If you want the rwx attribute, 4 + 2 + 1 = 7;
If the rw-attribute is required, 4 + 2 = 6;
If you want the r-x attribute, 4 + 1 = 7.
Example:
Chmod a = rwx file
And
Chmod 777 file
Same effect
Chmod ug = rwx, o = x file
And
Chmod 771 file
Same effect
If you use chmod 4755 filename, you can grant root permissions to this program.
Permission: root
Usage: chmod [-cfhvR] [-- help] [-- version] user [: group] file...
Note: Linux/Unix is a multi-person, multi-job operating system. All archives have owners. Chown can be used to change the owner of an archive. Generally, this command is only used by the system administrator (root). Generally, users do not have the permission to change the owner of another user's archive or change their owner to another user. Only the system administrator (root) has such permissions.
Calculation:
User: user IDgroup of the new owner: user group of the new owner (group)-c: if the owner of the file has indeed changed, the change action is displayed-f: if the archive owner cannot be changed, do not display the error message-h: only the link is changed, not the file that the link actually points to-v: show owner change details-R: perform the same owner change on all files in the current directory and sub-directories (I .e., change one by one in the way of delivery) -- help: show auxiliary description -- version: display version
Example:
Set the owner of the file file1.txt to user jessie of the users Group:
Chown jessie: users file1.txt
Set all files in the current directory and sub-directory owner to user lamport of users Group:
Chmod-R lamport: users *
Permission: All Users
Usage:
Cp [options] source dest
Cp [options] source... directory
Note: copy one file to another or copy several files to another directory.
Count
-A tries its best to copy the file status, permissions, and other information as they are.
-R if the source contains the directory name, the files under the directory are also copied to the destination in sequence.
-F if the destination already has an archive with the same file name, delete it before copying.
Example:
Copy the file aaa (already exists) and name it bbb:
Cp aaa bbb
Copy all C language programs to the Finished subdirectory:
Cp *. c Finished
Permission: All Users
Usage: cat [-AbeEnstTuv] [-- help] [-- version] fileName
Note: connect the archive string and upload it to the Basic output (screen or add> fileName to another archive)
Parameters:
-N or -- number indicates the number of all output rows starting from 1.
-B or -- number-nonblank is similar to-n, but is not numbered for blank rows.
-S or -- squeeze-blank when there are two consecutive blank rows or more, it is replaced by a blank row
-V or -- show-nonprinting
Example:
Cat-n textfile1> textfile2: add the row number to the file content of textfile1 and enter textfile2.
Cat-B textfile1 textfile2> textfile3 adds the file content of textfile1 and textfile2 to the row number (blank rows are not added) and then attaches the content to textfile3
Permission: All Users
Usage: cut-cnum1-num2 filename
Description: displays the text of each row starting from num1 to num2.
Example:
Shell> cat example
Test2
This is test1
Shell> cut-c0-6 example # the first 6 characters starting with print
Test2
This I