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 six skills in the Linux command line?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article shows you what are the six skills in the Linux command line, which are concise and easy to understand. I hope you can get something through the detailed introduction of this article.

Reasonable use of Linux command line tips can greatly improve our work efficiency and have a lot of fun. Here are six command line tips in the Linux system.

The watchwatch command repeats any commands you give and displays the output. By default, it runs the command every two seconds. Each run of the command overwrites what was displayed in the last run, so you can always see the latest data.

You may use it while waiting for someone to log in. In this case, you can use the watch who command or the watch-n 15 who command to run every 15 seconds instead of every two seconds. In addition, the date and time are displayed in the upper right corner of the terminal window.

$watch-n 5 who Every 5.0s: who stinkbug: Wed Aug 23 14:52:15 2017 shs pts/0 2017-08-23 14:45 (192.168.0.11) zoe pts/1 2017-08-23 08:15 (192.168.0.19) you can also use it to view log files. If the data you display does not change, only the date and time in the corner of the window will change.

$watch tail / var/log/syslog Every 2.0s: tail / var/log/syslog stinkbug: Wed Aug 23 15:16:37 2017 Aug 23 14:45:01 stinkbug CRON [7214]: (root) CMD (command-v debian-sa1 > / dev/nu ll & & debian-sa1 11) Aug 23 14:45:17 stinkbug systemd [1]: Started Session 179 of user shs. Aug 23 14:55:01 stinkbug CRON [7577]: (root) CMD (command-v debian-sa1 > / dev/nu ll & & debian-sa1 1 1) Aug 23 15:05:01 stinkbug CRON [7582]: (root) CMD (command-v debian-sa1 > / dev/nu ll & & debian-sa1 11) Aug 23 15:08:48 stinkbug systemd [1]: Starting Cleanup of Temporary Directories... Aug 23 15:08:48 stinkbug systemd-tmpfiles [7584]: [/ usr/lib/tmpfiles.d/var.conf:1 4] Duplicate line for path "/ var/log", ignoring. Aug 23 15:08:48 stinkbug systemd [1]: Started Cleanup of Temporary Directories. Aug 23 15:13:41 stinkbug systemd [1]: Started Session 182 of user shs. Aug 23 15:14:29 stinkbug systemd [1]: Started Session 183 of user shs. Aug 23 15:15:01 stinkbug CRON [7828]: (root) CMD (command-v debian-sa1 > / dev/nu ll & & debian-sa1 1 1) the output here is similar to that of using the command tail-f / var/log/syslog.

The name of the look command, look, may make us think that it does something similar to watch, but it's actually different. The look command is used to search for words that begin with a specific string.

The $look ecl eclectic eclectic's eclectically eclecticism eclecticism's eclectics eclipse eclipse's eclipsed eclipses eclipsing ecliptic ecliptic'slook command usually helps with the spelling of words, using the / usr/share/dict/words file, unless you specify a file name with the following command:

$look esac .bashrc esac esac esac in this case, it acts like a grep after an awk command, printing only the first word on the matching line.

The man-kman-k command lists the man pages that contain the specified words. It works basically the same as the apropos command.

$man-k logrotate dh_installlogrotate (1)-installlogrotate config files logrotate (8)-rotates, compresses, and mails system logs logrotate.conf (5)-rotates, compresses, and mails system logshelp when you are completely desperate, you may try to use this command, the help command actually displays a list of shell built-in commands. The most surprising thing is that it has quite a number of parameter variables. You might see something like this and start to wonder what these built-in features can do for you:

$help GNU bash, version 4.4.7 (1)-release (i686-pc-linux-gnu) These shell commands are defined internally. Type `help' to see this list. Type `help name' to find out more about the function `name'. Use `info bash' to find out more about the shell in general. Use `man-K'or `info' to find out more about commands not in this list. A star (*) next to a name means that the command is disabled. Job_spec [&] history [- c] [- d offset] [n] or hist > ((expression)) if COMMANDS; then COMMANDS; [elif C >. Filename [arguments] jobs [- lnprs] [jobspec...] Or jobs >: kill [- s sigspec |-n signum |-sigs > [arg... ] Let arg [arg...] [[expression]] local [option] name [= value]... Alias [- p] [name [= value]...] Logout [n] bg [job_spec...] Mapfile [- d delim] [- n count] [- O or > bind [- lpsvPSVX] [- m keymap] [- f file > popd [- n] [+ N |-N] break [n] printf [- v var] format [arguments] builtin [shell-builtin [arg...]] Pushd [- n] [+ N |-N | dir] caller [expr] pwd [- LP] case WORD in [PATTERN [| PATTERN]...) > read [- ers] [- an array] [- d delim] [- > cd [- L | [- P [- e]] [- @]] [dir] readarray [- n count] [- O origin] [- s > command [- pVv] command [arg.] Readonly [- aAf] [name [= value]...] O > compgen [- abcdefgjksuv] [- o option] [> return [n] complete [- abcdefgjksuv] [- pr] [- DE] > select NAME [in WORDS...;] do COMM > compopt [- o | + o option] [- DE] [name.. > set [- abefhkmnptuvxBCHP] [- o option- > continue [n] shift [n] coproc [NAME] command [redirections] shopt [- pqsu] [- o] [optname...] Declare [- aAfFgilnrtux] [- p] [name [= v > source filename [arguments] dirs [- clpv] [+ N] [- N] suspend [- f] disown [- h] [- ar] [jobspec. | pid > test [expr] echo [- neE] [arg.] Time [- p] pipeline enable [- a] [- dnps] [- f filename] [na > times eval [arg...] Trap [- lp] [[arg] signal_spec.] Exec [- cl] [- a name] [command [argume > true exit [n] type [- afptP] name [name...] Export [- fn] [name [= value]...] Or ex > typeset [- aAfFgilnrtux] [- p] name [= v > false ulimit [- SHabcdefiklmnpqrstuvxPT] [l > fc [- e ename] [- lnr] [first] [last] o > umask [- p] [- S] [mode] fg [job_spec] unalias [- a] name [name.] For NAME [in WORDS...]; do COMMAND > unset [- f] [- v] [- n] [name...] For ((exp1; exp2; exp3)); do COMMAN > until COMMANDS; do COMMANDS; done function name {COMMANDS;} or name > variables-Names and meanings of so > getopts optstring name [arg] wait [- n] [id...] The hash [- lr] [- p pathname] [- dt] [name > while COMMANDS; do COMMANDS; done help [- dms] [pattern.] {COMMANDS;} stat-cstat command is used to display important statistics such as file size, owner, user group, index node number, permissions, modification, and access time. This is a very useful command that can display more details than ls-l.

$stat .bashrc File: .bashrc Size: 4048 Blocks: 8 IO Block: 4096 regular file Device: 806h/2054d Inode: 421481 Links: 1 Access: (0644Mob.) Uid: (1000 / shs) Gid: (1000 / shs) Access: 2017-08-23 15Switzerland 1341.781809933-0400 Modify: 2017-06-21 1737 Modify: 11.875157790-0400 Change: 2017-06-21 17 37 11.899157791-0400 Birth:-use the-c option You can specify the fields to view. For example, if you only want to view the file name and access permissions of a file or a series of files, you can do this:

$stat-c'% n% a' .bashrc .bashrc 644 in this command,% n represents the name of each file and% a represents access. % u represents the UID of the numeric type, and% U represents the user name.

$stat-c'% a 'bin/* bin/loop 700 bin/move2nohup bin/move2nohup 700 bin/show_release 700$ stat-c'% n% a% U' bin/* bin/loop 700 shs bin/move2nohup 700 shs bin/nohup.out 600 root bin/show_release 700 shsTAB if you haven't used the tab key to complete the full-text file name, you really missed a very useful command-line technique. The tab key provides filename completion (including directories when using cd). It fills in as many file names as possible before ambiguity occurs (multiple files begin with the same letter. If you have a file named bigplans, another file named bigplans2017 will be ambiguous, you will hear a voice, and you will need to decide whether to press enter or enter 2 and then press tab to select the second file.

What are the six skills in the Linux command line? have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow 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

Development

Wechat

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

12
Report