Linux command finishing-basic operations

Source: Internet
Author: User

1.ls Directory Enumeration (dir)
Generally we write this:

    1. Ls   

Enumerating all the files in the current directory, if there are many files, it is very complicated. We can add keywords, for example we want to see all the files that contain XML.

    1. LS *xml*  

If this time, we want to see the owner information of these files can be written like this:

    1. Ls-la  



2.cd Directory Switching
As with other directory switching commands, there is no difference.

    1. CD A  

Switch to the A directory.

3.chown Change the owner of a file (folder)
Above through LS we see a bunch of files, there may be files we can not operate, this time requires the root account to execute the chown command to change the file belongs to, you can write:

    1. Chown Boss.boss *  

This operation is to give all the files in the current directory to the boss user and the boss Group user all rights. So the files (folders) under the Sub-folder need to be modified how to do it? Perform

    1. Chown-r Boss.boss *  



4.mkdir Creating a directory
This command is simple enough to perform

    1. mkdir x  

We have built an X directory under the current directory.

5.cat File View
We can view the contents of the file via the cat command and execute

    1. Cat A.xml  

We can view the contents of this file, of course, in textual form.

6.tail File View (can track files)
If this command does not add parameters, and Cat no difference, the final thing is that he can track the contents of the file, we often use it to monitor the log, such as

    1. Tail-f Javaeye.log  

When the Javaeye.log file grows, we can capture this change in the console, and if the log file changes quickly it looks like a scene in The matrix (black-green, no-stop brush!). )。

7.tar File Compression
Compression decompression, which is the basic operation of the deployment effort.

    1. TAR-ZVCF java.tar.gz Java  

All files containing subfolders under the Java directory are compressed into java.tar.gz files.
In turn, the unzip execution

    1. TAR-XZVF java.tar.gz  



8.rm Delete
Tossing so much, generating a heap of junk files. Clean up quickly, hehe!

    1. RM *  

Oh, my God! It's horrible! Fortunately did not carry out!!! Brothers, remember that you must not use this command when you execute the DELETE command!!! If you are a super administrator, it will be possible to delete all the files, the system will be paralyzed in the moment of reboot!!! It's a good idea to specify a filename or path name to avoid all deletions, which is suicide! Oops, the directory can not be deleted, there are sub-files can not be deleted what to do?

Rm-r XML  

This allows you to completely delete the XML directory.

9.su Super User command  

Just doing chown, we need to switch to the superuser, the root user, what to do? Perform

    1. Su  

Follow the prompts to enter the root user password and easily switch to Superuser. This account is not recommended for non-essential situations!

10.vim (vi) text editing
This is a bit more complicated, so let's just say that simple operations can meet our needs. Writing a file is nothing more than writing something in. VI, VIM use up, feel or vim comfortable a bit. Edit a file,

    1. Vim A.txt  

Now that the file is open, but you cannot edit it, type i. Tip Insert, insert State, we can insert text. Finished,Ctrl + C end the input status, type : w, Save does not exit, type : Wq, save exit. What if you don't save a forced exit? Type : q!. Of course, if you just come up and look at the content to exit directly, then type : Q . If you want to find a keyword in the file, you can type/ x. / means search, andx is the keyword.

11.cp File Copy
This command is an abbreviation for the copy Word, such as we want to do a file/directory backup, you can use this command:

    1. CP A.txt A.txt.bak  


In this way, the backup file A.txt.bakis obtained from the a.txt file.
If you want to copy a directory, you need to use the parameter- R:

    1. Cp-r a B   


This allows you to copy the A directory into the B directory.

12.mv File Clipping
This command is an abbreviation for the move word that can be used to cut/rename files and directories.
This command was originally intended to cut the operation, but from its point of view, it is suitable for the name of the duplicate!

    1. MV A C   


A is a file, it can be a directory, the above operation, a file/directory becomes a c file/directory!


13.mount Device Mount

    1. mkdir/media/cdrom  -t Iso9660/dev/cdrom/media/cdrom  

-T iso9660 Optional

14.umount Device Uninstall

    1. Umount/media/cdrom  



15.env Environment Variables

      1. Env  

Linux command finishing-basic operations

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.