1. use shell to compress and decompress File 1. compression: tarcvfztarget file source file 1[source file 2..w.tarcvfzm.tar.gz hello. cpphello. h // m.tar.gz is the target document, hello. cpp and hello. h is source document 2. decompress: tarxvfztarget document tarxvfzm.tar.gz // in the current directory
1. use shell to compress and decompress files
1. compression: tar cvfz Target document Source Document 1 [source document 2...]
Tar cvfz m.tar.gz hello. cpphello. h // m.tar.gz is the target document, and hello. cpp and hello. h are the source documents.
2. decompress: tar xvfz Target document
Tar xvfz m.tar.gz // extract the compressed package file m.tar.gz in the current directory
3. tar can create files for documents and directories. Using tar, you can create a file (backup file) for a specific document, change the document in the file, or add a new document to the file. Tar was originally used to create files on tape. now, you can create files, such as floppy disks, on any device. The tar command can be used to package a large number of documents and directories into one document, which is useful for backing up documents or combining several documents into one document for network transmission. Tar on Linux is of the GNU version.
Syntax: tar [primary option secondary option] document or directory
When using 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 document. Select this option if you want to back up a directory or some documents.
R: append the file to the end of the file. For example, if the user has prepared a backup document and finds another directory or document has forgotten to be backed up, this option can be used to append the forgotten directory or document to the backup document.
T list the contents of the archive document and view which documents have been backed up.
U updates the document. That is to say, replace the original backup document with the newly added Document. if it is difficult to find the document to be updated in the backup document, append it to the end of the backup document.
X release a document from the archive document.
Auxiliary options:
B. This option is set for the tape drive. It is followed by a number to describe the block size. the default value is 20 (20*512 bytes ).
F. This option is usually required when you use archive documents or devices.
K. Save the existing document. For example, if we restore a document, the same document will not be overwritten during restoration.
M sets the modification time of any document to the present when restoring the document.
M creates multi-volume archive documents to store them on several disks.
V carefully reports the document information processed by tar. If this option is not available, tar does not report document information.
W each step requires confirmation.
Z uses gzip to compress/decompress the file. after this option is added, the file can be compressed. However, you must use this option to decompress the file during restoration.
2. permission-related
1. ls-l filename is used to view the permission information of a file in detail.
Owner Group Others
Rwx Rwx Rwx
421 421 421
2. the command chmod is used to change the file permission information. it is used with the plus sign (+) to add permissions, and minus sign (-) to delete permissions.
U --- add and delete the read, write, and execute permissions of the user (owner)
G --- add and delete read, write, and execution permissions of group users
O --- add and delete read, write, and execute permissions for other users not in the user group
A --- add and delete read, write, and execution permissions of all users
R --- read permission
W --- write permission
X --- execution permission
Example: sudo chmod a + rw filename
3. about root permissions
Sudo-I can temporarily switch to the root command line status, and all subsequent commands are root-authorized.
If you want to log on to the system as a root user in ubuntu, you need to assign a password to the root user. the command is as follows:
Sudo passwd root
Tip: when editing any important system file, it is best to use the cp command in advance to create a file backup
4. add and delete users
After sudo useradd andrew command is executed, an entry for this user will appear in/etc/passwd, and the home directory for this user is created in the/home directory
After the sudo userdel andrew command is executed, the user's entries in/etc/passwd are deleted. the user cannot log on again, but the Directory in/home is not deleted.
Sudo userdel-r andrew simultaneously deletes the user's home directory in/home
5. shut down the system.
Sudo shutdown-h now or (-H means halt)
Sudo shutdown-n 0
To send a message to all active users when the system is shut down, run the following command:
Sudo shutdown-h 18:30 "System isgoing to shutdown for maintenance this evening"
Sudo shutdown-r now or (-R indicates reboot)
Sudo shutdown-r 0
Finally, a collection of ubuntu or linux Commands
1. manage users and groups: chage chfn chsh edquotagpasswd groupadd groupdel groupmod groups mkpasswd newgrp newuserspsswd
Umask useradd userdel usermod
2. file and file system management: cat cd chattr chmodcompress cp dd fdisk find gzip ln mkdir mksfs mount mv rm rmdir rpmsort
Swapon swapoff tar touch umount uncompress uniq unzip zip
3. obtain information: apropos cal cat cmp datediff fd dir dmesg du env file free grep head info last less locatels lsattr
Man more pinfo ps pwd stat strings tac tail top uname uptime vdirvmstat w wc whatis whereis which who whoami
4. console text editor ed jed joe mcedit nanored sed vim
5. console Internet commands and network commands: bing elm ftphost hostname ifconfig links lynx mail mutt ncftp netconfig netstatpine
Ping pump rdate route scp sftp sshTcpdumpTraceroute whoiswire-test