Getting Started

ls: (list) ls will list the contents of the current working directory (files or folders)

ls -l : You can view detailed information such as file attributes, size, etc.

ls -a : You can see all files (including hidden files)

ls -d : View directory attribute information, display the directory like a file, instead of displaying the files under it

ls -m : separate the names of each file and directory with a "," sign

ls -t : Show recently modified files on top

 

cd:Change Directory

​ Directory Operations

cd directory name--->make a directory

cd .. ---> return to the previous directory

cd - ---> return to the last directory

cd ~ ----> go back to the current user's home directory

 

pwd : Displays the current working directory of the user (print working directory)

mkdir : used to create a new directory

-p : Create a file directory with a nested cascading relationship

mkdir -p b/{c,d}/{d,e,f}

tree : Display the directory structure in a tree structure, the default is the display status of the current path, all files are displayed

-d : show only folders

-f : show the full path of the file

-L 2 : If there are too many levels, only look at the first two levels, use -L

rmdir : Remove the given directory. . Only empty folders can be deleted.

touch : Create a blank file, set the time of the file.

atime: Access Time   The time when the file or directory was last accessed (read or executed) 
mtime: Modify Time The time when the file or directory was last modified, only for the content. . ctime: Change Time The last time the file (attribute) or directory (attribute) was changed

-a : modify the read time atime

-m : modify the "modified time" mtime

-c : Modify ctime.

-d : Modify atime and mtime at the same time, followed by the date to be modified, that is, you can specify the date. instead of the current time. .

-t : The date to be modified can be followed, that is, the date can be specified. instead of the current time. . Format {YYYYMMDDhhmm}

Note: Time can only be specified after -d and -t.

-m, -d, -t: all modify mtime, but the format is different:

-m Modify mtime to the current time, without parameters. eg: touch -m index.html

-d, -t Modify mtime, followed by parameters.

touch -d "2 days ago" 1.txt

touch -t 201801010101 1.txt

View time parameters:

ls -l 1.txt View mtime

ll --time=atime 1.txt 查看atime

ll --time=ctime 1.txt 查看ctime

Another parameter for viewing time:

ls -lu 1.txt View atime

ls -l 1.txt View mtime

ls -lc 1.txt View ctime

stat : used to display the status information of the file, including inode, atime, mtime, ctime.

The output information of the stat command is more detailed than the output information of the ls command

cp : Used to copy files or directories. Format "cp [options] source file target file"

-i will ask whether to overwrite the target file if it exists


If the target file is a directory, the source file will be copied into that directory.
If the target file is a normal file, it will be asked if you want to overwrite it
. If the target file does not exist, the normal copy operation will be performed

mv : Used to cut or rename files. The cut operation is different from the copy operation because the source file is deleted. Only the cut file is kept.

If you cut a file in the same directory, you are actually renaming it

-i : Interactive operation, when there is a conflict, it will ask

-b : When there is a conflict, the source file will be backed up

 

rm : Used to delete files or directories. . Format "rm [options] file"

One or more files or directories within a directory can be deleted. You can also delete all files and subdirectories of a directory and its subordinates

-r delete the directory, otherwise it cannot be deleted

-ri interactive delete, ask for each delete

-rf Force deletion of file or directory

file : View the type of file. . Format "file filename"

 

 

Pack and compress

Packaging : It is to put several files or folders into a tar file, that is, it becomes a total file. File size is not compressed. The purpose of packaging is to facilitate storage and transmission. There is no obvious effect when multiple pictures or video data are compressed, so they can only be packaged and saved.

Compression : It is to compress the size of the file on the basis of packaging. The principle of compression is to replace the same information in the file with one character. The file size is reduced to achieve the purpose of compression. Compression has a distinct effect on text-based data files.

*.zip files compressed by the zip program

*.gz Files compressed by the gzip program. The most widely used, and gzip compressed files can be decompressed by WinRAR, 7zip software in Windows system

*.bz2 The files compressed by bzip2 program have better compression effect than gzip. It takes a long time.

*.xz xz program compressed files, software with higher compression quality, the biggest problem of xz is that it takes longer.

*.tar The data packaged by the tar program has not been compressed

*.tar.gz The files packaged by the tar program and compressed by gzip

* .tar.bz2 ....

*.tar.xz

tar : used to package or compress or decompress files

-c : create a compressed file

-x : unzip the compressed file

-t : View which files are in the compressed package

-z : compress or decompress with gzip

-j : compress or decompress with bzip2

-v : show the process of compression or decompression

-f : target filename

-C : specify the directory to extract to

-J : Compress by xz, decompress. . capital J

eg:tar -zxvf b.tar.gz -C ./daisy/

 

Linux directory structure

(/) :Root directory. At the topmost level of a hierarchical file system. Lets say it contains all the directories and files

/bin : system executable directory

/sbin: s means super, the executable file of the system administrator.

/boot : store all files used to start the linux system

/dev : Device directory. Linux treats all devices as files and provides only one interface, which is the interface for reading and writing files. The hardware is also abstracted into files. . Everything is a file in linux.

null discards all data written to it

zero will produce a stream of bytes such as wireless zeros.

random generates true randomness

/etc : Various configuration files of the system

/home : The user's home directory. Users other than the root user will have a home directory in their home. If you don't type any parameters in the terminal cd, you will go to the home directory.

/root : The home of the root user, the home of the super administrator. stable

su to enter the super administrator account

exit to log out of the super administrator account

/lib : Stores important library files. Other library files are stored under /usr/lib

/proc : A directory for storing process and system operating status information.

/usr : Software installed by the system. . Equivalent to program files in windows. .

​ There are also executable files bin and sbin, which are generally executable files installed by users themselves.

/opt : programs developed by third parties

 

/run : files in system running

/tmp : Temporary files. Stored for each user. The things that everyone stores here can only be manipulated by you.

/var : used to store volatile data, which will change continuously during the operation of the system. .

 

 

DD

dd: used to generate files according to the specified size and number of data blocks: the device file of /dev/zero in the linux system can provide endless data, because it can be used as the input file of the DD command to generate a file of specified size

if : the name of the input file

of : the name of the output file

bs : set the size of each "block"

count : Set the number of blocks to be copied

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325382779&siteId=291194637