Common LINUX skills

Source: Internet
Author: User
Article Title: Common LINUX skills. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
1. remove ^ M characters
When you FTP some DOS files to unix, you often see an annoying ^ M character behind each file line, there are two simple ways to cancel it. Open the file with "vi", and enter: % s/^ V ^ M/g in Command mode or in unix shell: sed's/^ V ^ M // g' foo> foo. new
  
  
2. use the nohup command
If you want the process to be executed after you exit the system, you can use the NOHUP command, for example, % nohup tar-cf/dev/tape/home. after you exit, log on again, run the 'Ps' command to check that the process is still being executed.
  
3. how to view files
If you only want to view the first five lines of the file, you can use the head command, for example, head-5/etc/passwd. if you want to view the last 10 lines of the file, you can use the tail command, for example: tail-10/etc/passwd. do you know how to view the middle part of the file? You can use the sed command, for example, sed-n'5, 10p'/etc/passwd, to view only rows 5th to 10th of the file.
  
4. calculate the number of files and directories. the following statement can help you calculate the number of files and directories ..
# Ls-l * | grep "^-" | wc-l ---- to count files
# Ls-l * | grep "^ d" | wc-l ----- to count dir
You can also convert the preceding statement into a script or an alias statement.
  
5. the method to only list sub-directories:
Ls-F | grep/$ or
Alias sub = "ls-F | grep/$" (linux)
Ls-l | grep "^ d" or
Ls-lL | grep "^ d" (Solaris)
  
6. use the Find command to change ownership
To change the ownership of all files in the current directory, you can:
Find.-exec chown OWNER. [GROUP] {}\; (Solaris)
Find.-exec chown-r owner. [GROUP] {}\; (Linux)
  
7. list all files in the current directory except for some types of files
Use Ksh and ls! (*. Z) displays all files except *. Z. This command is useful when there are many types of files in a directory.
  
  
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.