Learn Linux basic commands 1

Source: Internet
Author: User
Tags aliases symlink

Used for a long time Linux, but also only used some commands, and did not go into full study, a long time ago bought a "Linux command specification Quick check" manual, there is a CD-ROM, there is a comparative system of the tutorial. So today I want to learn a little bit. The following is just a note of my own usually not used.


Ls-a view all files, including hidden files. Hide files with '. ' As a prefix.

Ls-l c denotes a character device, B represents a block device, L represents a link symbol, D represents a directory,-represents a generic file.

Ls-i View the index node, all the files are preceded by a number, if the two numbers are the same, then the two files are essentially the same file.


Cp-l establish a hard connection.

eg. Cp-l Hello Hardlink.hello

At this point, Hardlink.hello and hello have the same index node number

Cp-i Establish symbolic links.

eg. Cp-i Hello Symlink.hello

At this point, Symlink.hello has a different index node number than Hello, but Symlink.hello points to Hello


Alias to see the aliases that the system has already set up


RmDir Delete Empty directories and cannot be deleted for non-empty directories. The personal feeling that this command is useless, but this can be used as a check whether the directory is not empty.

Mkdir-p can create multiple directories recursively.

eg. Mkdir-p A/B/C/D

At this point, the A directory is created in the current directory and the B directory is created under the A directory, and so on

Rmdir-p can delete multiple empty directories recursively. The premise is that these directories are empty.

eg Rmdir-p A/B/C/D


CHGRP Modify the workgroup.

Chgrp-r the modified directory of the recursive and all files under the directory are modified by the workgroup.

Chgrp-r User dir


chmod U=RWX,G=RW,O=RW Modify the operation permissions of the corresponding file.

chmod u-x Modify the corresponding file +/-increase or decrease the operation permissions

Chmod a indicates that all operation permissions are modified for the u,g,o of the corresponding file


Chown Modify the owner of the file and the workgroup.

Chown-r Root:root dir

At this point, recursively modify the Dir and the owner of all files in the Dir directory as well as the workgroup.

Chown Root dir

At this point, only the owner of Dir is changed


Find./-name "*.c"-exec rm-rf {} \;

At this point, all files with the suffix named. C are found in the current path, and the shell command RM-RF is invoked through-exec, and the results are placed inside a pair of curly braces. finally with "\;" As the Terminator to invoke the external command.


ln connection.

eg. ln log Hard.log

At this point, a hard connection is generated, their device node number is the same (ls-i view), change one of the contents, the other one will change, delete one, the other one is unaffected. It is important to note that hard connections must be made in the same device partition and cannot be hard-wired to the directory. Because the device nodes in each device partition are self-contained.

eg. Ln-s Log Sym.log

A symbolic connection is generated, their device nodes are different, essentially two different files, but the symbolic connection points to that target file (ls-l view). Change one of the contents, the other one will change, but if the target file is deleted, the symbolic connection becomes red and fails. A symbolic connection can be a cross-device partition and can operate on a directory.


Whereis will display the binary file path of the command we normally use, the source file path, and the path to the man manual.

eg. Whereis ls


Which will look in the directory under $path to find the execution path and alias of the command we normally use (UBUNTU9 below does not show aliases alias)

eg. which LS


Touch modifies the time attribute of the file to change the last modification time of the file to the current system time.

Touch file{1,2,3}

At this point, create file1,file2,file3 three empty files in turn.


Locate finding files in a database is much faster than find, but accuracy is based on the use of updatedb to update the cycle of the database.


DD Format output file (I feel like this is so ha ~)

eg. DD if=hello.c conv=ucase OF=NEW.C

At this point, all the letters in the HELLO.C will be capitalized and copied into new.c

eg. DD If=/dev/cdrom Of=mycdrom.iso

At this point, the contents of the CDROM are made into a. iso suffix image

eg. DD if=/dev/fd0 of=myfloppy.img

At this point, the contents of the fd0 are made into a floppy disk with an. img suffix.


DIRNAME/HELLO/HELLO.C get the absolute path where the file is located

This will output the absolute path where the hello.c is located/hello


BaseName removes the path in front of the file path and obtains only the filename.

eg. Basename/hello/world/test.c

This will output the TEST.C

eg. Basename/hello/world/test.c. C

At this point, the test is output. If you want to remove the suffix name, you only need to add the type you want to remove at the end of the command.


PATHCHK/HELLO/HELLO.C is used to detect whether the path is valid as a parameter, and whether it is portable

At this point, if there is no output, the proof is OK


Rename Batch Renaming

eg. Rename File Linux test* (under Debain)

eg. Rename ' s/file/linux/' test* (under Ubuntu)

At this point, all files prefixed with test are looked up in the current directory, and the file characters in those names are changed to Linux

Learn Linux basic commands 1

Related Article

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.