Linux File System troubleshooting

Source: Internet
Author: User
Linux File System troubleshooting-general Linux technology-Linux technology and application information. For more information, see the following section. Learning reference.

1. How to compress executable files?
In Linux, there is a command similar to pklite and lzexe in dos-gzexe. In addition, the compression ratio can generally exceed 50%, which is useful when the space is tight. For example:/dosc/temp # ls-al
Total 148
-Rwxr-xr-x 1 root 149564 Dec 8 :33 gawk
/Dosc/temp # gzexe gawk
Gawk: 54.5%
/Dosc/temp # ls-al
Total 216
-Rwxr-xr-x 1 root 68710 Dec 8 15:36 gawk
-Rwxr-xr-x 1 root 149564 Dec 8 :33 gawk ~
/Dosc/temp #

2. How do I view the Linux Startup information?
When Linux is started, the information displayed on the screen is too late to be visible. If you are interested in the information, you can run the dmesg command to view it after it is started.

3. How to Deal with files with special characters in the file name?
If you want to delete a file named file, typing rm-file will display invalid option. Since the first character of the file name is-, Linux regards the file name as an option, double quotation marks can be used to enclose the entire file name, so that-file is not considered as a command parameter.

4. How to process a whole directory at a time?
Many common Linux/UNIX commands, such as rm and cp, have a parameter-r, which indicates recursion. You can add the parameter-r to the command to operate the target directory and all its subdirectories, for example, rm-rf/test (f indicates force ), this command completely deletes the sub-directory test in the root directory, which is similar to the deltree in dos. Of course, be careful when using this command. Another example is cp-r/test/test1, which is similar to xcopy/s in dos.

5. What are some useful aliases?
Several aliases that can facilitate operations and reduce misoperations are recommended to put them in the startup file, such as/etc/bashrc.
Alias rm = 'rm-I'
Alias cp = 'cp-I'
Alias mv = 'mv-I'
The first three aliases are used to Prompt confirmation before deleting and overwriting files. The red flag is automatically added. We strongly recommend that Slackware users also add them, this is because files in Linux/UNIX cannot be recovered once they are deleted.
Alias l = 'LS-l'
Alias cd... = 'CD ..'
Alias utar = 'tar xvfz' # parses the * .tar.gz File
Alias inforpm = 'rpm-qpi '# displays rpm package information
Alias scheduled PM = 'rpm-Uhv '# Install the rpm package
Alias listrpm = 'rpm-qpl '# list files in the rpm package
Alias uistrpm = 'rpm-e' # reverse install the rpm package

6. How to Use the command to complete?
Command-Line Completion means that when the entered characters are sufficient to determine the next unique file in the directory, you only need to press the Tab key to automatically complete the remaining parts of the file name. For example, you need to unpack the gcc-2.8.1.tar.gz file under the directory/freesoft. when you type it into tar xvfz/freesoft/g, if the file is the only starting file in the directory, press the Tab key, the command is automatically completed as tar xvfz/freesoft/gcc-2.8.1.tar.gz, which is very convenient.

7. How to copy and paste the character interface?
Character interface: whether it is Slackware or red flag, a program named gpm is automatically run every time after installation. After the program runs, you can copy and paste it with the mouse. The specific method is to hold the left mouse button and drag it to make the place to be copied reversed. At this time, the area to be reversed has been copied, right-click the copied content and paste it at the cursor position.

8. How to quickly access some directories?
Type cd ~ You can access your home directory. Type cd-to enter the previous directory.

9. How to display the file type?
Use the command file to know whether a file is an executable file in ELF format, a Shell Script file, or another format, for example, # file startx.

10. How do I run the command file path?
When you type some commands such as find, shutdown, mount, and startx, do you want to know which directory these files are put in? You can use the command whereis to implement them. For example, # whereis startx.

11. How do I find files?
The find command must add some parameters to check the file, for example, # find/usr-name XF86Setup-print to search for the file XF86Setup in/usr. If you want to know the path of a file, you can use whereis filename.

12. How to delete useless core files?
Sometimes a file named core is generated after the program runs. This file is usually large and useless. You can delete it to release space.

13.where Can I open the .tar.gz file?
To decompress the .tar.gz file, you must first decompress it with gunzip and then decompress it with tar. This can be done once in Linux, for example:
# Tar zxpvf sample.tar.gz.

14. How to display long file names in Windows partitions?
If you find that the long file life in the Windows partition cannot be displayed, you can mount it in vfat mode again. You can modify the/etc/fstab file for the mount partition at startup and change the msdos text to vfat. If you cannot use vfat mount, recompile the core and add support for vfat.

15. How to 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 statements into scripts.

16. How can I view only a few lines of a file?
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
To view the last 10 lines of a file, run the tail command, for example:
Tail-10/etc/passwd
You can use the sed command to view the middle part of the file, for example:
Sed-n'5, 10p'/etc/passwd
In this way, you can only view rows 5th to 10th of the file.

17. A partition is mounted read-only. How can this problem be solved?
The mount-v command shows that the partition can be read and written, but it cannot be written in. The old one is a read-only filesystem.
You can solve the problem as follows:
A: mount-n-o remount, rw <安装点>

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.