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

A brief introduction to the common operation commands of linux

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

Share

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

# first of all, let's introduce the vim text editor.

# it mainly creates files, documents, edits to documents, files, such as: windows, txt files, doc files and so on. / / you can write content to files.

# give a simple example:

Vim abc.txt / / create an abc.txt document for the current directory

Vim / abc.txt / / create an abc.txt document under the root

So how to view the contents of the text:

Cat: mainly look at the text content

Cat / abc.txt / / check what the abc.txt content is

# so how to write content into it

After editing with vim, there are three modes

The first is: command line mode

The second is: input mode

The third is: the last line mode

# generally, after we enter the document with vim, the default is command line mode, and then enter I to enter the input mode to write content to it. When we have finished writing the content, we need to save and exit, then click the ESC key, go back to the command line mode, click shift+ again: and then the last line mode Enter wq to save and exit

# Note that vim enters the command line mode by default. When you want to switch between the input mode and the last line mode, you must exit to the command line mode before switching.

# enter Q! on the last line / / exit without saving

# briefly introduce how to copy, paste and delete in vim

Yy: copy the current line

10yy: copy the current 10 lines

P (lowercase p): glue to the current cursor

P (or shift+p) pasted above the current cursor

Dd: delete this line of the current cursor

10dd: delete 10 lines of the current cursor / / include the current cursor line

# tell you more about the jump between lines in command-line mode, the beginning of the line, and the jump before the line

Home/shift+6 / / Jump to the beginning of the current cursor line

End / shift+$ / / Jump to the end of the line of the current cursor

Gg / / Jump to the first line of the file

G / shift+g / / Jump to the last line of the file

# and introduce you to the simple operation of the last line.

Set nu / / display line number

Set nonu / / does not display line number

/ 10: at unentered / 10, the cursor jumps directly to the tenth line

S / root/new / / means to replace the first root of the current line with new

S / root/new/g / / means to replace all root on the current line with new

% s / root/new/g / / means to replace all root of the current file with new

# the following is a brief introduction to the creation of user groups and the creation of user groups

Useradd lili / / create user lili

Ls / home / / displays the home directory of an ordinary user

Id lili / / View the identity of the user

Gpgroupadd abc / / create a group of abc

Gpasswd-a lili abc / / add user lili to the labc group

Gpasswd-d lili abc / / remove the lili user from the group

Su-lili / / switch user directory

Usedel-r lili / / Delete user

Usermod-l koufei lili / / replace lili users with new users

# the following is about making the .tar package to compress and decompress the tar package.

Tar-zcf / opt/boot_back.tar.gz / boot/ compress the boot directory into boot_back.tar.gz

Tar-jcf / opt/boot_back.tar.gz2 / boot/ compress the boot directory into boot_back.tar.gz2

Tar-jcf / opt/boot_back.tar.xz / boot/ compress the boot directory into boot_back.tar.xz

# Summary: here are three different ways to compress tar packages

# Universal decompression formula

Tar-xf / opt/boot_back.tar.gz-C / root/abc / / extract boot_back.tar.gz to / root/abc

# No matter which compression method is used, it can be decompressed with tar-xf

# the following describes the local installation of yum sources

Mount / dev/cdrom / opt/ for mounting

Vim / etc/yum.repos.d/kf.repo

# as shown below:

[kf]

Name=kf

Baseurl= file:///opt/

Enabled=1

Gpgcheck=0

Verify: yum replosit / / as shown in the following figure

# above is the locally built yum source

# then you can install the software

Yum-y install httpd / / install httpd software

# introduce the user's permissions on the directory file again

Mkdir / opt/abc / / create directory abc

Ls-ld / opt/abc/ query the file attributes of / opt/abc/ to see what permissions it has

Root: the owner has the right of rwx.

Root: belonging to the group with ro right county

Others: with rx permission

# r: read

W: write

X: the meaning of execution

# change the directory permission of / opt/abc/ so that the owner only has rw permission and the group only has r permission

U=uid / / owner

G=gid / / generic group

Chmod upright RW Grunr / opt/abc/

# so how to make a user have both owner rights and group permissions

Give a simple example

# if you let user lili have group and master permissions

The first step is to check whether there is a user named lili, and if not, create

Id lili / / View lili identity

Useradd lili

Chown lili:lili / opt/abc/ make lili have the permission of group and owner

* _ *

I'll write about it today.

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