Linux user-related commands & nbsp; passwd commands for system security considerations, in addition to the user name, each user in Linux also has its own user password. Therefore, when you use the useradd command to add a new user, you also need to use the passwd command to set a password for each new user.
Linux user-related commands
Passwd command
For the sake of system security, in Linux, each user has a user name and password. Therefore, when you use the useradd command to add a new user, you also need to use the passwd command to set a password for each new user. later, you can use the passwd command to change your password at any time.
The common format of this command is passwd [user name]. the user name is the user name that needs to change the password. Only super users can use "passwd user name" to modify passwords of other users. common users can only use passwd commands without parameters to modify their own passwords.
The command is used as follows:
Input
Passwd <Enter>;
Enter the current password under (current) UNIX passwd:
Enter a new password at the prompt (this password is not displayed on the screen ):
The system prompts you to enter the new password again.
After the password is entered correctly, the new password is encrypted and put into the/etc/shdow file. It is important to select a password that is not easily deciphered.
The password selection rules are as follows:
The password should contain at least six (preferably eight) characters;
Passwords should contain uppercase/lowercase letters, punctuation marks, and numbers.
The process for a superuser to modify the password of another user (xxq) is as follows,
# Passwd root
New UNIX password:
Retype new UNIX password:
Passwd: all authentication tokens updated successfully
#
Su command
This command is very important. It allows a common user to have the permissions of a super user or other users, and allows the super user to do something as a normal user. A common user must have a superuser or another user's password when using this command. To exit the identity of the current user, you can exit.
The command is generally in the format of su [option] [? ] [User account]
Note: If no user account is specified, the default value is super user root. The meanings of the options in this command are as follows:
? C. It will end after executing a command.
? The purpose of adding this minus sign is to make the environment variable the same as the user who wants to convert.
? M retains the environment variables unchanged.
Password: [enter the superuser password]
Linux system management commands
Wall command
The function of this command is to send information to all logged-on users. you can first write the information to be sent to a file, and then enter:
# Wall <file name
In this way, information can be sent to all users.
In the preceding example, the symbol "<" indicates the input redirection. For more information about its meaning and usage, see Chapter 10. For example:
# Wall' Thank you! '
Broadcast message from root (tty1) Fri Nov 26 14:15:07 1999...
Thank you!
#
After executing the preceding command, the user's screen displays "Thank you !" No system prompt $ (#) appears. press enter again and the system prompt appears.
Write command
The write command sends information to a user in the system. The common format of this command is:
Write user account [terminal name]
Example: $ write Guest hello
At this time, the system enters the sending information Status. you can enter the information to be sent. after entering the information, press <Ctrl + c> when you want to exit the sending status.
Mesg command
The mesg command allows other users to use the write command to send messages to themselves. If you allow others to send messages to yourself, enter the following command:
# Mesg y
Otherwise, enter:
# Mesg n
For super users, the default value is n, and for general user systems, the default value is y. If the mesg does not contain any parameters, the current status is y or n ..
Sync command
The sync command is used when Linux is disabled. You must note that you cannot simply shut down the system by shutting down the power, because Linux caches a lot of data in the memory like other Unix systems, when the system is shut down, you need to synchronize the memory data with the hard disk data to ensure that the hard disk data is up-to-date when the system is shut down. Only in this way can you ensure that the data will not be lost. Generally, the normal process of shutting down the system is to automatically perform these tasks. during the system operation, these tasks are also scheduled and do not require user intervention. The sync command forcibly writes data in the memory back to the hard disk to avoid data loss. You can use this command as needed. The common format of this command is:
Sync
Shutdown command
The shutdown command can safely shut down or restart the Linux system. it prompts a warning message to all logged-on users before the system is shut down. This command also allows you to specify a time parameter, which can be a precise time or a time period from now on. The exact time format is hh: mm, indicating the hour and minute. the time period is expressed by "+" and the number of minutes. After the system executes this command, data synchronization is automatically performed.
The general format of this command is: shutdown [option] [time] [warning information] the meaning of each option in the command is:
-K does not actually shut down, but only sends a warning message to all users.
-R immediately restarts after shutdown.
-H: do not restart after shutdown.
-F: The fsck is skipped during restart.
-N: Fast Shutdown without passing through the init Program.
-C: cancel a running shutdown.
Note that this command can only be used by Super users.
Free command
The free command is used to view the memory usage of the current system. it displays the remaining and used physical memory and swap memory in the system, as well as the shared memory and the buffer used by the core.
The general format of this command is: free [-B |-k |-m]. the meaning of each option in the command is as follows:
-B is displayed in bytes.
-K is displayed in K bytes.
-M is displayed in MB.
Uptime Command
The uptime Command shows how long the system has been running. it displays the following information in sequence: current Time, how long the system has been running, how many logged-on users are there, and the average load of the system in the past 1 minute, 5 minutes, and 15 minutes.
The general format of this command is uptime.
Linux Disk Management
Df command
Function: checks disk space usage of the file system. You can use this command to obtain the space occupied by the hard disk and the remaining space.
Syntax: df [option]
Note: The df command displays the I node and disk block usage of all file systems.
The meaning of each option of this command is as follows:
-A: displays the disk usage of all file systems, including 0 block file systems, such as/proc file systems.
-K is displayed in k bytes.
-I: displays the I node information instead of the disk block.
-T: displays the disk space usage of each specified type of file system.
-X lists the disk space usage of a file system of a specified type (opposite to the t option ).
-T displays the file system type.
Du command
The original English meaning of du is "disk usage", which means to display the usage of disk space.
Function: calculates the disk space occupied by Directories (or files.
Syntax: du [option] [Names…]
Note: this command step by step enters each sub-directory of the specified directory and displays the directory's usage of file system data blocks (1024 bytes. If no Names is provided, the current directory is counted.
The options of this command are as follows:
-S indicates the total number of data blocks occupied by each Names parameter.
-A recursively displays the number of data blocks occupied by each file in the specified directory and its descendants. If neither-s nor-a is specified, only the disk blocks occupied by each directory and its subdirectories in Names are displayed.
-B lists disk space usage in bytes (the system defaults to k bytes ).
-K lists the disk space usage in 1024 bytes.
-C is followed by a total (system default setting ).
-L calculate the size of all files, and calculate hard-linked files multiple times.
-X skipping directories on different file systems is not counted.
Dd command
Function: copies the specified input file to the specified output file, and supports format conversion during the copy process. You can use this command to implement the diskcopy command in DOS. Use the dd command to write the data on the floppy disk as a storage file on the hard disk, and then write the storage file to the second disk to complete the diskcopy function. Note that you should delete the storage file on the hard disk with the rm command. Standard input files and standard output files are used by default.
Syntax: dd [option]
If = input file (or device name ).
Of = output file (or device name ).
Ibs = bytes: the number of bytes read from the buffer zone.
Skip = blocks skip the ibs * blocks block at the beginning of the read buffer.
Obs = bytes: the number of bytes written to the buffer zone.
Bs = bytes: set the number of bytes in the read/write buffer at the same time (equal to setting ibs and obs ).
Cbs = byte: bytes are converted once.
Count = blocks only copies the input blocks block.
Conv = ASCII converts the EBCDIC code to the ASCIl code.
Conv = ebcdic converts an ASCIl code to an EBCDIC code.
Conv = IBM converts an ASCIl code to an alternate EBCDIC code.
Conv = block converts a variable bit to a fixed character.
Conv = ublock converts a fixed bit to a variable bit.
Conv = ucase converts lowercase letters to uppercase letters.
Conv = lcase converts uppercase letters to lowercase letters.
Conv = notrunc: the output file is not truncated.
Conv = swab exchange each pair of input bytes.
Conv = do not stop processing when noerror occurs.
Conv = sync adjusts the size of each input record to the ibs size (filled with NUL ).
Fdformat command
Floppy disk is a common storage medium. A floppy disk must be formatted before it can be used. then, you can use commands such as tar, dd, and cpio to store data, or you can create an installable file system on a floppy disk.
Function: low-level formatting floppy disk
Syntax: format [-n] device
Note: this command is used to format a floppy disk.
-N the disk is not verified after being formatted.
Device specifies the device to be formatted. it is usually one of the following devices:
/Dev/fd0d360
/Dev/fd0h1200
/Dev/fd0D360