10 tips using Linux
Write by Ellen Siever
Translate by Guipei
Every user who uses Linux will find their favorite skills, according to our experience and work. Here are some of my experience. These techniques may be very simple, but I found that these simple skills will have the greatest help to our daily work.
Use other console
Linux can use the virtual console to log in to multiple sessions at the same time, so you can do more operations at a time or to log in with another user. Landing additional virtual console seems to be using different physical terminals, you can switch directly, in fact, you are in a terminal.
If you are not in the X system, the virtual console is useful, you can use it in your needs.
In the early kernel version (
1.1.54
Previously), the number of virtual console that can be used is compiled into the kernel. In the nearest kernel, 63 virtual console can be used, the default sets of 6 virtual consoles in the configuration file / etc / inittab.
Using the combination keys Alt Fn can switch the virtual console, FN refers to the function keys from the F1 to F6. (If you are in the X environment, you must use Ctrl-Alt-Fn to switch at the same time). If you run the X system, Alt F7 is used to return to the X system. You can also use the Alt-Right or Alt-Left combination to loop switching in the virtual console you log in.
Temporary use of other shells
Each account has a shell associated with it. LINUX uses Bash by default, a popular alternative is TCSH. The last column of the account password file (/ etc / passwd saves the shell information of the account. You can check your password file or use the finger command. For example, use the command "finger Ellen", in some cases, I will use / bin / tcsh.
Command ChSH can modify the shell used by the default, which means that it modifies the shell content in the account information. Of course, you can also use other shells to use other shells to be implemented by simple commands. To give an example, if I need to do some operations in Bash, I can enter the command bash, execute it in the console. Use the CTRL-D or EXIT command to return to the original TCSH session.
Print Help Manual
Here are some useful little tips about viewing or printing help manuals:
Print help, you can use the following command:
MAN
The role of the command col -b is to remove the retracter or other non-print characters that cause reading difficulties.
If you need to print a book that is not in the standard help directory help (that is, this help file is not in the MANPATH environment variable), you can specify the path to this help file, including a full file name:
Man /work/myapp/mymanpage.1
If you use the Emacs editor, you can use the command Meta-X Man to view the help manual, Emacs can prompt you to help the file. You can view and print it in any Emacs buffer.
The last prompt, use the groff command formatting the help manual. The default output file is PostScript format, you can send a PostScript printer, or use GhostView to view.
Groff -man /work/myapp/mymanpage.1 | ghostview -i
You can use the -a option to output ASCII, the result of the output is an unformatted text. Reading is not very perfect, but if there is no other need, it is also sufficient.
Use the replacement command to simply complex operation
Command Replacement The function allows you to use an output of a command as an input parameter for another command. Use the command to make sure you need the output result, use the backquotes to include the command, and make it an input parameter for another command. For example, I often use the replacement command in GREP to recursively find directory files: grep 'title' `Find / Work -Type F -Name 'Chap *' -Print`> Chaptitles
The content contained in this command is to find files that contain CHAP in the / Work directory. The output result is supplied to the grep command, the grep command queries "title" in the Find result, and the final result is saved to the chaptitles file.
View non-text files
You may need to view a binary file in some time. Maybe you find that there is no help manual (MANPAGE) you need, or you are looking for who developed such a program, or which program you can use.
In fact, text commands can meet your needs very well. It can search a file sequentially then print out what you need. You can use the pipeline command such as more, or you view some text, you can filter content via the grep command.
Use the locate command
Do you need a simpler way to find a file? Try using the locate command, which is more simple and usable compared to the complex Find command:
Locate
This command looks for the file containing their names in the internal database and then outputs the full file name, and you can filter the output results by using the GREP command. For example, the following example looks out all the files containing characters "KDE" and in the directory bin:
Locate KDE | grep bin
Find file names do not have to use all names; but use some characters, such as using "gno" instead of "gnome". Use the parameter -R option to use the regular expression to query:
Locate -r 'gno *'
One problem that needs attention is that the locate command is case sensitive: Find Howto and HOWTO, you will get different results.
Compared with the FIND command, the locate command is looking for from the database instead of each search file system. Because it is found from the database, Locate is far faster than the Find command. However, the result of using the locate command is only in the current database.
The Locate database is updated through cron day task, and you can also manually, use the updatedb command to complete (usually a root user). If you install new programs or delete old files, you don't want to wait until the next day, you can use manual processing.
Use Dmesg to view startup messages
Command Dmesg provides a simple way to view system boot information. When Linux starts, the information of the kernel is stored in the kernel Ring cache, and DMESG can display the contents in the cache. By default, Dmesg prints the content to the screen, of course you can redirect output to a file.
% DMESG> bootmsg
View the kernel version you use
Have you need to know the kernel version of your system? You can see the command uname, it will display your system version information. Use the -r parameter, the uname command prints out the kernel version:
% uname -R
2.2.14
-5.0
The other uname command options provide information such as machine types, operating system names, processors, etc., using the -all option to print out all information.
Use DF and DU to maintain your disk
Use the DF (Display Filesystem, Disk Free) command to view your file system usage and the remaining space. If you have trials and download new software hobbies, you must use it to view your disk information. DF commands have some options, do not use options it will provide basic information list of file systems:% DF
FileSystem
1k-blocks
Used
Available
USE%
Mounted ON
/ DEV / HDA3
1967156
1797786
67688
96%
/
Oh, it's time to clean up space. There is also a DU (Disk USAGE) command to know. The du command provides the file occupied by the file you need, you can provide the use of the entire file system, subdirectories, and directory. You can use DU to view a directory for use, or check the current directory by default.
If you don't want to use the du command in every subdirectory, you can use the -s parameter to do statistics. Here you can specify the directory you want to view in this command, for example:
% du -s / usr / x11r6142264 / usr / x11r6
% du -s / usr / x11r6 / * 34490 / usr / x11r6 / bin1 / usr / x11r6 / doc3354 / usr / x11r6 / incrude
97092 / usr / x11r6 / lib7220 / usr / x11r6 / man106 / usr / x11r6 / share
By using the information provided by DU, you can clean the directory files that occupy space or the archive file you no longer need.
Allow non-root users to load and unload drivers
Under normal circumstances, the system will automatically load the hard disk system when starting, but like a floppy disk and the disc system are generally not loaded until you need to use it, so that you can easily replace the floppy disk or CD. By default, loading and uninstalling systems require root user privileges. However, you can modify this default configuration via file configuration parameters, / etc / fstab, allowing other users to use this command normally. Do this must be added to the option to join the USER configuration parameters.
/ DEV / FD0
/ MNT / FLOPPY
Auto
Noauto, User
0 0
/ dev / cdrom
/ MNT / CDROM
ISO9660
NOAUTO, RO, User, unhat
0 0
You can view file / etc / mtab or run command mount (without any parameters and options) to see what options for what file system is loaded and used.