Linux Command Line Cheat Sheet
- 格式:pdf
- 大小:44.98 KB
- 文档页数:2
linux中处理表格相关的命令在Linux中,处理表格相关的命令包括一些用于创建、编辑和查看表格的工具。
以下是一些常用的命令及其用法:1.`awk`:awk是一种强大的文本处理工具,可以用于处理表格数据。
它可以根据指定的规则对文本进行分割和过滤,并执行各种操作。
用法示例:使用awk打印指定表格的特定列。
```arduinoawk'{print$1,$3}'filename.csv```这将打印出CSV文件中第一列和第三列的数据。
2.`cut`:cut用于提取文本文件中的指定列或行。
它可以按照列分隔符或行分隔符对文本进行切割。
用法示例:使用cut提取CSV文件中的特定列。
```arduinocut-d,-f1,3filename.csv```这将提取CSV文件中第一列和第三列的数据。
3.`paste`:paste将多个文件中的行连接起来,形成表格形式。
它可以将多个文件中的行按照指定的分隔符进行合并。
用法示例:使用paste合并两个表格文件。
```arduinopastefile1.txtfile2.txt>merged.txt```这将把file1.txt和file2.txt中的行按照制表符进行合并,并将结果写入merged.txt文件中。
4.`tr`:tr用于删除或替换文本中的字符。
它可以用于删除表格中的空行或空格,或替换表格中的特定字符。
用法示例:使用tr删除CSV文件中的空行。
```bashtr-d'\n'filename.csv>cleaned.csv```这将删除filename.csv文件中的空行,并将结果写入cleaned.csv文件中。
5.`grep`:grep用于从文本中筛选出包含特定模式的行。
它对于查找表格中的特定数据非常有用。
用法示例:使用grep查找CSV文件中包含特定值的行。
```arduinogrep"value"filename.csv```这将输出filename.csv文件中包含"value"的行。
Keyboard ShortcutsCtrl + C Ctrl + Z Ctrl + W Ctrl + UCtrl + KCtrl + Y Ctrl + R Ctrl + O Ctrl + G !!exitKill current processStop process (can be resumed)Cut the word before the cursor Cut part of the line before the cursorCut part of the line after the cursorPaste from clipboard Recall last command Run the recalled command Exit command history Repeat the last command Log out of the sessionShell Command Managementalias [alias]='[command]'watch -n [interval] [command]sleep [interval] && [command]at [hh:mm]man [command]historyCreate command alias Set interval to run a command Postpone command execution Schedule a jobDisplay command manual Print command historyVariableslet "[variable]=[value]"export [variable]declare [variable]="[value]"setecho $[variable]Assign integer value to var Export a Bash variable Declare a Bash variable List variables and functions Display value of the variableDisk Usagedf -h df -l fdisk -l du -ah du -shfindmnt mount [device] [mount_point]Show free space on system Show free nodes on system Disk partition types and sizes Show disk usage for all files Show disk usage for current directoryShow target mount point Mount a deviceDirectory Navigationcd ..cdcd [/location]Move up one levelChange directory to $HOME Change to a speci fied directoryNetwork Managementip addr show ip address add [ip]ifcon fig netstat -pnltu netstat -nutlp whois [domain]dig [domain]dig -x [host]dig -x [ip]host [domain]hostname -l wget [file_url]curl -O [file_url]nslookup [domain]Show IP addressesAssign IP address to interface Show all network interfaces Show active listening ports Show tcp and udp ports Show domain information Show domain's DNS info Domain reverse lookup IP address reverse lookup IP lookup for a domain Show local IP address Download a file from url Download a file from url Show domain informationSystem Management and Infouname -r uname -a uptimehostname hostname -l last reboot date timedatectl cal whoamifinger [username]ulimit [flags] [limit]shutdown [hh:mm]shutdown nowmodprobe [module-name]Show system information Show kernel release info Show uptime length/avg. load Show system hostname Show system IP address Show reboot historyShow current time and dateManage the system clock Show current day and month Show the current user Show user information View or limit system resources Schedule a system shut down Shut down immediately Add a new kernel moduleUsers and Groupsid last who wgroupadd [group]adduser [user]usermod -aG [group] [user]userdel [user]usermodchgrp [group] [directory]Show active user details Show last system logins Show who is logged in Show logged users and activity Add a new group Add a new user Add user to group Delete a userModify user information Change directory groupFile Commandsls ls -a pwdmkdir [name]rm [file]rm -r [directory]rm -rf [directory]cp [file1] [file2]cp -r [directory1] [directory2]mv [filename1] [filename2]ln -s [/path/file] [link]touch [file]more [file]head [file]tail [file]gpg -c [file]gpg [file.gpg]wcls | xargs wccut -d[delimiter] [file][data] | cut -d[delimiter]awk '[pattern] {print $0}' [file]shred -u [file]di ff [file1] [file2]source [file][command] | tee [file]>/dev/nullList files in the directory List files, include hidden files Show current directory Create a directory Remove a fileRecursively remove directory Force remove directory Copy file1 to file2Copy directory1 to directory2Rename a fileCreate symbolic link to file Create a new file Show file contents Show first 10 lines of a file Show last 10 lines of a file Encrypt a file Decrypt a fileCount words/lines/bytes Words/lines/bytes in directory Cut file section and print Cut data section and print Print lines matching a pattern Overwrite and delete a file Compare two files Compile from source code Store command output to a file, skip terminal outputFile Permissionchmod 777 [file]chmod 755 [file]chmod 766 [file]chown [user] [file]chown [user]:[group] [file]File read, write, execute permissions to everyone Full permission to owner,read permissions for others Full permission to owner,read and write for others Change file ownership Change file owner and groupProcess Relatedps pstree pmap topkill [process_id]pkill [process_name]killall [process_name]bg fgfg [job]lsoftrap "[commands]" [signal]waitnohup [command] &Show active process snapshot Show processes as a tree Show process memory usage Show all running processes Kill the process by ID Kill the process by name Kill all processes by name List background processes Most recent suspended job to foregroundBring [job] to foreground List files opened by processes Execute command on signal Pause terminal until process completesRun a process in backgroundFile Transferscp [file.txt] [server/tmp]rsync -a [/location] [/backup/]Create a tar file from a file Sync the contents of a location with the backup directorySearchinggrep [pattern] [file]grep -r [pattern] [directory]locate [name]find [/location]-name [x]find [/location]-size [+100M]Search for a pattern in a file Search a pattern recursively Search for files & directories List items beginning with [x]List items larger than 100MBSSH Loginssh [user]@[host]ssh [host]ssh -p [port] [user]@[host]telnet [host]Connect to host as user Connect to host via port 22Use a non-default port Connect to Telnet via port 23yum search [keyword]yum info [package]yum install [package.rpm]dnf install [package.rpm]rpm -i [package.rpm]rpm -e [package.rpm]apt install [package]tar zxvf [source_code.tar.gz]cd [source_code]./con figure makemake installFind a package by a keyword Package info & summary Install a package with YUM Install a package with DNF Install a local rpm package Remove an rpm package Install a package with APT Install software from source codeLinux Commands Cheat SheetHardware InformationFile CompressionPackage Installationdmesgcat /proc/cpuinfo free -h lshw lsblk lspci -tv lsusb -tv dmidecodehdparm -i /dev/[disk]hdparm -tT /dev/[disk]badblocks -s /dev/[disk]tar cf [file.tar] [file]tar xf [file.tar]tar czf [file.tar.gz]gzip [file]Show bootup messages Show CPU information Show free and used memory Hardware con figuration info Block devices infoTree-diagram of PCI devices Tree-diagram of USB devices Show BIOS hardware info Show disk data info Disk read speed test Unreadable blocks testCreate a tar file from a file Extract archived file Create a gzip tar file Create a gz compressed file。
常用的liuex命令liuex是一种文本编辑器,它是Linux系统中最常用的编辑器之一。
liuex具有强大的功能和灵活的配置选项,可以满足各种文本编辑需求。
在本文中,我们将介绍一些常用的liuex命令,以帮助您更好地使用这个编辑器。
1. 打开文件要打开一个文件,只需在终端中输入以下命令:liuex filename其中,filename是您要打开的文件名。
如果文件不存在,则会创建一个新文件。
2. 保存文件要保存文件,只需按下Esc键,然后输入以下命令::w这将把文件保存到当前目录中。
如果您想将文件保存到其他目录中,请使用以下命令::w /path/to/directory/filename其中,/path/to/directory是您要保存文件的目录路径,filename是您要保存的文件名。
3. 退出liuex要退出liuex,只需按下Esc键,然后输入以下命令::q如果您对文件进行了更改并想强制退出liuex,请使用以下命令: :q!4. 复制和粘贴要复制一行文本,请将光标移动到该行并按下yy键。
要粘贴复制的文本,请将光标移动到要粘贴的位置并按下p键。
5. 搜索和替换要搜索文本,请按下/键,然后输入要搜索的文本。
要替换文本,请按下:键,然后输入以下命令::%s/old_text/new_text/g其中,old_text是要替换的文本,new_text是要替换为的文本。
6. 撤消和重做要撤消上一次操作,请按下u键。
要重做上一次操作,请按下Ctrl+r键。
7. 移动光标要向上移动一行,请按下k键。
要向下移动一行,请按下j键。
要向左移动一个字符,请按下h键。
要向右移动一个字符,请按下l 键。
总结liuex是一种功能强大的文本编辑器,它可以帮助您更好地编辑文本文件。
本文介绍了一些常用的liuex命令,包括打开文件、保存文件、退出liuex、复制和粘贴、搜索和替换、撤消和重做以及移动光标。
希望这些命令可以帮助您更好地使用liuex。
炫酷的Linux终端命令大全Linux是一套免费使用和自由传播的类Unix操作系统,是一个基于POSIX和UNIX的多用户、多任务、支持多线程和多CPU的操作系统。
接下来是小编为大家收集的炫酷的Linux终端命令大全,希望能帮到大家。
炫酷的Linux终端命令大全1.命令行日常系快捷键如下的快捷方式非常有用,能够极大的提升你的工作效率:CTRL + U -剪切光标前的内容CTRL + K -剪切光标至行末的内容CTRL + Y -粘贴CTRL + E -移动光标到行末CTRL + A -移动光标到行首ALT + F -跳向下一个空格ALT + B -跳回上一个空格ALT + Backspace -删除前一个单词CTRL + W -剪切光标后一个单词Shift + Insert -向终端内粘贴文本那么为了让上述内容更易理解来看下面的这行命令。
sudo apt-get intall programname如你所见,命令中存在拼写错误,为了正常执行需要把“intall”替换成“install”。
想象现在光标正在行末,我们有很多的方法将她退回单词install 并替换它。
我可以按两次ALT+B这样光标就会在如下的位置(这里用指代光标的位置)。
sudo apt-get^intall programname现在你可以按两下方向键并将“s”插入到install中去了。
如果你想将浏览器中的文本复制到终端,可以使用快捷键"shift + insert"。
2. SUDO !!如果你还不知道这个命令,我觉得你应该好好感谢我,因为如果你不知道的话,那每次你在输入长串命令后看到“permission denied”后一定会痛苦不堪。
sudo !!如何使用sudo 很简单。
试想你刚输入了如下命令:apt-get install ranger一定会出现“Permission denied”,除非你已经登录了足够高权限的账户。
Linux终端命令的快捷键Linux终端是开源且广泛使用的操作系统终端,它提供了丰富的命令和功能来帮助用户管理和操作系统。
为了提高工作效率,熟练掌握终端命令的快捷键是非常重要的。
本文将介绍一些常用的Linux终端命令的快捷键,以帮助读者更高效地使用Linux终端。
1. 全局快捷键在终端中,有一些全局快捷键可以用于在不同命令之间切换,以及执行常见的操作。
以下是一些常用的全局快捷键:- Ctrl + C:终止当前正在运行的命令。
- Ctrl + Z:将当前命令放入后台,并暂停它的执行。
- Ctrl + D:退出当前的终端会话。
- Ctrl + L:清屏,相当于执行clear命令。
- Ctrl + R:在历史命令中进行逆向搜索。
- Ctrl + S:暂停输出到终端。
- Ctrl + Q:恢复输出到终端。
这些全局快捷键能够快速有效地帮助用户进行操作和导航。
2. 命令行编辑快捷键在终端中,命令行编辑是一个非常实用的功能,它可以帮助用户快速编辑和修改命令。
以下是一些常用的命令行编辑快捷键:- Ctrl + A:将光标移动到行首。
- Ctrl + E:将光标移动到行尾。
- Ctrl + W:删除光标前的一个单词。
- Ctrl + K:删除光标位置到行尾的所有内容。
- Ctrl + U:删除光标位置到行首的所有内容。
- Ctrl + Y:粘贴最后一次剪切的内容。
- Ctrl + _:撤销最后一次操作。
这些命令行编辑快捷键可以帮助用户快速进行修改和调整命令,提高输入效率。
3. 历史命令快捷键终端可以记住用户执行的历史命令,并提供一些快捷键来访问和重复执行这些命令。
以下是一些常用的历史命令快捷键:- 上箭头:执行上一个历史命令。
- 下箭头:执行下一个历史命令。
- !!:执行上一个历史命令。
- !n:执行第n个历史命令(n为命令编号)。
- !-n:执行倒数第n个历史命令。
- Ctrl + R:逆向搜索历史命令。
- Ctrl + G:退出历史搜索。
Linux系统自定义快捷命令的详细说明
Linux系统用户可以自定义喜欢的快捷键命令。
下面由店铺为大家整理了Linux系统自定义快捷键命令的详细说明,希望对大家有帮助!
Linux系统自定义快捷命令的详细说明
目前总结到的有两种方式,一种是临时快捷键,一种是永久快捷键。
Linux系统自定义临时快捷键
1)临时快捷键: 使用alias命令设置别名,有点像c语言中的#define定义
例如,想用".."替代“cd ..”
那么可以在命令行输入:$alias ..='cd ..'
即可实现,以后在用到cd ..时,只需要..即可。
尽管该功能已经很方便,很强大了,但是有一个缺点,即这个别名会在机器重启后失效。
所以,为了避免这种情况,你也可以使用第二种方法。
Linux系统自定义永久快捷键
2)永久快捷键:即将1)中的设置,保存文件,并执行使其生效
步骤:
1)编辑用户目录下的.bashrc文件,例如使用vi编辑器,vi ~/.bashrc
2) 将你想设置的快捷键,保存至.bashrc, 例如
alias ..='cd ..'
alias clone='git clone http://192.26.72.1:8080/sever/master' 注意:=左右两边不要有空格
3) 保存退出.bashrc后,使用命令
source ~/.bashrc
重新执行刚才保存的文件使其立即生效,而省去注销重新登录的麻烦。
ok,到此,永久快捷键就设置完成了。
Linux控制字符(快捷键组合)修改终端或文本显示的行为.控制字符以CONTROL + key 组合.控制字符在脚本中不能正常使用.Ctl-B光标后退,这应该依赖于bash 输入的风格,默认是emacs 风格的.Ctl-C Break,终止前台工作.Ctl-D从当前shell 登出(和exit 很像)"EOF"(文件结束符).这也能从stdin 中终止输入.在console 或者在xterm window 中输入的时候,Ctl-D 将删除光标下字符.当没有字符时,Ctrl-D 将退出当前会话.在xterm window 也有关闭窗口的效果.Ctl-G beep.在一些老的终端,将响铃.Ctl-H backspace,删除光标前边的字符.如:1#!/bin/bash2# 在一个变量中插入Ctl-H34 a="^H^H" # 两个Ctl-H (backspaces).5 echo "abcdef" # abcdef6 echo -n "abcdef$a " # abcd f7 # 注意结尾的空格^ ^ 两个twice.8 echo -n "abcdef$a" # abcdef9 # 结尾没有空格没有backspace 的效果了(why?).10 # 结果并不像期望的那样11 echo; echoCtl-I 就是tab 键.Ctl-J新行.Ctl-K垂直tab.(垂直tab?新颖,没听过)作用就是删除光标到行尾的字符.Ctl-L clear,清屏.Ctl-M回车Ctl-Q继续(等价于XON 字符),这个继续的标准输入在一个终端里Ctl-S挂起(等价于XOFF 字符),这个被挂起的stdin 在一个终端里,用Ctl-Q 恢复Ctl-U删除光标到行首的所有字符,在某些设置下,删除全行.Ctl-V当输入字符时,Ctl-V 允许插入控制字符.比如,下边2 个例子是等价的echo -e '\x0a'echo <Ctl-V><Ctl-J>Ctl-V在文本编辑器中十分有用,在vim 中一样.Ctl-W删除当前光标到前边的最近一个空格之间的字符.在某些设置下,删除到第一个非字母或数字的字符.Ctl-Z终止前台工作.。
Linux系统exec命令(Linux system exec command)Shell's built-in exec command will not start a new shell, but with the command to be executed by the shell to replace the current process, and will clean up the environment of the old process, and other orders will be executed no longer after the exec command.So, if you are in a shell, an exec ls, then, after the lists the current directory, the himself out of the shell, because the process of the shell has been replaced with the implementation of the ls command only one process, perform over nature also dropped out. To avoid this influence our use, the exec command in a shell script, use the script to invoke this script, call point can use bash a.s h, (a.s h is to store the command scripts), which can build a sub for a.s h shell to carry out, after the execution to exec, the child script process has been replaced by the corresponding exec command.The source command or ". "will not create a shell for the script, but just execute the script contained in the current shell.One exception, however, is that when the exec command is used to manipulate the file descriptor, it does not replace the shell, and when the operation is completed, it will continue to execute the next command.Exec 3 < & 0: this command will also point the operator 3 to the standard input.In addition, this command can be used as an option for the find command, as shown below:(1) in the current directory (containing subdirectories), find all TXT files and find the lines containing the string "bin"/ - name "*.txt" - exec grep "bin" {} \;(2) delete all TXT files in the current directory (including subdirectories)/ -name "*.txt" -exec rm {} \;To summarize a table:Exec command actionExec ls performs ls in the shell, and the ls ends without returning to the original shellExec < file takes the contents of file as the standard input of execExec > file writes the contents of the file as standardExec 3 < file reads the file into fd3The content read in sort < & 3 fd3 is classifiedExec 4 > file will be written to the file in fd4Ls > & 4 ls will not be displayed, directly to fd4, in the file aboveExec 5 < & 4 create fd4 copy fd5Exec 3 < & close fd3The exec execution programAlthough exec and source are executed directly in the parent process, exec is a big difference from source, which executes shell scripts and returns the previous shell. The exec execution does not return to the previous shell, but instead, the previous login shell is viewed as a program and copied on it.Example:Root @ localhost: ~ / test# exec lsExp1 exp1 exp5 Linux - 2.6.27.54 ngis_post. Sh test xen - 3.0.1 - installThe < logout >Root @ localhost: ~ / test# exec > textRoot @ localhost: ~ / test# lsRoot @ localhost: ~ / test# PWDRoot @ localhost: ~ / test# echo "hello!"Root @ localhost: ~ / test# exec > / dev/ttyRoot @ localhost: ~ / test# cat textexp1exp5Linux - 2.6.27.54Ngis_post. ShThe testThe textXen 3.0.1 - install/ root/testHello!Root @ localhost: ~ / test#Exec > text is the standard output that opens the current shell to the text fileRoot @ localhost: ~ / test# cat testlsThe PwdRoot @ localhost: ~ / test# bashRoot @ localhost: ~ / test# exec < testRoot @ localhost: ~ / test# lsExp1 exp1 exp5 Linux - 2.6.27.54 ngis_post. Sh test text xen - 3.0.1 - installRoot @ localhost: ~ / test# PWD/ root/testRoot @ localhost: ~ / test#Root @localhost: ~ / test# exit # is executed automatically2. Redirection of execFirst, let's look at it in the /dev/fd/directory:Root @ localhost: ~ / test# CD/dev/fdRoot @ localhost: / dev/fd# ls0 1 2 255The default is to have these four items: 0 is the standard input, and the default is the keyboard.1 is standard output, and the default is screen/dev/tty2 is standard error, and the default is the screen255When we execute exec 3 > test:Root @ localhost: / dev/fd# exec 3 > / root/test/testRoot @ localhost: / dev/fd# ls0, 1, 2, 255, 3Root @ localhost: / dev/fd#See, there's a 3 more, which is to add a device, and you can also see the idea of the Linux device as a file. At this point, fd3 is equivalent to a pipe, and the file redirected to fd3 will be written in test. To close this redirect you can use exec 3 > &.Root @ localhost: / dev/fd# who > & 3Root @ localhost: / dev/fd# ls > & 3Root @ localhost: / dev/fd# exec 3 > & -Root @ localhost: / dev/fd# cat/root/test/teThe test textRoot @ localhost: / dev/fd# cat/root/test/test Root devices tty1 01:13 2010-11-16Root PTS / 0 2010-11-15 22:01 (192.168.0.1) Root PTS / 2 2010-11-16 01:02 (192.168.0.1)one225533. Application example:The exec < 3 testWhile read-u 3 PKGThe doEcho $PKG ""The doneThe system calls exec to replace the original process with a new process, but the PID of the process remains the same. Therefore, you can think that the exec system call does not create a new process, but simply replaces the content of the original process context. The code segment of the original process, the data section,The stack segment is replaced by a new process.A process mainly includes the following aspects:(1) an executable program(2) all data associated with the process (including variables, memory, buffers)(3) program context (program counter PC, where to save the program)2. Exec is a function cluster consisting of six functions, which are the excel and execv.Executing the exec system call, which is generally the case, creates a new process using the fork () function and then lets the process execute the exec call. We know that in the fork () to establish a new process, the parent into the Shared with the child process code, but the data space is separated, but the parent would be to copy the content of the data space to the child, and context can also copy to the child process. And in order to improve the efficiency, the strategy of using a writtencopy, creating the child process, do not copy the parent process's address space, share a common address space, a parent and child process only when the child process will need to write data (e.g., to write data buffer), then will duplicate the address space, copy the buffer to the child process. Thus, the father-son process has a separate address space. With the exec after fork (), this strategy can improve efficiency, and if you start with copy, after exec, the data of the child process will be discarded and replaced by the new process.3. The difference between exec and system(1) exec is directly used to replace the original program with the new process, and does not return to the original program after running.(2) system is to call the shell to execute your command, system = fork + exec + waitpid, after execution, go back to the original program. Continue with the following sections.In short, if you call from exec, you should first fork a new process, and then exec. And system doesn't need your new fork process, it's already wrapped.Exec I/O redirection details and application examples1. Basic concepts (this is a prerequisite for understanding the later knowledge, please understand)A, I/O redirects are usually associated with FD, and the shell FD is usually 10, which is 0 to 9;B. There are 3 common FD, which are 0 (stdin, standard input),1 (stdout),2 (stderr, standard error output), and the default is related to keyboard, monitor and monitor.C. To change the data channel (stdout, stderr) sent out to the specified file;E, 0 is the same thing as 1 BBB 0;F. In the IO redirection, stdout and stderr will be prepared before the stdin is read into the data;G, pipe line: the stdout of the last command received stdin from the next command;H, tee command is to copy stdout into a file without affecting the original I/O.I, bash (KSH) execute the command: the process of the analysis command - variables evaluated - command substitution (` ` and $()) - redirect - wildcard expansion - determine the path - execute commands;J. () put the command group in sub - shell to execute,Also known as the nested sub-shell, it has a very important feature: Standard input, output, and error plus any other open file descriptors that inherit the parent shell.K, exec commands: commonly used to replace the current shelland restart a shell, in other words, no subshell is started. Any existing environment will be cleared when using this command. When the exec is working on the file descriptor, it is only at this point that the exec does not cover your current shell environment.2. The CMD & n USES the system to call dup (2) to copy the file descriptor n and use the results as standard output- close standard outputN & - - means to close the n outputAll of the above can lead to a number, and the file descriptor set up at this point is specified by this number instead of the default 0 or 1. Such as:... 2 > file runs a command and directs the error output (file descriptor 2) to file.... 2 > & 1 runs a command and combines its standard output and output. (strictly, file descriptor 2 is created by copying file descriptor 1, but the effect is usually a combination of two streams.)We have 2 > &1 detailed descriptions: 2 > &1 FD2 = FD1, here is not to say that value is equal to the value of FD1 and FD2 because > is change the data channel is sent out, that is, the "data output channel" the FD2 FD1 "data output channel" instead. If that's the case, this change doesn't seem to work, because the default output of FD2 and the default output of FD1 are allmonitor, same!However, when FD1 is another file, or even other FD, this has a special purpose. Please be sure to understand this.3. If stdin, stdout, stderr is redirected or closed, but does not save the original FD, can it be restored to the default state?* * * if stdin is turned off, it can't be restored because it will cause an exit.* * * if you redirect or close stdout and stderr, you can recover because they are all sent to monitor by default (but do not know if there will be any other impact). If redirected or closed stdout: exec 1 > & 2, restore the redirected or closed stderr: exec 2 > & 1.* * * if stdout and stderr are all closed, and there is no original FD, you can use: exec 1 > / dev/tty restore.4, CMD > a 2 > a and CMD > a 2 > & 1 why different?CMD > a 2 > a: stdout and stderr are sent directly to file a, and the a file will be opened twice, resulting in stdout and stderr overlapping each other.CMD > a 2 > &1: stdout is sent straight to file a, stderr is the pipe that inherits FD1 and is sent to file a. The a file is opened only once, which is FD1 to open it.I think: their difference is:CMD > a 2 > a is equivalent to using two pipes that compete with each other using file a;And CMD > a 2 > & 1 just used a pipe,。
Linux终端命令解析sc命令的实用技巧在Linux系统中,终端命令是执行各种任务和操作的核心工具。
其中,sc命令是一款强大实用的命令行工具,用于处理电子表格数据。
本文将介绍sc命令的基本用法和一些实用技巧,帮助您更高效地处理电子表格。
1. 安装与启动sc命令在开始之前,您需要确保已经安装了sc命令。
使用以下命令在终端中安装sc:```sudo apt-get install sc```安装完成后,使用以下命令启动sc:```sc```2. 创建与编辑电子表格使用sc命令创建和编辑电子表格很简单。
在sc界面中,可以通过移动光标,输入或编辑内容来操作电子表格。
以下是基本的编辑和导航命令:- 使用方向键控制光标移动;- 按下Enter键可以输入或编辑单元格内容;- 使用Ctrl + D和Ctrl + U向下或向上滚动页面;- 使用Ctrl + R和Ctrl + L向右或向左滚动页面;- 使用:q退出sc。
3. 基本电子表格操作sc命令提供了许多基本的电子表格操作功能。
以下是一些常用的命令及其功能:- Ctrl + G:显示帮助文档,查看sc命令的使用说明;- :read file:从文件中读取数据到当前电子表格;- :write file:将当前电子表格保存到文件中;- :name new_name:重命名当前电子表格;- :goto cell:跳转到指定的单元格;- :format cell format:设置单元格的格式,如日期、数值、文本等;- :sumrange cell1 cell2 cell3:对指定范围内的单元格进行求和操作;- :sort range:对指定范围内的单元格进行排序操作;- :hidecols cell1 cell2:隐藏指定范围内的列;- :hiderows cell1 cell2:隐藏指定范围内的行。
4. 数据处理与计算sc命令不仅可以创建和编辑电子表格,还可以进行各种数据处理和计算操作。
Linux终端小技巧如何同时运行多个命令Linux 终端是一个功能强大的工具,用户可以通过终端运行各种命令。
在某些情况下,我们希望同时执行多个命令,以提高工作效率。
本文将介绍几种实用的技巧,帮助你在 Linux 终端中同时运行多个命令。
1. 使用分号分号是用于在一行中分隔多个命令的字符。
通过在每个命令之间使用分号,你可以实现同时运行多个命令。
例如:```command1; command2; command3```这将先执行 `command1`,然后是 `command2`,最后是 `command3`。
2. 使用连接符 &&连接符 `&&` 可以在运行一个命令之前先检查之前的命令是否成功执行。
如果前一个命令成功执行,才会执行下一个命令。
这在需要确保每个命令按顺序执行的情况下很有用。
例如:```command1 && command2 && command3```只有在 `command1` 成功执行后才会执行 `command2`,以此类推。
3. 使用连接符 ||连接符`||` 则是在运行一个命令之前检查之前的命令是否执行失败。
如果前一个命令执行失败,才会执行下一个命令。
这在需要处理错误或异常情况时很有用。
例如:```command1 || command2 || command3```只有在 `command1` 执行失败后才会执行 `command2`,以此类推。
4. 使用连接符 &连接符 `&` 可以使命令在后台运行,而不会阻塞当前终端。
这对于运行耗时较长的命令或需要保持终端可用性的情况非常有用。
例如:```command1 &command2 &command3 &```这将同时启动 `command1`、`command2` 和 `command3`,并使它们在后台运行。
5. 使用括号和连接符你还可以使用括号结合连接符来组织多个命令,并将其作为一个整体运行。
Linux Command Line Cheat Sheetby Dave Child (DaveChild) via /1/cs/49/Bash Commandsuname -a Show system and kernelhead -n1 /etc/issue Show distributionmount Show mounted filesystemsdate Show system dateuptime Show uptimewhoami Show your usernameman command Show manual for commandBash ShortcutsCTRL-c Stop current commandCTRL-z Sleep programCTRL-a Go to start of lineCTRL-e Go to end of lineCTRL-u Cut from start of lineCTRL-k Cut to end of lineCTRL-r Search history!!Repeat last command!abc Run last command starting with abc!abc:p Print last command starting with abc!$Last argument of previous commandst argument of previous command!*All arguments of previous command^abc^123Run previous command, replacing abcwith 123Bash Variablesenv Show environment variablesecho $NAME Output value of $NAMEvariableexport NAME=valueSet $NAME to value$PATH Executable search path$HOME Home directory$SHELL Current shellIO Redirectioncmd < fileInput of cmd from filecmd1 <(cmd2)Output of cmd2 as file input to cmd1cmd > fileStandard output (stdout) of cmd to filecmd > /dev/nullDiscard stdout of cmdcmd >> fileAppend stdout to filecmd 2> fileError output (stderr) of cmd to filecmd 1>&2stdout to same place as stderrcmd 2>&1stderr to same place as stdoutcmd &> fileEvery output of cmd to fileDirectory Operationspwd Show current directorymkdir dir Make directory dircd dir Change directory to dircd ..Go up a directoryls List filesls Options-a Show all (including hidden)-R Recursive list-r Reverse order-t Sort by last modified-S Sort by file size-l Long listing format-1One file per line-m Comma-separated output-Q Quoted outputSearch Filesgrep patternfilesSearch for pattern in filesgrep -i Case insensitive searchgrep -r Recursive searchgrep -v Inverted searchgrep -o Show matched part of file onlyfind /dir/ -namename*Find files starting with name in dirfind /dir/ -usernameFind files owned by name in dirfind /dir/ -mminnumFind files modifed less than numminutes ago in dirwhereiscommandFind binary / source / manual forcommandlocate file Find file (quick search of systemindex)File Operationstouch file1Create file1cat file1file2Concatenate files and outputless file1View and paginate file1file file1Get type of file1cp file1file2Copy file1 to file2mv file1file2Move file1 to file2rm file1Delete file1head file1Show first 10 lines of file1tail file1Show last 10 lines of file1Nano ShortcutsFilesCtrl-R Read fileCtrl-O Save fileCtrl-X Close fileCut and PasteALT-A Start marking textCTRL-K Cut marked text or lineCTRL-U Paste textNavigate FileALT-/End of fileCTRL-A Beginning of lineCTRL-E End of lineCTRL-C Show line numberCTRL-_Go to line numberSearch FileCTRL-W FindALT-W Find nextCTRL-\Search and replaceMore nano info at:/docs.phpScreen ShortcutsscreenStart a screen session.screen -rResume a screen session.screen -listShow your current screen sessions.CTRL-AActivate commands for screen.CTRL-A cCreate a new instance of terminal.CTRL-A nGo to the next instance of terminal.CTRL-A pGo to the previous instance of terminal.CTRL-A "Show current instances of terminals.CTRL-A ARename the current instance.More screen info at:/software/screen/File Permissionschmod 775 fileChange mode of file to 775chmod -R 600 folderRecursively chmod folder to 600chown user:group fileChange file owner to user and group to groupFile Permission NumbersThe first digit is the owner permission, the second thegroup and the third for everyone.Every output of cmd to filecmd refers to a command.Pipescmd1 | cmd2stdout of cmd1 to cmd2cmd1 |& cmd2stderr of cmd1 to cmd2Command Listscmd1 ; cmd2Run cmd1 then cmd2cmd1 && cmd2Run cmd2 if cmd1 is successfulcmd1 || cmd2Run cmd2 if cmd1 is not successfulcmd &Run cmd in a subshell tail -f file1Output last lines of file1 as it changesProcess Managementps Show snapshot of processestop Show real time processeskill pid Kill process with id pidpkillnameKill process with name namekillallnameKill all processes with names beginningnameWatch a Commandwatch -n 5 'ntpq -p'Issue the 'ntpq -p' command every 5 seconds anddisplay outputCalculate each of the three permission digits byadding the numeric values of the permissions below.4read (r)2write (w)1execute (x)CheatographerDave Child (DaveChild)/davechild/ Cheat SheetThis cheat sheet was published on 28th October, 2011and was last updated on 15th February, 2013.SponsorFeedbackFair, increase your conversion rate today!Try it free!。