|
Basic File Operations
ls, rm, mv, ln
ls
ls [option] [files]
With no parameters, lists the contents of the current working directory
$ Ls
Lists the contents of the specified directory
ls dir1
Or individual files
ls file1
Options
-a lists all files, including hidden files and directories (beginning.)
-l displays the file name properties and detail in long format
-h to k, m, etc. units substituted for users to read bytes
-F Type of drum to symbolize the number to modify a specific file name
/ table of Contents
* executable file
@ Symbol files (symbolic links)
l command pipeline (named pipes)
= Communication channels (sockets)
Symbol appended to the file name, you can help us to see at a glance their type, these symbols are not a file name
Part, but ls displayed when added to their own.
-i ask price before filling the file name inode number
-s before the filename raise the number of blocks occupied by the file (1 block typically 1024 bytes)
-R Recursively lists the contents of a directory
-d Lists directory itself, not its contents
cp [option] files (file | dir)
Do not add parameter indicates copy a file
$ Cp srcfile destfile
Copy multiple files to a directory
$ Cp file1 fle2 file3 dir
-a or -R option, you can copy the entire subdirectories recursively
-p together with the access mode of the source file, the time stamp also be copied to the new file, if your permissions allow, owner of the new file, and also belongs to the group and the old files. If you can not specify the owner of the item, the new file is your knee is the current time, and the access mode is the access mode of the source file with your umask intersection.
-a copy the entire directory tree, and retention relationship special file access mode, symbolic links and hard links.
This option is equivalent to specifying -R (contains special files, including the recursive copy), -p (access mode)
-d (link)
-i interactive mode, before overwriting the destination file, first seek the views of users
-f force replication, timely target file already exists, it will be unconditionally overwritten.
mv [option] sources target
Moving and renaming is one thing, move command can also change the file name.
mv file1 file2
The file or directory to another directory
mv file1 file2 dir3 dir4 dest_dir
-i interactive mode
-f Force Mobile
rm [options] files | dirs
rm (remove) command to delete a file
rm file1 file2 file3
You can also delete the entire directory
rm -r dir1 dir3
-i interactive mode
-f Force delete, ignore any error or warning HE
-r recursive call for directory and its content,
ln [options] source target
Link link is a reference to another file reference, there ln command established. Divided into two links, break
No connection (symbolic link) to the "path" to indicate another file, wanted the windows shortcuts
Formula (shorcut) or macintosh alias alias
$ Ln -s myfile softlink
If you delete the source file, the symbolic link file does not exist just because the two paths become invalid. On the other hand, hard links (hard link) is the name of a second physical disk file (with terms, hard links point to the same inode). Delete source files and link failure does not cause that you can still access the contents of the source file with hard links.
$ Ln myfile softlink
Symbolic links can span disk partition, because they are only references to the source file path only. But hard links can not, because inode a partition to another partition does not make sense. Objects can make a symbolic link directory, but not hard links, unless you are superuser and using the -d option.
Common options
-s make a symbolic link (the default behavior is to produce a hard link)
-i interactive mode
-f Force mode, unconditionally be covered
-d allow superuser production directory hard links
Object using one of these commands, you can easily find out why a symbolic link
$ Readlink linkname
$ Ls -l linkname
Directory Operations
cd Change the current working directory
pwd Displays the name of the current working directory
basename display the file path in the end portion
Part dirname like the end of the file path outside
mkdir Create a directory
rmdir to delete empty directories
rm -r remove non-empty directory and its contents
cd [directory] bash
shell built-in commands |
|
|
|