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 Linux commands that few people know about?

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

Share

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

Editor to share with you what few people know about Linux commands, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

thirty-two。 Strace Command

Strace is a debugging tool and is mainly used for troubleshooting Linux. It may not be installed by default on your system, and you may need the packages required for apt or yum installation.

Use the strace command to track the execution of a command.

Root@tecmint [~] # strace pwd

Sample output

Execve ("/ bin/pwd", ["pwd"], [/ * 29 vars * /]) = 0 brk (0) = 0x728000 mmap (NULL, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,-1,0) = 0x7f29b0df2000 access ("/ etc/ld.so.preload", R_OK) =-1 ENOENT (No such file or directory) open ("/ etc/ld.so.cache") O_RDONLY) = 3 fstat (3, {st_mode=S_IFREG | 0644, st_size=38427,...}) = 0 mmap (NULL, 38427, PROT_READ, MAP_PRIVATE, 3,0) = 0x7f29b0de8000 close (3) = 0 open ("/ lib64/libc.so.6", O_RDONLY) = 3 read (3) "\ 177ELF\ 2\ 1\ 3\ 0\ 0\ 0\ 0\ 0\ 0\ 0\ 0\ 0\ 0\ 3\ 0 >\ 0\ 1\ 0\ 0\ 0\ 0\ 360\ 355\ 1I Fstat (3, {st_mode=S_IFREG | 0755, st_size=1922152,...}) = 0 mmap (0x3b49000000, 3745960, PROT_READ | PROT_EXEC, MAP_PRIVATE | MAP_DENYWRITE, 3,0) = 0x3b49000000 mprotect (0x3b4918a000, 2093056, PROT_NONE) = 0 mmap (0x3b49389000, 20480, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED | MAP_DENYWRITE, 3, 0x189000) = 0x3b49389000 mmap (0x3b4938e000, 18600, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS,-1 0) = 0x3b4938e000 close (3) = 0 mmap (NULL, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,-1,0) = 0x7f29b0de7000 mmap (NULL, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,-1,0) = 0x7f29b0de6000 mmap (NULL, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,-1,0) = 0x7f29b0de5000....

The strace command has a large number of parameters and options, please refer to the man page for more information.

thirty-three。 Disown-a & & exit command

Most system administrators use the screen command to control jobs that run in the background of the terminal. Let's assume that if you have a long-running job and want to detach it from the terminal, you can use the screen command to do so. But if you don't know how to use screen, then disown can be used as an emergency.

The disown command can run the task continuously in the background, even if you close the terminal session. The syntax of the disown command is:

Root@tecmint [~] # Command; disown-a & & exit

To break away from a long-running task in the terminal again, use the jobs command to find the task number, and then use disown% n, where% n is the job number. To verify that the job is actually running, use the ps or top command. The nohup command is also a substitute for the disown command.

thirty-four。 Getconf LONG_BIT command

Does the above command show whether your machine architecture is 32 bit or 64 bit?

Root@tecmint [~] # getconf LONG_BIT 32

thirty-five。 Date is displayed on the terminal

The following command is a collection of several commands, or rather a script. For people working under shell or terminals, it is a tedious task to see the current system date without a GUI interface. You can check today's date with the 'date' command.

Just type the following command at the prompt and you will see the date and time in the upper right corner of the terminal.

Root@tecmint [~] # while sleep 1 * do tput sc;tput cup 0 $(($(tput cols)-29)); date;tput rc;done &

thirty-six。 Convert command

When writing tutorials, I often need to generate output, most of the time in image format. The above command set is not suitable for me. Suppose I need the output in the image format of the tree command (to the / etc/x11 directory).

Root@tecmint:/etc/X11# tree | convert label:@- / home/avi/tree.png

The output of the above command can be seen in a specific location (here is my home directory), and the file name is tree.png.

thirty-seven。 Watch-t-N1 "date +% T | figlet"

Remember the description of the "figlet" command in our earlier article, "20 Funny Commands of Linux". This command is very cool, this time we will pipe the output to 'figlet' and display an animated electronic clock on the terminal.

Check for yourself and remember that you must have installed figlet on your system and install the required packages with apt or yum.

Root@tecmint [~] # watch-t-N1 "date +% T | figlet"

Sample output

_ _) _ _) | (_) (_) | _\ | | | _ | | _ / _ /\ _ _ | | _) | _ _ | | _ |\ _ _ / (_) _ | / / (_) _ / | _ |

thirty-eight。 Host and dig commands

Although the "host" and "dig" commands are less well known, they are still rarely used. The host command is a DNS query tool.

Root@tecmint [~] # host www.google.com www.google.com has address 173.194.66.147 www.google.com has address 173.194.66.105 www.google.com has address 173.194.66.99 www.google.com has address 173.194.66.104 www.google.com has address 173.194.66.106 www.google.com has address 173.194.66.103 www.google.com has IPv6 address 2a00:1450:400c:c03::68

As a matter of fact, I think the dig command is big. Since I have dig, I don't use nslookup anymore. )

Root@tecmint [~] # dig www.google.com; DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6 www.google.com;; global options: + cmd;; Got answer:;-> > HEADER

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