Linux Foundation Essay (About Limiting User's Single File Size and Using System mail Functions)

Keywords: Linux vim

1. Limit the maximum file size that users can create:

[root@localhost ~]# vim /etc/security/limits.conf     #Edit the file

# /etc/security/limits.conf
lvjianzhao soft fsize 90000                      #This is a soft limit. The unit is KB.
lvjianzhao hard fsize 102400                   #This is a hard limit. The unit is KB.
                    .....................#Omit part of content

The above two lines of configuration set some restrictions on the user lvjianzhao, who can create no more than 100M of a single file.

2. Query the user's login terminal and login history

[root@localhost ~]# w              #The w command queries which terminal the current user is logged in to
 13:04:54 up  1:32,  8 users,  load average: 2.13, 0.55, 0.21
USER     TTY      FROM             LOGIN@   IDLE   JCPU  U WHAT
root     pts/0    192.168.1.8      11:13    1:33m  0.52s  0.02s bash
root     pts/1    192.168.1.8      11:22    1:42m  0.02s  0.02s -bash
root     pts/2    192.168.1.8      12:21   38.00s  0.30s  0.30s -bash
lv       pts/3    192.168.1.8      13:01    3:46   0.01s  0.01s -bash
lvjianzh pts/4    192.168.1.8      13:01    3:15   0.03s  0.03s -bash
root     tty2                      13:04   46.00s  0.05s  0.05s -bash
root     :0       :0               13:04   ?xdm?  39.10s  0.44s /usr/libexec/gn
root     pts/5    :0               13:04    3.00s  0.02s  0.00s w
#The first line shows the current time, how long to boot, the average load of several users on the system, etc.
#The second line is just a description of each item.
#After the third line, each line represents a user who logs in and gets the terminal pts/3 as shown above.
[lv@localhost ~]$ who  #The information you see with the "who" command and the "w" command are simpler and easier to read than the "who" command.
root     pts/0        2019-09-03 11:13 (192.168.1.8)
root     pts/1        2019-09-03 11:22 (192.168.1.8)
root     pts/2        2019-09-03 12:21 (192.168.1.8)
lv       pts/3        2019-09-03 13:01 (192.168.1.8)
lvjianzhao pts/4        2019-09-03 13:01 (192.168.1.8)
root     tty2         2019-09-03 13:04
root     :0           2019-09-03 13:04 (:0)
root     pts/5        2019-09-03 13:04 (:0)
[lv@localhost ~]$ lastlog  #The lastlog command is used to view all user's historical login records

When the users currently logged on to the system and the terminals used are identified, some messages can be sent to the other party to coordinate their work, as follows:

[root@localhost ~]# write lv pts/3       #write is the command word, lv is the user name, and pts/3 is the terminal.
hello,ni zai jin xing shen me gong zuo     #This is the message to be sent.
#After the input is finished, press the Enter key to change lines and press [crtl+d] to finish the input.
#Then the terminal where lv is located will display the following contents:
Message from root@localhost.localdomain on pts/2 at 13:46 ...
pts/3
EOF

Message from root@localhost.localdomain on pts/2 at 13:46 ...
hello\357\274\214ni zai jin xing shen me gong zuo
EOF
#If you do not want to receive other users to communicate with you in this way, you can use the following methods:
[lv@localhost ~]$ mesg                 #View message status
is y       #"y" means open receive message
[lv@localhost ~]$ mesg n      #"n" means shut down and no messages are received
[lv@localhost ~]$ mesg                 #Check again and confirm
is n
[lvjianzhao@localhost ~]$ write lv pts/3  #The use of "lvjianzhao" users to communicate with "lv" users is directly prohibited.
write: lv has messages disabled on pts/3
#Although other users can be prohibited from sending messages to "lv", root users cannot be prohibited from sending messages to "lv".

3. Mail mail function of the system

(1) Send mail to the user "lv":

[lvjianzhao@localhost ~]$ mail -s "who are you?" lv            #Send an email to the user "lv", the title is the content in quotation marks
#The following is the body of the mail
ni shi shei a
.                      #After the input is finished, you can send it by entering a "...", which is very important.
EOT
[lvjianzhao@localhost ~]$                 #Exit to the command prompt indicates successful delivery.

(2) To the console where the lv user logs in:

[lv@localhost ~]$ mail                    #Execute the mail command
Heirloom Mail version 12.5 7/5/10.  Type ? for help.
"/var/spool/mail/lv": 1 message 1 new
>N  1 lvjianzhao@localhost  Tue Sep  3 14:37  18/628   "who are you"      #This is the message just sent. The opening "N" means unread.
& ?                            #Here you can enter a lot of instructions, enter "?" Viewable output instructions
               mail commands
type <message list>             type messages
next                            goto and type next message
from <message list>             give head lines of messages
headers                         print out active message headers
delete <message list>           delete messages
                .........................#Omit part of content
#Specific support for the use of translation software can be translated

Some instructions are used as follows:

———————— This is the end of the article. Thank you for reading.————————

Posted by zahadum on Tue, 01 Oct 2019 14:29:41 -0700