http://blog.csdn.net/pipisorry/article/details/44681081
Little TricksDirect view of Linux shell commands and explanations in the command line
Mans command
Help commands for better use under Linux-cheat
#pip Install cheat
$cheat Tar
[better use of Linux help command-cheat]
Copy, paste on the command line
In the Ubuntu Terminal window, the shortcut keys for copying and pasting need to be added shift
Copy: Ctrl+shift+c paste: Ctrl+shift+v
Bash Special parameters
Command!$ after execution!$ the last parameter of the last command as input
!! Represents the previous command
command to execute a command
$ (hostname)
Can do this echo $ (hostname) > 1.txt
You can also execute commands by '
Sed "s/oldstring/newstring/g" ' grep oldstring-rl yourdir '
sudo shell built-in commands
The shell is an interactive application that creates a child process by fork when executing an external command, and then executes by using the Exec to load the external command, but if a command is a shell built-in command, it can only be run directly by the shell. sudo means to fork a process, load the program and run it with the privileges of another user (such as root), so sudo cannot follow the shell's built-in commands, such as: $ sudo cd/sys/kernel/debugfs
Sudo:cd:command not found
In this case, we do not have the root account password, how do we execute the command? One way to do this is to use sudo to get root shell permissions, and then execute the command in the root shell. It is easy to enter the root shell by typing sudo bash to confirm the user's password, at which point you will see that the command prompt displays the current root. Once you have the root shell, you can execute any command without having to enter sudo before each command.
Phi Blog
Shell built-in commands
[Useful Bash Shell built-in Commands (with Examples)]
[CD command: A built-in command]
directory and file operations commands
[Linux file and directory management ]
[Linux file formatting and related processing and SED tools ]
Linux vi Vim command, shortcut key
[Linux VI Vim Command, shortcut key]
Linux unzip, compress command tar
Z is for Gzip,j is for Bzip2,j for XZ. Note. TGZ is the abbreviation for. tar.gz
Compression (multiple files or directories can be simultaneously):
Tar-zcv-f filename.tar.gz fname1 fname2 or dirname1 dirname2
Tar-jcv-f filename.tar.bz2 fname1 fname2 or dirname1 dirname2
Enquiry: Tar-jtv-f filename.tar.bz2
Note: If the For loop compresses multiple directories, use the
dirs=$ (Echo ~/sysreinstall/~/files/desktop/#不能加 "", otherwise the path cannot be found
For DIR in $DIR
Do
Cd
Tar-czf $ (basename $DIR). tar.gz $DIR
Done
Unzip:
Tar-zxv-f Filename.tar.bz2-c directory to unzip
Tar-jxv-f Filename.tar.bz2-c directory to unzip
TAR-XJF extra-cmake-modules_1. 4.0. orig.tar.xz
Compress unzip. zip,. 7z files
sudo apt-get install p7zip p7zip-full p7zip-rar
# 7z a yajiu.7z Yajiu
This command is to compress the folder Yajiu into a 7z package
# 7z x yajiu.7z
This command is to extract all the files in the yajiu.7z, X is extracted to the compressed package named directory
# 7z E yajiu.7z
This command is to extract all the files in the yajiu.7z, E is extracted to the current path, that is, the contents of the compressed package are extracted into the current directory (generally do not use this command)
[Linux compression and decompression. zip and. rar and. 7z Files]
Linux under compression \ decompression rar file
Decompression rar file seems to only use Unrar, 7z extracted only 0kb. Compression also use RAR bar
$sudo apt-get Install rar
$sudo Apt-get Install Unrar
After installation, you can open and unzip the RAR file in the command line or File Manager.
Compression $rar a ***.rar * * *
Decompression Unrar ***.rar
File name garbled when you unzip a compressed file under Windows under Linux
The main reason is that when you compress a file under Windows, it is compressed with the system's default encoding (gbk,gb18030), and the zip file does not have an encoded format, so when you unzip it, it will be uncompressed using the system default format (UTF-8), which is different from the encoding format. Will naturally appear garbled.
Workaround, the code can be declared when extracting the zip file under Linux.
For example, under a Windows Zip compressed file xx.zip, unzip, you can use
$ unzip-o CP936 Xx.zip
In fact, CP936 with GBK, GB18030 is also possible.
Note: The general RAR file in the Linux decompression does not appear garbled file name, the main reason is that the RAR file header declaration of compression encoding. So everyone later for convenience, as far as possible still use RAR compression bar.
Bash commands bulk processing of compressed files
#!/bin/bash
For I in $ (ls | grep ' Zip ')
Do
Unzip-o CP936 ${i}
Done
For I in $ (ls | grep ' rar ')
Do
Unrar ${i}
Done
Linux Download Command wget
wget linkurl-p/usr/local
{nm, wrote the article why only half, really to kneel ... }
Linux commands: Common shell commands and applications