3. Accumulated Linux/UNIX operation commands (gzip, jar, tar, find, crontab) and gzipcrontab
In Linux/UNIX, users often use text interfaces to set up systems or operating systems. The author is constantly working on these commands, therefore, this article has been specially developed, prepared, and started. This article mainly records some of the operating commands you encounter in Linux/UNIX at ordinary times, record and sort them out, one can deepen your impression, and the other can be recorded and shared. We hope that you will give instructions and explanations on inappropriate or ambiguous aspects so that you can learn and improve them together.
[For more information, see http://blog.csdn.net/mahoking]
009 Linux gzip command
1 Command Format
Gzip [option] [file or directory] format gzip [option] [file/dir]
2. command functions
Gzip is a widely used compression program. After a file is compressed, its name will be followed by an extension of ". gz.
3 common examples
Example 01
Command: gzip-d testFile.tar.gz
Input:
[Root @ localhost root] # gzip-d testFile.tar.gz
Note:
Decompress file.tar.gzto file.tar.
-D or -- decompress Or ---- uncompress To uncompress the compressed file.
Example 02
Command: gzip-r testFile.tar
Input:
[Root @ localhost root] # gzip-r testFile.tar
[Root @ localhost root] # ls
[Root @ localhost root] #
Note:
The extension name of the compressed file is .tar.gz.
-R or -- recursive processing: all files and subdirectories under the specified directory are processed together.
010 Linux jar command
1 Command Format
Jar [option] [file] format jar [option] [file]
2. command functions
Jar command to decompress the zip and war files.
3 common examples
Example 01
Command: jar-xvf testFile.zip
Input:
[Root @ localhost root] # jar-xvf testFile.zip
Note:
Decompress testfile.zip and display the decompression process.
-X expand the specified or all files in the JAR package;
-V: displays process information;
-F specifies the name of the compressed file (JAR). This parameter is usually required.
011 Linux tar command
1 Command Format
Tar [option] [file/directory] format tar [option] [file/dir]
2. command functions
Run the userdel command to decompress and back up the file directory.
3 common examples
Example 01
Command: tar-xvf testFile.tar
Input:
[Root @ localhost root] # tar-xvf testFile.tar
Note:
Decompress the testfile.tar File
-X command to uncompress the file;
-V displays files during compression;
-F: use the file name. Note that you need to connect the file name immediately after f. Do not add any parameters!
012 Linux find command
1 Command Format
Find [start Directory] search for conditional operations
2. command functions
The find command is used to find the files we need.
3 common examples
Example 01
Command: find.-name "*. txt"-print
Input:
[Root @ localhost root] # find.-name "*. txt"-print
Note:
Search for all '*. txt' files in the current directory and subdirectory and print the files.
-Name 'string': searches for all files whose names match the given strings. Wildcards *,? , [].
013 Linux crontab command
1 Command Format
Userdel [option] [user] format: userdel [option] [user]
2. command functions
Crontab command to submit, edit, list, or remove cron jobs. In work contacts, the author uses this command to set scheduled tasks.
3 common examples
Basic command format
* *** Command
Hour, day, month, and week commands
The 1st column indicates minute 1 ~ 59. Each minute is represented by * or */1.
The first column indicates the hour 1 ~ 23 (0 indicates 0 points)
The 3rd column indicates the date 1 ~ 31
The 4th column indicates the month 1 ~ 12
The Identification Number of column 5th is from day of the week to day ~ 6 (0 indicates Sunday)
6th columns of commands to run
Example:
0 23 ** 6/usr/local/etc/rc. d/lighttpd restart
The preceding example indicates that apache is restarted at every Saturday.
* 23-7/1 ***/usr/local/etc/rc. d/lighttpd restart
Restart apache every hour between PM and PM.
Example 01
Command: crontab-e
Input:
[Root @ localhost root] # crontab-e
[Root @ localhost root] #
0 23 ** 6/usr/local/etc/rc. d/lighttpd restart
Note:
Crontab-e [user]-edit the current crontab of the user.
Example 02
Command: crontab-l
Input:
[Root @ localhost root] # crontab-l
[Root @ localhost root] #
0 23 ** 6/usr/local/etc/rc. d/lighttpd restart
Note:
Crontab-1 [user]-lists the current crontab of the user.
How to use basic operation commands in linux
◆ Installation and logon commands: login, shutdown, halt, reboot, install, mount, umount, chsh,
Exit, last;
◆ File processing commands: file, mkdir, grep, dd, find, mv, ls, diff, cat, ln;
◆ System management commands: df, top, free, quota, at, lp, adduser, groupadd, kill,
Crontab;
◆ Network operation commands: ifconfig, ip, ping, netstat, telnet, ftp, route, rlogin, rcp,
Finger, mail, nslookup;
◆ System security related commands: passwd, su, umask, chgrp, chmod, chown, chattr, sudo ps,
Who;
◆ Other commands: tar, unzip, gunzip, unarj, mtools, man, unendcode, and uudecode.
How to Implement the command line in linux/unix-copy or move multiple files to another directory, and the source file name to be copied is in one text file
It should be appropriate to use tar instead of reliable
Tar cvf--T files-to-copy.txt | (cd dest-folder; tar cvf -)
If you have to use the cp command, it's also very simple.
Cat files-to-copy.txt | xargs-I cp {} dest-folder