Should survive on Ubuntu OS (2/3)

Source: Internet
Author: User
Tags temporary file storage

In order to survive on Ubuntu (can look at the kernel and the source and so on, the attention is not engaged in server operations and so on)

Also must understand the common file or directory operation command, no nonsense, directly on the content

Press the TAB Completion command once

Press two tab to list options

Inadvertently read binary not seen CTRL + C or input reset

Get help

Man command name

e.g. man ls

With Linux, as far as possible to avoid using the graphics system, it is necessary, for example, to use the IDE to see the Android source, and then to start the graphical interface


Linux System file Directory basics

remember the main points :

1. Linux has no folder (folders), only directory (directory).

2. The directory structure of Linux is inverted tree (inverted trees).

3. The file path that is recorded from the root directory (/) is called the FQN (fully qualified name) full path name.

4. Current working directory (CWD) is the environment in which certain commands run (each process must be started by its parent process)

5. Catalogs are also one of the documents.



Key Commands :

PWD Displays the current fqn (the bash prompt can only prompt for the last directory)

CD Directory name change directory (the CD is a command inside bash (provided by bash, not system), the path to the command is not found with which)

. Represents the current catalog

.. Indicates a parent directory

-Represents the last working directory

~ User Home Directory (CD-only also means switch to default directory)

which view command path



Some key directories: (and not to introduce too much theory)

/var content frequently changing files or directories placed in this directory

/tmp temporary file storage space (service run of some apps or intermediate result store or user-shared space) (in short, some processes use that directory)

/bin and/usr/bin non-privileged directories,/sbin and/usr/sbin privileged directories, but they all store commonly used executable programs (such as some common bash commands, which can be viewed in the which command name)

/etc System configuration file (general user may only read, but can modify the configuration file)

/root Root User's home directory

/root directory (root of the Linux directory upside-down tree)



A file created by Touch Test.txt


mkdir Create a new empty directory (under the current folder, create a single-level directory, that is, the parent directory must exist)


MKDIR-P Create a multi-tier directory (parent directory can be absent, note overwrite issues)

For example: mkdir new/new1 (This new directory does not exist, is the creation of the New1 directory, by the way, the creation of its parent directory)

> Redirect to non-standard output file, if the file already exists, then delete the original file, re-create a new file


>> Redirect, file end append (re-created if not present)


Echo Displays part of the keyboard input information on the standard output


CP Copy files and directories (can be renamed) (multiple files can be manipulated at one time)

CP Test1.txt Test1_new_name.txt (this is replicated in the same directory)

CP test1.txt Test2.txt .../new_direcotry (copy files from this directory to another directory)

Cp/home/merlin/test.txt. (copy files from other directories to this directory.)


Cp-r Directory 1 Directory 2 directory 3 (Put directory 1, directory 2 move already existing directory 3)


MV Moves files or directories (can be renamed when a single move) (multiple files can be manipulated at one time)

MV Test1.txt Test2.txt (in the same directory, is actually renamed)

MV Test1.txt test2.txt/new_directory (this directory file is moved to another directory)

MV ~/test.txt. (move from another directory to this directory)

MV Directory 1 Directory 2 directory 3 (directory 1, directory 2 moved to directory 3, as long as the directory 3 must already exist, or can only be a single)

MV Directory 1 Directory 2 (directory 1 renamed to directory 2)


(actually just doing one thing, in the file system just record file name changes, that is, change the FQN only---first)


RM file 1 File 2 delete file (actually unlink from file system, files purged with RM can be recovered)

RM-RF Directory name forcibly delete directory (recursive and force)


RmDir Delete Empty Directory


Note the point:

1. Avoid overwriting the original file when redirecting

2. Avoid the CP, the MV when the renaming will overwrite the original existing files

3. When redirecting, note the Order of command execution on the left > right side

For example:

PWD > File1 (at this point the cat file1 results are/home/merlin)

Cat File1 > File1

(Error input file is output Flie, but it is too late, > To see that the file already exists, the file was re-created, but the newly created file is empty, the cat file1 result is empty)


Last Supplemental ls-r directory name

(Recursive display of files or directories within a directory, if you do not specify a directory name, the default is to list subdirectories and files in the current directory, etc.)


Well, don't too much, hope to live on the Ubuntu12.04.5.


Speaking of comparative basis, and the layout is ugly, please gently spit groove
If you think my article to you a little help, please give me a praise, feel relatively low or where write wrong, please hurriedly, high me a sound, thank you.

Three articles per week

Merlin 2015/8/13 Night


Should survive on Ubuntu OS (2/3)

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.