60 required commands in linux and their details (below)

Source: Internet
Author: User
Tags zipinfo

60 required commands in Linux (5)-60 required commands in Linux: system security commands
Although Linux is a multi-user system like Windows NT/2000, there are many important differences between them. For many administrators who are used to Windows, there are many new challenges to ensure the security and reliability of the Linux operating system. This article focuses on Linux system security commands.
1. Role
The passwd command is used to change the logon password of an account. The permission is granted to all users.
2. Format
Passwd [Option] account name
3. Main Parameters
-L: the name of the named account is locked and can only be used by users with super user permissions.
-U: Unlock the account lock status. Only users with Super User Permissions can use it.
-X, -- maximum = DAYS: maximum Password usage time (DAYS). Only users with Super User Permissions can use it.
-N, -- minimum = DAYS: minimum Password usage time (DAYS). Only users with Super User Permissions can use the password.
-D: Delete the user's password. Only users with Super User Permissions can use it.
-S: Check the password authentication type of a specified user. Only users with Super User Permissions can use the password.
4. Application Instance
$ Passwd
Changing password for user cao.
Changing password for cao
(Current) UNIX password:
New UNIX password:
Retype new UNIX password:
Passwd: all authentication tokens updated successfully.
As you can see above, the passwd command requires entering the old password and then entering the new password twice.
1. Role
Su is used to change the identity of another user. Except for a Super User, you need to enter the user's password.
2. Format
Su [Option]... [-] [USER [ARG]...]
3. Main Parameters
-F, -- fast: does not need to read the Startup File (such as csh. cshrc). It is only used for csh or tcsh shells.
-L, -- login: After this parameter is added, it is like re-logging into the USER. Most environment variables (such as HOME, SHELL, and USER) are based on this USER) and the working directory will change. If no USER is specified, the default value is root.
-M,-p, -- preserve-environment: the environment variable is not changed when su is executed.
-C command: the USER who changed the account to USER, and then executes the command to change it back to the original USER.
USER: USER account to be changed. ARG is used to input new Shell parameters.
4. Application Instance
Change the account to a Super User, and restore the user after executing the df command. Su-c df root
1. Role
Umask sets the default blocking value for creating files in User Files And Directories. If you place this command in the profile file, you can control the access permission for subsequent files created by the user. It tells the system not to grant access permission to anyone when creating a file. The permission is granted to all users.
2. Format
Umask [-p] [-S] [mode]
3. Parameters
-S: determines the current umask settings.
-P: Modify umask settings.
[Mode]: Modify the value.
4. Description
The umask value of Unix is 022, which prevents other users in the same group and users in other groups from modifying the user's files. Since each user has a private group of his/her own
This "group protection mode" is not needed. Strict permission settings constitute the foundation of Linux security, and making mistakes in permissions is fatal. Note that the umask command is used to set
The maximum value for the read and write permissions of the created file is 0077, that is, to disable the read and write permissions of all processes other than the process for creating the file, which is-rw -------. In
~ /. In bash_profile, the umask 0077 command can be added to ensure that the umask permission of the process can be correctly set after each Shell startup.
5. Application Instance
U = rwx, g = rx, o = rx
Umask-p 177
U = rw, g =, o =
The preceding five-line command first shows the current status, and then changes the umask value to 177. Only the file owner has the permission to read and write the file, and other users cannot access the file. This is obviously a very safe setting.
1. Role
Chgrp indicates the group to which one or more files or directories belong. The permission is a Super User.
2. Format
Chgrp [Option]... group file...
Chgrp [Option]... -- reference = reference file...
Set each group.
3. Parameters
-C, -- changes: Like -- verbose, but the result is displayed only when there is a change.
-- Dereference: affects the objects indicated by the symbolic link, rather than the symbolic link itself.
-H, -- no-dereference: affects the symbolic link itself, rather than the destination indicated by the symbolic link (this option is valid only when the system supports changing the owner of the symbolic link ).
-F, -- silent, -- quiet: removes most error messages.
-- Reference = reference file: used group, not specified.
-R, -- recursive: recursively processes all files and subdirectories.
-V, -- verbose: displays information when processing any file.
4. Application description
This command changes the user group to which the specified file belongs. The group can be either the user group ID or the group name of the user group in the/etc/group file. A file name is a list of files separated by spaces to change the group. Wildcards are supported. If the user is not the owner or super user of the file, the file group cannot be changed.
5. Application Instance
Change the owner group of all files in/opt/local/book/and its subdirectories to book. The command is as follows:
$ Chgrp-R book/opt/local/book
1. Role
The chmod command is very important. It is used to change the access permissions of files or directories. You can use it to control the access permissions of files or directories.
2. Format
The chmod command can be used in two ways. One is the character setting method that contains letters and operator expressions (relative permission setting), and the other is the number setting method that contains numbers (absolute permission setting ).
(1) character setting method
Chmod [who] [+ |-| =] [mode] File Name
◆ The operation object who can be any one of the following letters or their combination
U: indicates the user, that is, the owner of the file or directory.
G: Indicates users in the same group, that is, all users with the same group ID as the file owner.
O: other users.
A: All users. It is the default value.
◆ Operation symbol
+: Add a permission.
-: Cancel a permission.
=: Grant the given permission and cancel all other permissions (if any ).
◆ Set the mode permission to any combination of the following letters
R: readable.
W: writable.
X: executable.
X: append the x attribute only when the target file is executable to some users or the target file is a directory.
S: During File Execution, set the owner or group ID of the process to the file owner of the file. In the format of "u + s" to set the user ID of the file, and "g + s" to set the group ID.
T: Save the program text to the swap device.
U: The same permissions as the file owner.
G: users in the same group as the file owner have the same permissions.
O: The same permissions as other users.
File Name: list of files separated by spaces to change permissions. Wildcards are supported.
Multiple permission methods can be provided in a command line, separated by commas.
(2) number setting method
The general format of the number setting method is: chmod [mode] File Name
The numeric attribute should be in the format of three Octal numbers 0 to 7, in the order of (u) (g) (o) file names, separated by spaces to change the permission of the file list, wildcard characters are supported.
0001 indicates the execution permission of the owner, 0002 indicates the write permission of the owner, 0004 indicates the read permission of the owner, and 0010 indicates the execution permission of the group; write group 0020
Permission: 0040 indicates the group's read permission; 0100 indicates the execution permission of others; 0200 indicates the write permission of others; 0400 indicates the read permission of others; and 1000 indicates the paste position; 2000 indicates false
If this file is an executable file, the Group ID is the location bit; otherwise, the file lock location bit; 4000 indicates that if this file is an executable file, the user ID is the location bit.
3. Instance
If a system administrator writes a table (tem) for all users to enter, the user must be authorized to read and write the file. Run the command: # chmod 666 tem
In the code, how is the 666 number calculated? 0002 is the write permission of the owner, 0004 is the read permission of the owner, 0020 is the write permission of the group, and 0040 is the read permission of the group,
0200 is the write permission of others, and 0400 is the read permission of others. The sum of the six digits is 666 (the above numbers are octal values). The result is shown in Figure 1.
Figure 1 use the chmod numeric method to set File Permissions
As shown in figure 1, the permission for the tem file is-rw-, that is, the user has the Read and Write Permission for the file.
Use the following command to set the character permission:
# Chmod a = wx tem
1. Role
Change the owner and group of one or more files or directories. The permission is a Super User.
2. Format
Chown [Option] user or group file
3. Main Parameters
-- Dereference: The objects indicated by symbolic links are affected, not the symbolic links themselves.
-H, -- no-dereference: affects the symbolic link itself, rather than the destination indicated by the symbolic link (this option is valid only when the system supports changing the owner of the symbolic link ).
-- From = Current Owner: the current group changes the owner and group only when the owner and group of each file meet the specified options. One of these attributes can be omitted. The omitted attributes do not need to conform to the original attributes.
-F, -- silent, -- quiet: removes most error messages.
-R, -- recursive: recursively processes all files and subdirectories.
-V, -- verbose: displays information when processing any file.
4. Description
Chown changes the owner of a specified file to a specified user or group. The user can be the user name or user ID, and the group can be the group name or group ID; files are separated by spaces to change the permission list. Wildcards are supported. The system administrator often uses the chown command to grant the user the permission to use the file after copying the file to another user's directory.
5. Application Instance
1. Change the owner of the shiyan. c file to wan
$ Chown wan shiyan. c
2. Change the owner of the directory/hi and all files and subdirectories to wan and the group to users.
$ Chown-R wan. users/hi
1. Role
Modify the attributes of the ext2 and ext3 file systems and use the permission superuser.
2. Format
Chattr [-RV] [-+ = AacDdijsSu] [-v version] file or directory
3. Main Parameters
-R: recursively processes all files and subdirectories.
-V: displays the modified content in detail and prints the output.
-: Invalid attribute.
+: Activation attribute.
=: Specifies the attribute.
A: Atime: Tell the system not to modify the last access time of this file.
S: Sync. Once the application writes the file, the system immediately writes the Modification result to the disk.
A: Append Only. The system Only allows data to be appended to this file. No process is allowed to overwrite or intercept this file. If the directory has this attribute, the system will only allow the creation and modification of files under this directory, and will not allow the deletion of any files.
I: Immutable. The system does not allow any modifications to this file. If the directory has this attribute, any process can only modify the files under the Directory and cannot create or delete files.
D: Check for errors in the compressed file.
D: No dump. During file system backup, the dump program ignores this file.
C: Compress. The system compresses the file transparently. When reading from this file, the returned data is extracted. When writing data to this file, the data is first compressed before being written to the disk.
S: Secure Delete. The system will use 0 to fill in the region where the file is located when deleting the file.
U: Undelete: When an application requests to delete this file, the system will keep its data block so that the file can be deleted in the future.
4. Description
Some of the functions are supported by the Linux kernel version. If the Linux kernel version is earlier than 2.2, many functions cannot be implemented. Similarly,-D checks for errors in the compressed file.
Function, which can be supported only by kernels above 2.5.19. In addition, modifying attributes using the chattr command can improve system security, but it is not suitable for all directories. The chattr command cannot
Protects/,/dev,/tmp, And/var directories.
5. Application Instance
1. Restore the/root directory, that is, all files in the subdirectory.
# Chattr-R + u/root
2. Use the chattr command to prevent the modification of a key file in the system.
In Linux, some configuration files (passwd, fatab) cannot be modified by anyone. To prevent accidental deletion or modification, you can set "immutable" for the file )", the command is as follows:
# Chattr + I/etc/fstab
1. Role
Sudo is a command in the configuration file, which is used by users within a limited period of time and recorded in the log. The permission is for all users.
2. Format
Sudo [-bhHpV] [-s] [-u] [command]
Sudo [-klv]
3. Main Parameters
-B: execute commands in the background.
-H: displays help.
-H: Set the HOME environment variable as the HOME environment variable of the new identity.
-K: end the password's validity period, that is, you will need to enter the password next time.
-L: list the commands available to the current user.
-P: the prompt symbol for changing the query password.
-S: Execute the specified Shell.
-U: takes the specified user as the new identity. The default value is root when the user is not in use.
-V: The password is valid for 5 minutes.
4. Description
Command configuration in the/etc/sudoers file. When using sudo, you need to enter a password to verify your identity. After a period of time, you can use the defined commands.
Files do not have commands, there will be an alarm record. Sudo is a program used by the system administrator to allow some users to run some/all system commands as root. An obvious purpose is to enhance the site
Security. If you need to do some daily work as a Super User every day and often execute some fixed commands that can only be executed as a Super User, sudo is very suitable.
1. Role
Ps displays the dynamics of the instantaneous process. The permission is applied to all users.
2. Format
Ps [options] [-- help]
3. Main Parameters
There are many ps parameters. Only a few common parameters are listed here.
-A: List all processes.
-L: displays the long list.
-M: displays memory information.
-W: Display widening can display more information.
-E: displays all processes.
A: displays all processes on the terminal, including those of other users.
-Au: displays more detailed information.
-Aux: displays all processes that contain other users.
4. Description
To monitor and control processes, you must first understand the current process, that is, you need to view the current process. Ps command is the most basic and powerful process view command. Use this command to determine which
Processes are running, running status, Process Termination, process botnets, and processes that occupy excessive resources. Figure 2 illustrates the ps-aux command. Most of the information can be executed
. The three most common parameters are u, a, and x. The following three parameters are used to describe the role of the ps command: ps aux
Figure 2 ps-aux command details
Figure 2 in the 2nd line of code, USER indicates the process owner; PID indicates the process identifier; % CPU indicates the CPU usage; % MEM indicates the physical memory usage; VSZ indicates the virtual memory used; RSS indicates the physical memory used by the process; TTY indicates the secondary device Number of the terminal.
Indicates the state of the process, where D is an uninterrupted static (I/O action); R is in progress; S is in static state; T is paused; Z does not exist, but cannot be eliminated temporarily; W does not have enough memory to split pages
Configuration; high-priority process; N low-priority process; L memory paging allocation and lock in the memory body (real-time system or
I/O ). START indicates the process START time. TIME indicates the execution TIME. COMMAND is the executed COMMAND.
4. Application Instance
During system maintenance, the memory usage is often astonishing, but you do not know which process occupies a large number of processes. In addition to using the top command to view memory usage, you can also use the following command:
Ps aux | sort + 5n
1. Role
Who displays which users log on to the system. The displayed information includes the user ID, logon terminal used, launch time, idle time, CPU usage, and what has been done. The permission is granted to all users.
2. Format
Who-[husfV] [user]
3. Main Parameters
-H: do not display the title column.
-U: Do Not Display User Actions/work.
-S: Display in short format.
-F: do not display the user's online location.
-V: displays the program version.
4. Description
Command is mainly used to view the current online user information. If you want to establish instant communication with other users, such as using the talk command, you must first determine that the user is online. Otherwise
The talk process cannot be established. Another example is that the system administrator also needs to use the who command to monitor what every login user is doing at this moment. The who command is very simple to use and can be relatively accurate
It is widely used to grasp the user's situation.
Hands-on exercises
1. Use Linux commands to detect system intruders
Installed with Mandrake Linux and Red Hat
Linux users will know that the Linux system will have three built-in firewalls of different levels (standard, high, and higher). After installing the Linux server and some basic settings, the server should
This statement is relatively safe, but some hackers may exploit the system administrator's negligence to intrude into the system through various methods. It is important to quickly find hackers. In general, you can use commands to query whether a hacker is intruded. See the following table.
Table 1 commands for querying hacker intrusions
For example, if a hacker sniffers a network, the network interface must be in the mixed mode. Run the following command to query the network interface:
# Ifconfig-
Eth0 Link encap: Ethernet HWaddr 00: 00: E8: A0: 25: 86
Inet addr: Bcast: Mask:
Up broadcast running promiscuous mtu: 1500 Metric: 1
In the output of this command, we can see the concepts mentioned above. 00: 00: E8: A0: 25: 86 on the first line is the mac address, and on the second line is the IP address,
The fourth line is about the receiving data status, which is being sniffed by hackers. Generally, the NIC has several statuses for receiving data frames, such as Broadcast, Multicast,
Promiscuous. Broadcast refers to the data frame that receives all types of Broadcast packets; Multicast refers to receiving specific Multicast packets; Promiscuous
Generally speaking, the hybrid mode refers to the working mode for receiving all the destination hardware addresses in the packets without any check.
2. Restrict the abuse of su commands
They know that Super Users have the greatest right in Linux, and almost all hackers want to achieve this goal. Linux adds restrictions on switching to Super Users. Use PAM
(Pluggable Authentication
Modules) prohibit anyone except in the wheel group from su root, modify the/etc/pam. d/su file, and remove the blocking ID #. Use
/Usr/sbin/usermod G10 bjecadm: add the account bjecadm to the group with the gid of 10, that is, the wheel group. The command is as follows:
/Etc/pam. d/su # password verification #
Auth sufficient/lib/security/pam_wheel.so debug
# Only users in the wheel group can switch to the root node #
Auth required/lib/security/pam_wheel.so use_uid
Chmod-G10 bjecadm
In addition, whenever a user tries to use the su command to access a system user, the command will write a message in the/usr/adm/sulog file, if the file records a large number of invalid operations that attempt to use su to enter the root, it indicates that someone may attempt to crack the root password.
Linux commands have powerful functions. For Linux system administrators, they only need to combine various security command techniques to form a security defense line. From the perspective of computer security, there is no absolutely secure computer system in the world, and Linux is no exception.
60 required commands for Linux (6)-Other commands
60 required commands for Linux: Other commands
In the previous sections, we have divided Linux commands into several parts based on their functions in the system. However, there are still some commands that are difficult to classify, but learning them is equally important.
1. Role
The tar command is a reliable method for backing up files in Unix/Linux systems. It can work in almost any environment and has the permission of all users.
2. Format
Tar [main option + auxiliary option] file or directory
3. Main Parameters
When you use this command, the main option is required, and it tells tar what to do. The auxiliary option is used for assistance and can be used.
Main options:
-C. Create a new archive file. Select this option if you want to back up a directory or some files.
-R: append the file to be archived to the end of the file. For example, if you have prepared a backup file and find that there is another directory or some files have forgotten to be backed up, you can use this option to append the directory or files you have forgotten to the backup file.
-T list the file content and check which files have been backed up.
-U updates the file. That is to say, replace the original backup file with the new file. If the file to be updated cannot be found in the backup file, append it to the end of the backup file.
-X releases a file from the file.
Auxiliary options:
-B. This option is set for the tape drive, followed by a number to indicate the block size. The default value is 20 (20 × 512 bytes ).
-F this option is usually required when you use an archive file or device.
-K: Save the existing file. For example, if a file is restored, the same file will not be overwritten during restoration.
-M sets the modification time of all files to the present when restoring files.
-M: Create a multi-volume archive file to store it on several disks.
-V details the file information processed by tar. If this option is not available, tar does not report file information.
-W each step requires confirmation.
-Z uses gzip to compress or decompress the file. With this option, you can compress the file, but you must use this option to decompress the file during restoration.
4. Application description
Tar is the abbreviation of Tape Archive. It was originally designed to package files on Tape. If you have downloaded the Linux source code, you may have encountered a tar file.
Note that Linux is case sensitive. For example, the tar command should always be executed in lower case. The command line switch can be a combination of upper-case, lower-case, or lower-case. For example,-t and-T perform different functions. File or directory names can be both case sensitive and case sensitive, just like the command line switch.
5. Application Instance
Tar is a command line tool without a graphical interface. Use Konsole to open a terminal window, followed by a simple BACKUP command (create a back.tar file in the/tempdirectory, and all the content in the/usr directory is included in it .) :
$ Tar cvf-/usr>/temp/back.tar
In addition, the tar command supports the crontab command mentioned in the third lecture. You can use the crontab tool to set it to run regularly based on time. For example, back up the/usr directory
Hda-the primary drive of the first IDE interface (always on the first hard disk). Add the following statement to the root crontab:
$00 06 *** tar cvf/dev/hda1/usrfiles.tar-/usr
Generally, the following directories need to be backed up:
◆/Etc contains all core configuration files, including network configuration, system name, firewall rules, users, groups, and other global system items.
◆/Var contains the information used by the system daemon (service), including DNS configuration, DHCP lease period, Mail Buffer file, HTTP Server File, and dB2 instance configuration.
◆/Home contains the home directories of all default users, including personal settings, downloaded files, and other information that users do not want to lose.
◆/Root (root) user's home directory.
◆/Opt is the place where many non-system files are installed. The IBM software is installed here. OpenOffice, JDK, and other software are installed here by default.
Some directories cannot be backed up:
◆/Proc should never back up this directory. It is not a real file system, but a virtual view of the running kernel and environment, including files such as/proc/kcore. This file is a virtual view of the entire running memory. Backing up these files is just a waste of resources.
◆/Dev contains the file representation of the hardware device. If you plan to restore to a blank system, you can back up/dev. However, if you plan to restore to an installed Linux system, it is unnecessary to back up/dev.
1. Role
Commands are located in the/usr/bin directory. They are used with pkzip, pkunzip, and MS in ms dos.
In Windows, the winzipsoftware function is similar to compressing a file into a. ZIP file to save hard disk space. When necessary, unzip the compressed file. Use Right of the command
Only all users are allowed.
2. Format
Unzip [-cflptuvz] [-agCjLMnoqsVX] [-P ][.zip file] [file] [-d] [-x]
3. Main Parameters
-C: displays the extracted results on the screen and converts the characters properly.
-F: update an existing file.
-L: displays the files contained in the compressed file.
-P: similar to the-c parameter, the extracted result is displayed on the screen without any conversion.
-T: Check whether the compressed file is correct.
-U: similar to the-f parameter, but in addition to updating an existing file, other files in the compressed file are also extracted to the directory.
-V: detailed information is displayed during execution.
-Z: only the remarks of the compressed file are displayed.
-A: Perform necessary character conversion for text files.
-B: Do not convert characters in text files.
-C: The file name in the compressed file is case sensitive.
-J: the original directory path of the compressed file is not processed.
-L: change all file names in the compressed file to lowercase.
-M: Send the output result to the more program for processing.
-N: Do not overwrite the original file during decompression.
-O: you do not need to ask the user first. After unzip is executed, the original file is overwritten.
-P: Use the zip password option.
-Q: No information is displayed during execution.
-S: converts the blank characters in the file name to the bottom line characters.
-V: retain the file version information of VMS.
-X: the original UID/GID of the file is saved back at the same time.
. ZIP file]: Specifies the. Zip compressed file.
[File]: Specifies the files in the. Zip compressed file.
-D: Specifies the directory to be stored after the file is decompressed.
-X: Specifies which files in the. Zip compressed file are not processed.
-Z unzip:-Z is equivalent to executing the zipinfo command. In Linux, a tool called zipinfo is provided to view the details of zip files. Unzip is 5.50 In the latest version.
1. Role
The gunzip command is used to decompress the file and the permission is granted to all users.
2. Format
Gunzip [-acfhlLnNqrtvV] [-s] [file...]
Gunzip [-acfhlLnNqrtvV] [-s] [Directory]
3. Main Parameters
-A or -- ascii: Use the ASCII text mode.
-C or -- stdout or -- to-stdout: output the decompressed file to the standard output device.
-F or-force: uncompress the compressed file by force, regardless of whether the file name or hard connection exists, and whether the file is a symbolic connection.
-H or -- help: online help.
-L or -- list: lists information about compressed files.
-L or -- license: displays version and copyright information.
-N or -- no-name: during decompression, if the compressed file contains the original file name and time stamp, it will not be processed.
-N or -- name: during decompression, if the compressed file contains the original file name and timestamp, it will be stored back to the unlocked file.
-Q or -- quiet: no warning information is displayed.
-R or -- recursive: recursive processing that processes all files and subdirectories under a specified directory.
-S or -- suffix: Change the compressed character string.
-T or -- test: test whether the compressed file is correct.
-V or -- verbose: displays the command execution process.
-V or -- version: displays version information.
4. Description
Gunzipis a simple decompressed program. It is used to open a file that has been compressed by gzip. the extension name of the compressed file is pai.gz ". In fact, gunzip is the hard connection of gzip. Therefore, you can use the gzip command to complete it separately, whether it is compressed or decompressed. The latest version of gunzip is 1.3.3.
1. Role
Unarj files in the. arj format are decompressed. the permission is granted to all users.
2. Format
Unarj [eltx] [. arj compressed file]
3. Main Parameters
E: extract the. arj file.
L: displays the files contained in the compressed file.
T: Check whether the compressed file is correct.
X: the original path is retained during decompression.
4. Description
Files with the. arj extension are created by the ARJ utility for ms dos and Windows. Because ARJ is a sharing program that cannot obtain source code for free
1. Role
It is actually a command set and a tool program of the DOS file system. It can simulate many DOS commands and is very convenient to use. The permission is granted to all users. Linux provides a set
Mtools's portable tool allows you to easily read and write files and directories from standard DOS floppy disks. They are very useful for switching files between DOS and Linux environments. Mtools
It is very easy to use. If you want to copy all the files in the floppy disk to the hard disk, You can execute the following command:
Mcopy :*.*
That is to say, you only need to add a letter "m" before the corresponding doscommand to complete the corresponding function. This software is usually available in Linux distributions. Run the following command to check the software.
Rpm-qa | grep mtools
If there is no installation, it does not matter, you can download (http://mtools.linux.lu/) a latest version of the installation from the Internet. The latest mtools version available for download is
2. Included commands
Mcd directory name: Change the directory under ms dos.
Mcopy source file target file: copy the file between ms dos and Unix.
Mdel file name: delete the file in ms dos.
Mdir directory name: displays the directory under ms dos.
Mformat drive letter: Create a ms dos file system on a low-level formatted floppy disk.
Rnlabel drive letter: generate the volume label under the ms dos.
Mmd directory name: create a directory under ms dos.
Mrd directory name: Delete the directory under ms dos.
Target file of the mren source file: rename the existing ms dos file.
Mtype file name: displays the content of the ms dos file.
Note that these commands are very similar to the corresponding MS doscommand. In the mtools command, "/" and "\" can be mixed. Because the file list contains documents in the DOS system and is not case sensitive, "CDE" and "cde" are the same here.
3. Application Instance
(1) If you want to quickly format a floppy disk, run the mformat command:
It was originally developed to process DOS file systems, so it can only be used in partitions in the FAT file format. Note that if the FAT16/32 partition is mounted using the mount command
You cannot use mtools commands to process files in these partitions. This is because once the FAT16/32 partition is mounted to the Linux File directory, Linux regards it as a file system.
In this case, you must use the instruction set attached to Linux.
(2) copy the file htca. c on the DOS disk to the current directory and run the ls command for verification.
$ Mcopy a: \ htca. c
$ Ls-l htca. c
-Rw-r--1 xxq 27136 Jan 1 01: 80 htca. c
1. Role
The man command is used to provide online help. the permission is granted to all users. In Linux, an online user manual is stored for users to find on the terminal. You can use the man command to view the help information, which is very convenient and practical.
2. Format
Man command name
Man [-acdfhkKtwW] [-m system] [-p string] [-C config_file] [-M path] [-P pager] [-S section_list] [section] name. ..
3. Parameters
-C config_file: Specifies the man. conf file. The default value is/etc/man. conf.
-M path: Specifies the search path of the online manual. If not specified, the environment variable MANPATH is used. If MANPATH is not used,/usr/lib/man is used. conf. If MANPATH is an empty string, the default value is used.
-P pager: Specifies the pager to use. man uses this option first, and then sets it according to the environment variable MANPAGER, and then the environment variable PAGER. man uses/usr/bin/less-is by default.
-S section_list man: List of chapters to be searched (separated by colons). This option overwrites the MANSECT setting of the environment variable.
-A man: by default, searches are stopped after the first found manual is displayed. Using this option forces man to continue displaying all online manuals that meet the name.
-D: do not display the online manual. Only the error message is displayed.
-D: displays both online manuals and debugging messages.
-H: displays the help message and ends the program.
-K: searches all online manuals for specified strings. Please note that the response speed of this function may be slow. If you specify a section (region), it will be helpful.
-M system: specify another group of online manuals based on the specified system name.
Man: the abbreviation of manual. You can obtain this document immediately when it is difficult to enter the command. For example, if you encounter difficulties when using the ps command, you can enter man ps to get help information. The man page of ps is displayed ).
Since the man page of the manual page is viewed by the less Program (which can be easily used to flip the screen up and down), all the less options can be used in the man page.
More important function keys in less are:
[Q] Quit;
[Enter] one row goes underground;
[Space] page by page;
Turn over one page;
[/] Followed by a string and [Enter] To find the string;
[N] finds the next match in the last query.
4. Read the manual page
The manual page provides a lot of information in a few spaces. Here we will briefly introduce some of the content on most manual pages. The Linux manual page consists of nine parts: USER commands, system calls, libraries, device descriptions, file formats, games, miscellaneous, system commands, and kernels. The snapshots on the manual page are shown in Figure 1.
Figure 1 ps command manual page Snapshot
The Linux manual page is shown in table 1.
5. Application Instance
Commands include basic and important commands, such as ps, find, cat, and ls. Here is an example of a comprehensive application. We can see that man's position in Linux is crucial.
Yes. However, the information displayed by man is not common text. If you direct the text to a text file, you will find that the highlighted text in man is changed to two, besides
Number of tabs, making printing and editing inconvenient. However, use the following statement to print the ps command.
# Man ps | col-B | lpr
This command uses both the output redirection and pipeline techniques to print the help information of the ps command directly. For more Man files, see Linux Man
1. Role
The unencode command encodes a binary file table into a text file. the permission is granted to all users.
2. Format
Uuencode [-hv] [source file] target file
3. Main Parameters
-H: Lists instructions in the help format ).
-V: List version information.
4. Application description
The uuencode command can convert a binary file into an ASCII code that can be sent by email. The uuencode encoded data starts with begin and ends with end. Generally, each row starts with "M" and the middle part is the encoded file, the encoded file is larger than the source file.
1. Role
The uudecode command is used to restore the uuencode-encoded file. uudecode only restores the encoding data between the in and the end mark, and the program skips the data other than the mark. The permission is granted to all users.
2. Format
Uuencode [-hv] [file1...]
3. Main Parameters
-H: Lists instructions in the help format ).
-V: List version information.
4. Application Instance
Run the following command to restore several files at a time:
Uuencode file1.uud file2.uud file3.uud
Hands-on exercises
1. send an email under the Linux Command Line
Despite the rapid development of Linux desktop applications, Shell still has a strong vitality in Linux. If the email server supports 8-bit bytes, run the following command:
Cat <Attachment File Name> | mail <email address>
The cat (cat is the abbreviation of concatenate) command processes several files into one and saves the processing results to a separate output file, here we use it to merge the text of the mail.
Write the email name, for example, cjkmail, and run the following command:
$ Uuencode <Attachment File Name> cjkmail
In this way, you can use the vi editor to write the cjkmail file, write the text of the letter in front, and then send it.
After receiving the letter, the recipient copies the content in the letter from cjkmail and saves it as themail. uue. If the recipient is in Windows, you can decompress WinRAR or WinZip to see the attachment.
If the other party also uses Linux, you can use the undecode command to restore:
$ Uudencode-o <Attachment File Name> themail. uue
2. Implement tar volume sharding
I want to compress a MB file into multiple MB files (I use 64 MB USB). Run the following command:
$ Tar czvf-dir | split-d-B 63 m
Then merge the command:
$ Cat x *> dir. tgz
The above example is actually completed by a combination of three commands, that is, packaging with tar, splitting with split, and merging with cat. "Tar czvf-dir" means to package the dir directory and output it to the standard output (argv). In this way, you can directly output it to the split using a pipeline.
3. Execute a command consecutively
You can run the watch command repeatedly. If it works with ls, you can observe the size of a file.
$ Watch ls-l file. name
4. Use the tar command to export a file
Tar xvf GLvPro6.4_linux.tar readme.txt
In this example, readme.txt is exported separately.
5. Only several subdirectories are backed up when a directory is packed with tar.
Tar cf -- exclude home/cw.home/cao
In this way, the home directory is backed up in only two subdirectories, csung and cao.

So far, all 60 required Linux commands have been introduced. Linux Command Line is powerful. If you are familiar with common Linux commands
A complex command can be combined to complete user tasks. There are too many commands in Linux, and it is impossible
In DOS, remember all commands and parameters. Linux provides some methods, such as using "help" and "man" to query the name order.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.