Common Commands under Linux

Source: Internet
Author: User
Tags bz2 uncompress

I. Renaming files and folders under Linux and CentOS

Mv:move with the move File command, because the Linux system does not have a dedicated rename command.

Basic format:

Move file: MV file name move destination file name

Rename file: MV FileName modified file name

Example: MV Oldfilename NewFileName (Oldfilename is the old file name, NewFileName is the new filename)

Copy folder: Mv-r the current folder after copying the file name Cp-r manData1 mandata1_20170216

①linux Close and open fire

1) effective after reboot
Open: Chkconfig iptables on
OFF: chkconfig iptables off

2) immediate effect, failure after reboot
Open: Service iptables start
Close: Service iptables stop

② viewing the size of a folder

Du-h--max-depth=1/live/tomcat

is to look at the size of each file in the Tomcat directory

II. Delete files and folders under Linux and CentOS

Typically, delete files by: RM file name. Delete folder with: RmDir folder name.

But RmDir cannot delete the non-empty folder, how to delete the non-empty folder: command: RM-RF non-empty folder name;

-R is recursive down, regardless of how many levels of directory, deleted.

-F is directly forcibly deleted, without any hint of meaning.

1. Delete Folder command

Rm-rf/var/log/httpd/access

The/var/log/httpd/access directory and all files and folders under it will be deleted

2. Delete File command

Rm-f/var/log/httpd/access.log

This file will be forcibly deleted/var/log/httpd/access.log

It is recommended to do a good backup before use, as if this command is not put in the Recycle Bin, deleted will never see the following file.

3. Global Search

If you want to find "hello,world!" in the current directory String, you can do this:

Grep-rn "hello,world!" *

*: represents all files in the current directory, or it can be a file name

-R is recursive lookup

-N is the line number displayed

-R Find all files containing subdirectories

-I ignores case


three, Linux, CentOS decompression different kinds of compression packageExtract
TAR–XVF File.tar//Unpacking the TAR Package
TAR-XZVF file.tar.gz//Decompression tar.gz
TAR-XJVF file.tar.bz2//Decompression tar.bz2
TAR–XZVF file.tar.z//Unzip tar. Z 
Unrar e file.rar//decompression Rar 
Unzip File.zip//decompression Zip 

Summary  
1, *.tar decompression tar–xvf  
3, *.tar.gz and *.tgz extract tar–xzf  
4, *.bz2 with bzip2-d or bunzip2 to extract  
5, *. tar.bz2 with TAR–XJF decompression  
6, *. Z extract   with uncompress;
7, *.tar. Z decompression   with Tar–xzf,
8, *.rar with Unrar e decompression  
9, *.zip with unzip decompression  
Compression Example One: Package all the files in the/etc directory into/tmp/etc.tar
[[email protected] ~]# TAR-CVF/TMP/ETC.TAR/ETC <== package only, do not compress!
[[email protected] ~]# tar-zcvf/tmp/etc.tar.gz/etc <== packaged, compressed with gzip
[[email protected] ~]# tar-jcvf/tmp/etc.tar.bz2/etc <== packaged, bzip2 compressed
# Note that the file name after parameter f is taken by yourself, and we are accustomed to using. Tar as a recognition.
# if the z parameter is added, the. tar.gz or. tgz represent the gzip compressed tar file ~
# If you add the J parameter, use. tar.bz2 as the file name.
# When the above instruction is executed, a warning message is displayed:
# "tar:removing leading"/"from member names" that is a special setting for absolute paths.
  • Tar command

    Unpacking: Tar zxvf Filename.tar

    Package: Tar czvf filename.tar DirName

  • GZ command

    Decompression 1:gunzip filename.gz

    Decompression 2:gzip-d filename.gz

    Compression: gzip FileName

    . tar.gz and. tgz

    Decompression: Tar zxvf FileName.tar.gz

    Compression: Tar zcvf FileName.tar.gz DirName

    Compress multiple files: Tar zcvf FileName.tar.gz DirName1 DirName2 DirName3 ...

  • bz2 command

    Decompression 1:bzip2-d filename.bz2

    Decompression 2:BUNZIP2 filename.bz2

    Compression: Bzip2-z FileName

    . tar.bz2

    Decompression: Tar jxvf FileName.tar.bz2

    Compression: Tar jcvf FileName.tar.bz2 DirName

  • BZ command

    Decompression 1:bzip2-d filename.bz

    Decompression 2:BUNZIP2 filename.bz

    Compression: Unknown

    . tar.bz

    Decompression: Tar jxvf FileName.tar.bz

  • Z Command

    Decompression: uncompress filename.z

    Compression: Compress FileName

    . Tar. Z

    Decompression: Tar zxvf filename.tar.z

    Compression: Tar zcvf filename.tar.z DirName

  • Zip command

    Decompression: Unzip Filename.zip

    Compression: Zip Filename.zip DirName

Iv. viewing tomcat log files under Linux and CentOSTail-f Catalina.log//real-time update for Tomcat log files Five, Linux, CentOS shutdown and restart command detailed ① Restart Command1, Reboot2, Shutdown-r now restart (root) users to use 3, Shutdown-r 10 over 10 minutes automatic restart (root user) 4, shutdown-r 20:30 restart time is 20:30 (root user) ② shutdown Command 1, halt immediately shutdown 2, Poweroff immediately shutdown 3, shutdown-h now shutdown (root user) 4, shutdown-h 100 minutes Auto Power off ③ Cancel restart Shutdown-c

Common Commands under Linux

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.