Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the rarely used Linux commands?

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "what are the less used Linux commands", the content is simple and easy to understand, and the organization is clear. I hope it can help you solve your doubts. Let Xiaobian lead you to study and learn "what are the less used Linux commands" this article.

1. pgrep, substitute:

# ps -ef | egrep '^root ' | awk '{print $2}'1234520213839...

You can also do this:

# pgrep -u root1234520213839...

2. pstree, which lists processes in tree format, is very useful when there is webSphere or heavy task application.

# pstreeinit-+-acpid|-atd|-crond|-cups-config-dae|-cupsd|-dbus-daemon-1|-dhclient|-events/0-+-aio/0| |-kacpid| |-kauditd| |-kblockd/0| |-khelper| |-kmirrord| `-2*[pdflush]|-gpm|-hald|-khubd|-2*[kjournald]|-klogd|-kseriod|-ksoftirqd/0|-kswapd0|-login---bash|-5*[mingetty]|-portmap|-rpc.idmapd|-rpc.statd|-2*[sendmail]|-smartd|-sshd---sshd---bash---pstree|-syslogd|-udevd|-vsftpd|-xfs`-xinetd

bc is an arbitrary precision calculator language that can perform square root operations with Shell scripts, expr does not support square roots.

# ./ sqrtUsage: sqrt number# ./ sqrt 648# ./ sqrt 132112363# ./ sqrt 132112132136347Here is the script:# cat sqrt#!/ bin/bashif [ $# -ne 1 ]thenecho 'Usage: sqrt number'exit 1elseecho -e "sqrt($1)\nquit\n" | bc -q -ifi

Do you need to split a large file into smaller pieces?

Split is your command, and here's how to split a 250MB file into 2 MB chunks, all starting with LF_prefix.

# ls -lh largefile-rw-r--r-- 1 root root 251M Feb 19 10:27 largefile# split -b 2m largefile LF_# ls -lh LF_* | head -n 5-rw-r--r-- 1 root root 2.0M Feb 19 10:29 LF_aa-rw-r--r-- 1 root root 2.0M Feb 19 10:29 LF_ab-rw-r--r-- 1 root root 2.0M Feb 19 10:29 LF_ac-rw-r--r-- 1 root root 2.0M Feb 19 10:29 LF_ad-rw-r--r-- 1 root root 2.0M Feb 19 10:29 LF_ae# ls -lh LF_* | wc -l126

5, nl digital line, before the discovery of nl, has been implemented with scripts.

# head wireless.h/** This file define a set of standard wireless extensions** Version : 20 17.2.06** Authors : Jean Tourrilhes - HPL* Copyright (c) 1997-2006 Jean Tourrilhes, All Rights Reserved.*/# ifndef _LINUX_WIRELESS_H# nl wireless.h | head1 /*2 * This file define a set of standard wireless extensions3 *4 * Version : 20 17.2.065 *6 * Authors : Jean Tourrilhes - HPL7 * Copyright (c) 1997-2006 Jean Tourrilhes, All Rights Reserved.8 */9 #ifndef _LINUX_WIRELESS_H

Mkfifo is the coolest one, you must know how to create pipes to transport grep results to LESS, maybe even perl.

But do you know how to make 2 commands communicate through 1 named pipe? Look at the image below, create the pipe and start writing to it.

Then read it:

7, ldd, want to know which Linux thread library java links to?

# ldd /usr/java/jre1.5.0_11/bin/javalibpthread.so.0 => /lib/tls/libpthread.so.0 (0x00bd4000)libdl.so.2 => /lib/libdl.so.2 (0x00b87000)libc.so.6 => /lib/tls/libc.so.6 (0x00a5a000)/lib/ld-linux.so.2 (0x00a3c000)

8, col, want to save the help page as plain text?

# PAGER=cat# man less | col -b > less.txt

9, xmlwf, need to know whether an XML document or configuration file is reasonable?

# curl -s 'http://bashcurescancer.com' > bcc.html# xmlwf bcc.html# perl -i -pe 's@@@g' bcc.html# xmlwf bcc.htmlbcc.html:104:2: mismatched tag

10, lsof lists open files, you can use it to do a lot of cool things, such as finding which interface is open?

# lsof | grep TCPportmap 2587 rpc 4u IPv4 5544 TCP *:sunrpc (LISTEN)rpc.statd 2606 root 6u IPv4 5585 TCP *:668 (LISTEN)sshd 2788 root 3u IPv6 5991 TCP *:ssh (LISTEN)sendmail 2843 root 4u IPv4 6160 TCP badhd:smtp (LISTEN)vsftpd 9337 root 3u IPv4 34949 TCP *:ftp (LISTEN)cupsd 16459 root 0u IPv4 41061 TCP badhd:ipp (LISTEN)sshd 16892 root 3u IPv6 61003 TCP badhd.mshome.net:ssh->kontiki.mshome.net:4661 (ESTABLISHED)Note: OpenBSD 101 pointed out that "lsof -i TCP" a better way to obtain this same information. Thanks! Or find the number of open files a user has. Very important for running big applications like Oracle, DB2, or WebSphere:# lsof | grep ' root ' | awk '{print $NF}' | sort | uniq | wc -l179

Hint, anonymous commenter pointed out that "sort-u" should be used instead of sort| uniq, I forgot-u flag, thank you!

The above is "What are the less used Linux commands" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report