Make Linux apps more handy

Source: Internet
Author: User

1. Calculate the number of files and the number of directories


The following statement can help you calculate how many files and how many directories
# ls-l * |grep "^-" |wc-l----to count files
# ls-l * |grep "^d" |wc-l-----to Count dir
You can also turn the above statement into a script or alias

2. Display the type of file

Use the command file to let you know whether a file is an elf-formatted executable or a shell
Script file or any other format, for example: #file startx

3. Convert data formats with the DD command

You probably know that the DD command is used to copy data. Especially used to make startup disks. But DD Also
Can be used for data conversion. On the system of the "endian" structure, export the contents of the Ingres database
, the code will have a strange conversion, which takes: "The Cat in the Hat" into a
"HT eac tnit ehh ta", the way to recover data is to use the DD command:
DD If=randys_bad_data Of=marcs_good_data Conv=swab
The last part of the "Conv=swab" tells DD to take the "swap bytes" mode conversion.
Similarly, if you want to convert the data in the EBCDIC format to the ASCII format, you can use the following life
Make:
DD If=ebcdic_file of=ascii_file Conv=ascii
DD's man help shows that there are not less than 10 conversions, take a closer look, the next time you encounter the same problem,
You can use DD to help.


Norton Commander in 6.Linux

After you type command MC at the prompt, you will see an interface similar to Norton Commander
Functions are similar or even more powerful, such as direct-to-tar.gz compression packages
The files are carried out!! (a bit like zipmagic).

7. Enter x directly after booting

Edit the/etc/inittab file and change the id:3:initdefautl to Id:4:initdefautl. No
The search path may be a problem, you have to go directly into the/sbin to perform shutdown.

9. Forced exit X

Sometimes in X because of the program error, the mouse keyboard does not work, this time do not worry, because
Under Linux is almost not as vicious as in Win95, you just need to type Ctrl+alt+back
The space key can be returned to the character interface.


12. How to view Files

If you only want to see the first 5 lines of the file, you can use the Head command, such as: Head-5/etc/passwd
If you want to view the following 10 lines of the file, you can use the tail command, such as: tail-10/etc/
passwd do you know how to view the middle section of a file? You can use the SED command such as: Sed-n
' 5,10p '/etc/passwd so you can view only the 5th line of the file to line 10th.

13. Elimination of the xwindows under the freezing phenomenon

We can use two common methods to eliminate this phenomenon: first, using the composite key on the keyboard
"Ctrl+alt+backspace" to close the currently running task; second, hold down the key first
The "Ctrl+alt+f2" compound key on the disk, let the system switch to another!! Make a table, and then log in
To the system, then execute the "#ps-ax/grep startx" command, which will list your Xserver
Process ID, and then enter the following command on the command line to eliminate the Xwindows
Image: #kill-9 Pid_number, and finally returns to the original flat by the "alt+f1" compound key
Console

14. Use the current path as a prompt

For bash, add a line to the. BASHRC: ps1= "$PWD $"
For tcsh, add a line in. TCSHRC: Set prompt= "%/>"

16. Fix password for super user under Linux

If the Superuser forgets the password, it cannot enter the system or manage and use the system. This
This is unlikely to happen, but in some Linux standalone users, especially beginners,
It is relatively easy to happen. The general solution is to format the hard drive to reinstall the system, but
It's a bit of a fuss. Prepare the Bootdisk and Rootdisk two floppy disks, boot from the floppy drive,
Boot to the root disk and a shell prompt appears. Mount the Linux root partition to the/mnt directory,
For example, if your Linux is on the first partition of the hard disk, enter mount/dev/hda1/mnt on the command line,
Then go to the MNT directory, rename the etc/passwd file, and enter the MV/MNT/ETC/PASSWD
/mnt/etc/passwd.bak, then use the command cp/etc/passwd/mnt/etc/
passwd Copy the/etc/passwd file on the floppy disk to the ETC directory on your hard disk so that you re-
Boot from hard disk, do not ask for super password when logging in, and finally use Mv/etc/passwd.bak
The passwd command changes the passwd file back, and then runs the passwd command to reset the password.

17. Processing a whole catalogue at a time

Linux/unix a lot of common commands, such as RM,CP, have a parameter "-R", is the meaning of recursion
The command add the parameter "-R" to the target directory and all of its subdirectories!! For
Such as:
Rm-rf/test (f is force), this command completely deletes subdirectories under the root directory
Record test, acting like a Dos deltree, of course, use this command with special care.
Again such as: Cp-r/test/test1 has similar DOS under the function of the xcopy/s.

18. List all files in the current directory except for certain types of files

Use Ksh, with LS! (*. Z) can display all files except *. Z file. This command is in a
It is useful to have many types of files in a directory.

19. Make Lilo Boot Disk

Just change the boot=/dev/hdxx in/etc/lilo.conf to/dev/fd0 and then perform Lilo
-V writes Lilo to the disk, and the Lilo boot disk is ready. Note that after the boot disk is finished,
Change the boot=/dev/fd0 back to the original settings and perform the lilo-v write back to the master boot record again
or Super Block.

20. Using the Nohup command

If you want the process to execute after you exit the system, you can use the Nohup command such as:% Nohup
Tar-cf/dev/tape/home & When you exit and then log back in, use the ' ps ' command to
To see that the process is still executing.

Make Linux apps more handy

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.