Some UNIX commands that are frequently used from time to time but are useful

Source: Internet
Author: User
Od
The OD (octal dump) filter will convert the input (or file) to octal or other hexadecimal. You need to view
This command is useful when processing binary data files or an unreadable system device file,
For example,/dev/urandom, or a binary data filter.

Dd
This is also a well-known tool, but it is a frightening "Data Replication" command.
It is used to exchange data between a Unix microcomputer and an IBM mainframe through tape. This command still has its
The purpose of the. dd command is simply to copy a file (or stdin/stdout), but it will do some
Change. Below are some possible conversions, such as ASCII/ebcdic, [4] uppercase/lowercase, between input and output
The switch of byte pairs, as well as some work to cut the headers to the end of the input file. dd -- help lists all conversions,
There are some other options for this powerful tool.
1 # convert a file to uppercase:
2
3 dd If = $ filename Conv = ucase> $ filename. uppercase

M4
A hidden treasure, M4 is a powerful macro processing filter. [5] is almost a language.
However, this tool was originally written as a ratfor Preprocessor, but later it was proved that M4 was the sole processor.
In fact, M4 integrates the functions of many tools, such as Eval, TR, awk,
In addition, it also makes macro extension easy.
In the Linux journal question list in April 2004, there is a very good article about the M4 command usage method.

Stty
Display and (or) Modify terminal settings. This complex command can be used in scripts and can be used to control terminal behavior and
Its display output method. See the info page of this command and learn it carefully.

Lsof
List opened files. This command will list all the currently opened files in a detailed table, including
Owner information, dimensions, information related to them, etc. Of course, lsof can also be output to grep and (or)
Awk to analyze its results.

Uptime
Displays the system running time and other statistics.
Bash $ uptime
PM up, 3 users, load average: 0.17, 0.34, 0.27
NOTE: If load average is smaller than or equal to 1, it means that the system will handle it immediately. If
If the load average is greater than 1, it means that the process needs to be queued. If the load average is greater than 3,
This means that the system performance has been significantly reduced.

Fuser
Obtain the ID of a process that is accessing a file or some files (or directories). Using the-K option will kill these processes.
In terms of system security, this command is especially used in scripts to prevent unauthorized users from accessing system services.
It seems very useful.
Bash $ Fuser-U/usr/bin/Vim
/Usr/bin/VIM: 3207e (Bozo)
Bash $ Fuser-U/dev/null
/Dev/null: 3009 (Bozo) 3010 (Bozo) 3197 (Bozo) 3199 (Bozo)
When you normally insert or delete stored media, such as a cd rom or USB flash device, the fuser application also displays
This means that
Some users or processes are accessing this device. You can do this using Fuser-um/dev/device_name,
In this way, you can kill all related processes.
Bash $ umount/mnt/usbdrive
Umount:/mnt/usbdrive: device is busy
Bash $ Fuser-um/dev/usbdrive
/Mnt/usbdrive: 1772c (Bozo)
Bash $ kill-9 1772
Bash $ umount/mnt/usbdrive
The-N option of the fuser can obtain the process that is accessing a port. when used in combination with the Nmap command
Useful.
Root # NMAP localhost. localdomain
Port State Service
25/tcp open SMTP
Root # Fuser-un tcp 25
25/TCP/IP: 2095 (Root)
Root # ps ax | grep 2095 | grep-V grep
2095? SS 0: 00 Sendmail: accepting connections

Ulimit
Set the upper limit of system resources. Generally, the-F option is used for calling, and-F is used to set the file size limit.
Ulimit-F 1000 is to limit the file size to 1 MB ).
Write is-T) option to limit coredump (Translator's note: core dump, memory state when the program crashes to write files)
Size (ulimit-C 0 is not coredumps). Generally, the value of ulimit should be set in
/Etc/profile and (or )~ /. Bash_profile (see Appendix G ).

 
LDD
Displays the dependency of an executable file's shared library.
Bash $ LDD/bin/ls
Libc. so.6 =>/lib/libc. so.6 (0x4000c000)
/Lib/ld-linux.so.2 =>/lib/ld-linux.so.2 (0x80000000)

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.