Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Common basic management commands, classification and summary under Linux system

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Source code of this article: GitHub click here | | GitEE click here |

1. Directory directive 1. Create directory make directorymkdir directory name / / mkdir spring Create a spring folder mkdir-p file/file/file / / Recursively create a multi-level relational directory mkdir dir/newdir/ / do not use recursive mkdir-p dir/newdir/newdir / / use recursion 2, Move the directory movemv dir1 dir2 / / move the dir1 directory to the dir2 directory mv dir1/dir2 dir3/ / move the dir2 directory to the dir3 directory mv dir1/dir2 dir3/dir4 / / move the dir2 directory to the dir4 directory mv dir1/dir2. / / move dir2 to the current directory mv dir1/dir2 dir3/dir4 / / dir2 move to the dir4 directory And change the name to "original name" mv dir1/dir2 dir3/dir4/newdir / / dir2 to the dir4 directory, and change the name to "newdir" 3, change the file name mv dir1 newdir1 / / change the name of dir1 to newdir14, copy copy

Copy a file

Cp file1 dir/file2 / / copy file1 to the dir directory and rename it to file2cp file1 dir/ / file1 is copied to the dir directory, and renamed to "original name" cp dir1/file1 dir2/newfile / / file1 is copied to the dir2 directory And change the name to "newfile" copy directory:-r ignore the hierarchical relationship of the directory cp-r dir1 dir2 / / dir1 is copied to the dir2 directory, and rename to "original name" cp-r dir1/dir2 dir3/newdir / / dir2 is copied to the dir3 directory, and rename to "newdir" cp-r dir1/dir2 dir3/dir4 / / dir2 is copied to the dir4 directory And renamed to "original name" cp-r dir1/dir2 dir3/dir4/newdir / / dir2 was made to the dir4 directory, and renamed to "newdir" cp-r dir1. /.. / newdir / / dir1 was copied to the upper two-level directory, and renamed to "newdir" 5, delete removerm file / / delete file remove regular file "/ / y: delete N: cancel operation of rm-r level directory / / Recursive delete directory rm-rf directory / file / / force delete file or directory 2, file directive 1, View the contents of the file cat filename / / print the contents of the file to the output terminal more filename / / View each line of the file line by line by typing enter / / start viewing from the first line by default / / do not support looking back / / enter Q to exit viewing less filename / / View various parts of the file through the "up, down, left and right" keys / / support looking back / / enter Q to exit viewing head-n filename / / View the first n lines of the file tail-n filename / / View the last n lines of the file wc filename / / View the number of lines of the file 2, Create a file touch dir1/filename / / create a file under the specified path touch filename / / create a file under the current directory 3, append content to the file

If the file does not exist, the file is created

Echo content > filename / / append "content" to "File" in the form of [overwrite] echo content > > filename / / write "content" to "File" in [append] form. 3. User instruction

User actions: root login of the system is required

1. Create a user user add

Configuration file: / etc/passwd

Useradduseradd liming / / create a liming user and create a group with the same name to useradd-g group number username / / set up the user's group Avoid creating a group with the same name useradd-g group number-u user number-d home directory username2, modifying the user usermodifyusermod-g group number-u user number-d home directory-l new name username3, deleting the user userdeleteuserdel usernameuserdel-r username / / deleting the user while deleting their home directory 4, setting a password for the user to log in to the system passwd user name 4, group operation

System root login required

1. Create the group groupadd configuration file: / etc/groupgroupadd music2, modify the group groupmodifygroupmod-g gid-n new name groupname3, delete the group groupdeletegroupdel groupname / / if there is a user under the group, it is forbidden to delete the permission directive

Three kinds of access rights are defined in Linux, which are r, w, and x respectively.

R: indicates that the object is readable, octal represents 4w: indicates that the object is writable, octal represents 2x: indicates that the object is executable, and octal represents the permissions of the user group to which the 1-rwx file belongs and other user permissions

Function: modify the permissions of a directory or file

U:user (owner) g:group (group to which)

O:other (others) a:all (owners)

R:read (read) w:write (write) x:execute (execute)

Chmod 460 test.txt: test file owner: r, group: rw, other users do not have permission chmod Ubunw dest_file: add w permissions to the owner of the target file. Chmod upriwx, gourmage, dest_file: add w permissions to the owner of the target file, x permissions to the group you belong to, and w permissions to other users of the system. Chmod Omurw dest_file: remove w permissions to other users of the target file. Chmod u=rwx dest_file: give rwx permission to the owner. Chmod-R 777 / tmp/a, directory a, including all files or directories under the directory, all user rights become rwx. VI. Notepad instructions

Below the edit mode is shown:-- INSERT--

Below the command mode shows: (nothing is displayed by default)

Under trailing mode:: wq (exit and save)

1. Edit mode operation a: move the cursor back one bit. I: the cursor and the character do not change. O: give a new line s: delete the character where the cursor is located. 2. Tail mode operation: Q / / quit exit editor: W / / write save the modified content: wq / / write quit save changes and exit editor: Q! / / (do not save) force exit editor: W! / / force save: wq! / / strong Save and exit editing: set number or nu / / set line number: set nonumber or nonu / / set line number: / content / or / content / / find specified content lowercase n (next) next uppercase N (next) previous Number / / jump to the line where the number is located string replacement cont1 is replaced with cont2: s/cont1/cont2/ replace the first cont1 on the line of the cursor: s/cont1/cont2/g / / replace all the cont1:% s/cont1/cont2/g / / replace the cont13 of the entire document, Command mode operation u cursor move upper (k) lower (j) left (h) right (l) key word level w: word move to the first letter of the next word e: end move to the last letter of the next word b: before move to the first letter of the previous word Line level $: line end 0: line beginning paragraph level (flip screen) {: previous (this) paragraph first}: next (this) paragraph tail screen level (do not flip screen) H: screen head L: screen end document level G: document tail 1G: document line 1 nG: document line n u content delete dd: delete cursor current line 2dd: including current line Delete 2 lines of content backward ndd: including the current line, delete the next n lines of content x: delete the character where the cursor is located, delete to the end of the word, and enter edit mode u content copy yy: copy the current line of the cursor 2yy: including the current line Copy 2 lines backward nyy: including the current line, copy the next n lines p: paste (delete) the copied content u related shortcut operation u: undo revoke J: merge the upper and lower lines r: single character replacement. Point: repeat the last most recent instruction. Decompress instructions gzip a.txt: gzip Compression gzip-d a.txt.gz or gunzip a.txt.gz: decompress bzip2 a:bzip2 Compression bunzip2 a.bz2 or bzip2-d a.bz2: decompress tar-cvf bak.tar.: package the files in the current directory tar-rvf bak.tar / etc/password: add / etc/password append files to bak.tar (r) tar-xvf bak.tar: extract tar-zcvf a.tar.gz: package and compress Gziptar-zxvf a.tar.gz: extract tar-zxvf a.tar.gz-C / usr: extract to / usr/ tar-ztvf a.tar.gz or zip/unzip: view the contents of the package tar-jcvf a.tar.bz2: package and compress into bz2tar-jxvf a.tar.bz2: extract bz288, Firewall instruction 1: effective after restart: chkconfig iptables on closed: chkconfig iptables off2, effective immediately Failure to open after restart: service iptables start off: service iptables stop 9. System instruction shell > # grep keyword path name matches the information specified in the text shell > # which instruction lookup instruction corresponding to the binary file shell > # ps-A View system active process processshell > # du-h Target to KJM G displays the size of disk space occupied by directories or files in units (block block default = 4k) shell > # date-s "2013-09-13 19:42:30" set time to the system shell > # date View system time shell > # df-lh View system partitions shell > # kill-9 pid kills the process with the specified process number. Shortcut key instruction ctrl + c: stop the process ctrl + l: clear the screen ctrl + r: search history command ctrl + Q: exit help "instruction" or man "instruction": view internal commands help cd ~ or cd: enter the user root directory pwd: view the current directory cd ~ cl: enter the cl user root directory cd -: return to the original directory cd.: return to the previous directory ls-la: view All files under the root directory of the la user. Source code address GitHub address https://github.com/cicadasmile/linux-system-baseGitEE address https://gitee.com/cicadasmile/linux-system-base

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report