Today is the fifth day of learning commonly used commands, today I mainly learn some user management and compression commands
The first is useradd: add a new user. The observation path can be sent to /usr/sbin/useradd, which means that only root can call this command.
The second and similar is passwd: set password. The password set by Linxu must be more than eight characters and preferably contain alphanumeric characters and symbols
Here I created a user named liming and set a password for the user
who: View information such as login and terminal
The first is the user, tty is the local terminal, pts remote terminal, and then the login time, the host ip address of the login, if not written, the local login
The last user management command introduced is w: view the detailed information of the logged-in user
up: update, refers to the continuous running time of the virtual machine; IDLE: idle time, refers to the time without code operations; PCPU: cumulative CPU time
Next, let’s talk about Linux compression commands. Compression commands are very important commands and play an important role in file transfer. Let me introduce the first compression command gzip: compressed files are in gz format, and can only compress files, not directories. Compression does not retain the source file
As you can see, the gzip command does not preserve the original file.
Matched with it is gunzip: decompress files in gz format without retaining compressed files
The first two commands can only compress and decompress files. What about compressing directories? Here is a very important command tar: packaging directory, packaging will retain the source files
- tar -c: package
- tar -v: display detailed information
- tar -f: specify the file name
- tar -z: Pack and compress at the same time, or unpack and decompress at the same time.
Here I will pack and integrate the linux_yasuo directory into linux_yasuo.tar. Note that it is just integration, not compression yet. Due to the addition of the -v command, the files and directories in the directory will be displayed.
Here again use the gzip command learned before to compress the integrated linux_yasuo.tar into a linux_yasuo.tar.gz file. This tar.gz format is very common on the Internet. Remember, the directory must be packaged first, and then compressed.
Of course, if you find it troublesome, you can directly use this format: tar -vczf linux_yasuo.tar.gz linux_yasuo, directly package and compress. But this compression command must pay attention to the order, compression is to pack -c first, then pack and compress at the same time -z (cz can exchange positions), the specified file name -f must be placed at the end, and the display details -v cannot be placed at the end , Usually put -v at the beginning, so it must not be wrong. - tar -x: unpack
tar -vxzf linux_yasuo.tar.gz: unpack linux_yasuo.tar.gz and unzip the files inside. Decompression is similar to compression, even if the -c package is replaced with -x to unpack.
Next, let's talk about a command zip that can compress files and directories: compress files or directories. Here is an explanation. If you can't find the command, just type yum install zip and yum install unzip to install the command. Other commands are similar.
- zip -r: The compressed directory is to display the file information in the directory, similar to the -v operation in gzip.
Here, the boduo file is compressed into boduo.zip, and the original file is retained. The decompression command is similar: unzip boduo.zip
Finally, talk about bzip2: compressed files. This command is an upgraded version of gzip. The previous gzip command does not retain the original file whether it is compressed or decompressed. This gzip has a command option to retain the original file, and the degree of compression is greater than that of gzip.
- bzip2 -k: Generate compressed files and keep the original files.
You can find that the original files are not deleted.
bzip can also be used with tar to compress directories
- tar -j: Compress into bzip2 format.
This format is very similar to gzip, except that -z is replaced with -j. - bunzip2 -k: Keep the original file. It
can be found that the original file boduo.bz2 is preserved.
Decompression can also be used with tar to decompress the bz2 directory.