First time Linux Contact
Shutdown command: (need to log in with root) shutdown-h now//Shut down immediately shuwdown-r today//Restart the computer reboot//Now restart the computer
User login: ' su-' command to switch users.
User logoff: Logout Log off the user.
command to enter the graphical interface: STARTX
VI Editor use: Development steps: 1, vi Hello.java 2, input I enter the editing state 3, enter the ESC key into the command mode 4, enter a colon: 5, enter "Wq means exit save" or "q! means exit does not save "6, compile Java program: Javac Hello.java 7, run Java Hello
command to view all files in the current directory: LS
Linux file directory: Linux file system is a hierarchical tree-like directory structure, the topmost layer in this structure is the root directory "/". The other directories are then created under this directory. A deep understanding of the Linux file directory is very important. The root directory is mainly: root directory, home directory, bin directory, sbin directory, mnt directory, etc directory, var directory, boot directory, usr directory, and so on, root directory: Store the root user-related files home directory: Storage of ordinary users of relevant files Bin directory: The directory that holds the General Command Sbin directory: Store Some commands with certain permissions to use the MNT directory: The directory that is used to hang the floppy disk drive and the CD-ROM, or the default is hanging in the directory. Etc Directory: to store configuration-related files, such as the configuration of the database var directory: Store some frequently changing files Boot directory: Store some boot-related files usr directory: Store the installer default installation path
If you want to show the current path below? Please use the PWD command to view the current path
One, Linux user management 1, useradd user name (must be required to log in with the root user) Case: Useradd xiaoming//indicates adding user Xiaoming
2. passwd username//Modify user password case: passwd xiaoming
3. Delete User Userdel username//delete user Userdel xiaoming//delete xiaoming Userdel-r xiaoming//delete xiaoming and user home directory
4. Specify RunLevel (same as root user) command init[0123456] Run level: 0: Shutdown 1: Single User 2: Multi-user state No NETWORK SERVICE 3: Multi-user state with Network Service 4: System not used reserved to User 5: Graphical interface 6: System restart The normal run level is 3 and 5, to modify the default RunLevel to modify the Id:5:initdefault of the file/etc/inittab: The number in this line
To resolve the method of modifying the error configuration: When you enter the Grub interface at Redhat boot, enter E, select the second line, enter an E, and then enter a 1 to indicate the RunLevel 1th. Because the single-user mode does not read the Inittab configuration file, it can be entered using single-entry, the modification level last entered B into one-user mode, and finally the RunLevel is modified in single-user mode.
5. Create directory and delete directory mkdir create directory rmdir delete directory ls-a Show hidden file ls-l show long list style touch Create an empty file CP Copy command cp-r DIR1 dir2//Recursive copy command (copy subdirectory information) For example: CP a . out/home/xiaoming/indicates that the A.out file is copied to the Xiaoming user
MV move file and the file name RM delete files and directories RM-RF * Delete all content (including directories and files) R recursive F mandatory
ln establishes a symbolic link ln-s source target such as: Ln-s/etc/inittab inittab//indicates inittab points to the actual file/etc/inittab
More display file contents, with paging less display file contents with paging grep query content in text: such as grep-n "shunping" Aaa.java//Display the number of result rows found | Pipe command: Means to give the result of the previous command to | command processing | and more with more.
Man help command
Find search files and directories (1) Search for and display files and directories of the specified name in a specific directory Find/-name man means to search for a file or directory named man from the root directory (2) search for files or directories that have been accessed/changed over time find/home-amin-1 0 means a file or directory accessed within 10 minutes find/home-atime-10 means a file or directory accessed within 10 hours find/home-cmin-10 means a file or directory that has been changed within 10 minutes find/home-ctime-10 meaning 10 hours Files or directories that have changed within (3) search for files of the specified size find/home-size +10k means to find files of size 10k in the/home directory
redirect Commands > and >> to save the results to the appropriate file. such as: Ls-l >a.txt means to write the contents of the LS view to a.txt (overwrite write) ls-l >>aa.txt means to append LS view to the end of the file Aa.txt
II. User management: Focus: File owners, groups, and other groups: each user in Linux must belong to a group and cannot be independent of the group. Each file in Linux has the concept of owner, group, and other groups. (1) Owner: Generally the creator of the file, (2) group: When a user creates a file, the group that the file is in is the same group as the user. Use the Ls-ahl command to see all groups of files (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 (4) Change the group: You can modify the group of files by chgrp the group name file name
How to add a group to Linux: Groupadd new group name View information for all groups in Linux: Vi/etc/group Create a user and specify that the user is assigned to that group? USERADD-G Group name User name How to view information for all users of Linux: vi/etc/passwd
-rw-r--r--: Represents various types of user permissions on the file operation, which can be divided into four parts:-| rw-|r--|r--, the permissions are divided into three kinds: R is readable, 4 is represented, W is writable, 2 is represented, X is executable, 1 represents-|rw-|r--|r--, The first part represents the file type, if-the normal file, D for the folder, the second section indicates the permissions the file owner has on the file, and the third part represents the user's permissions to the file, and the third part represents the permissions that the other group of users have on the file.
How to modify the permissions of a user of a file (note that changing any one of the file permissions requires the owner of the file to change or root user) chmod change the permissions of the file or directory chmod 755 ABC means to give ABC permission rwxr-xr-x permissions chmod U=rwx,g=rx , O=RX ABC means to give ABC permissions rwxr-xr-x permissions, where u represents user rights, G for group permissions, O for different groups of other user rights chmod u-x,g+w ABC means to remove user execution rights for ABC, increase group Write permissions chmod a+r ABC This means adding permissions to all users.
How to change the owner of a file (chown) and user group (CHGRP) chown xiaoming ABC means to change the owner of ABC to xiaoming CHGRP root ABC means to change the group that the ABC belongs to as Root chown root./abc The owner of the directory that changed the ABC is root chown-r root./abc means change the ABC directory and the owner of all files and directories underneath it is root
Modify user group, must use root operation usermod-g Group name User name you can also use usermod-d directory name User name means to change the initial directory of the user login
Linux Learning Note 1