NO13 useradd-passwd-uname-hostname command-upload rz download sz-batch deployment-Linux user related operations


24 useradd   #Add   user  
               syntax: useradd username Example: ueradd oldboy .
25 passwd #Set      or modify the password for the user.
                Example: passwd oldboy sets the modified password for the user oldboy (direct passwd is the current user's modified password).
               Non-interactive direct password setting method:
                [root@localhost ~]# echo "123456"|passwd --stdin oldboy
                Changing password for user oldboy.
                passwd: all authentication tokens updated successfully.

26 uname #Print       system information. -m 32or64 -r kernel version -a (all) show all -n show the hostname (equivalent to the hostname command)
27 hostname   #Display and set the hostname The default is to display the hostname, and the hostname can be set: hostname name (temporary effect)

 

 

 


·Enterprise scenario interview questions: What is the difference between 32-bit and 64-bit systems? How to check?

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core) (this is the system version information)
[root@localhost ~]# uname -r
3.10.0-693.el7.x86_64 ( This is the version number of the kernel)
[root@localhost ~]# uname -m
x86_64 (this means a 64-bit system)

 


1 Instructions for upload and download commands:

1. Installation method of rz, sz command:
1. The first method: When installing the system, select the package group containing the rz, sz command: Dial-up Networking Support
2. The second method: After installing the system, execute: yum install lrzsz- y
                              or: yum groupinstall "Dial-up Networking Support" -y command to install.

2. Upload command rz:
first go to the directory you want to upload to, such as /root, and then directly enter the rz command, a window appears to select the file to upload, and add -y to overwrite the upload.
[root@localhost ~]# pwd
/root
[root@localhost ~]# cd /  
[root@localhost /]# pwd
/
[root@localhost /]# rz

[root@localhost /]# rz -y

3. Download command: sz.
    Execute the command: sz filename, if you want to overwrite the local download of the same name, you can enter sz -y filename.
    

4. Precautions for using rz, sz commands:
1. Only upload and download files, not directories. If it is a directory, it needs to be packaged into a file and then transmitted. Linux to package ZIP package.
2 The uploaded file can be any file in the computer, and the downloaded file will be downloaded to the corresponding download path directory of the SecureCRT location.
3 At the bottom of the window that appears after executing the rz command and press Enter, be sure not to check "Upload files in ASC mode" at the bottom, otherwise you will encounter problems.


5. Other tools:
In addition to rz sz and other transfer tools, you can also use ftp, sftp (SSH service), winscp and other tools to transfer files.

 

 

2. Batch deployment:
How to batch deploy multiple tags in SecureCRT? PS: You can clone multiple labels by right-clicking on a label.
In window mode, click View-command(chat)window on the SecureCRT toolbar, there will be a white area under the command program, right-click the mouse cursor, and select Send chat to all tabs. After entering the command here, the command will be displayed in the run in all tags.
eg: batch production to see the IP address of the server

Note:
1 The above batch management operations cannot use interactive commands. For example: vi/vim, rz, etc.
   But it can be used alternatively, for example: the vi/vim command can be replaced by echo, cat, and sed.
2 If there is a large number of servers, you can use batch management tools such as saltstack and ssh key.

 


Three Linux users:

Linux feudal society
root emperor
Qianlong 60 years 89 years old social stability


ordinary users common people

The puppet in the virtual user
system cannot be used, it exists fixedly, and it exists to meet the requirements of the service process and program owner in Linux.
Both processes and programs must belong to the user.

 

[root@localhost ~]# useradd oldboy        (add user: oldboy)
[root@localhost ~]# tail -1 /etc/passwd     (view user)
oldboy:x:1001:1001::/home/oldboy:/bin/ bash
[root@localhost ~]# passwd oldboy      (set password for user oldboy)
Changing password for user oldboy.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:      (
passwd is too simple to enter twice) : all authentication tokens updated successfully.
[root@localhost ~]# su - oldboy   (switch to oldboy user)
[oldboy@localhost ~]$ pwd          (check what the current user is)
/home/oldboy
[oldboy@localhost ~]$ whoami       (to see what the current user is)
oldboy

 

Summary:
1. The root user is switched to a normal user: su - username No password is required.
  Ordinary users go to the root user: ctrl+d or su - root to enter the password. Ordinary users need to enter the root user password to access the root user.
3 #Super administrator's prompt
4 @front oldboy: current username
5 @behind localhost is the host name, you can use hostname to query
6 ~: indicates the current directory, that is, the home directory
7 The Linux command prompt is controlled by the PS1 environment variable. This operation does not change the configuration file and is temporary .
  An example is as follows:
  set|grep PS1 Note that PS1 is capitalized.
  Here PS1='[\u@\h\W]\$', you can adjust PS1='[\u@\h\W]\$' through the global variable configuration /etc/profile file.

 

 

Tips:
1 Under normal circumstances, in the enterprise production environment, you should try to avoid operating directly under the root user, unless there are system maintenance requirements beyond ordinary user permissions. If an enterprise that requires it finds that it is directly fired by root, if necessary, it should return to the ordinary user immediately after use.
2 You can also set the password in one step (user oldboy, password qq:31333741) through the following command
   echo "qq:31333741"|password --stdin Username
   example: [root@localhost ~]# echo "123456"|passwd - -stdin oldboy
                   Changing password for user oldboy.
                   passwd: all authentication tokens updated successfully.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324976818&siteId=291194637