Learned two days, finally learned the basic command, master later can be half a programmer. (^∇^*)
This article is a memo or query notes, if which big guy saw and very dislike, but also please big guy give advice, forgive
The following is my class do some notes, very messy, (⊙﹏⊙ anyway is to see their own
Day1:
Using Ubuntu as an example, Ctrl + Shift + ‘+’ up Ctrl + ‘-‘ down ls displays all file names and folder names in the current path. Ubuntu has no concept of drive letters, only a root directory
Bin is the program related to boot and Ubuntu boot, The default directory to look for is under the home directory Sakura in the home directory Ls by default displays all file names and folder names in the Sakura folder under the home file in the root directory
/ diagonal \ backslash – rail _ _ | vertical poles
Clear Clear the screen CD Switch the directory touch File name Command for creating a file mkdir Folder name Command for creating a folder
If the name of the created file is. Start, indicating that the file is a hidden file such as touch.123.txt
Ls -a Displays all files (including hidden files)
Ls -l Display list ls -L -h Display file unit size ls -a -L -h Display file unit size ls -a -L -h Display file unit size ls -a -L -h Display file unit size ls -a -L -h Display file unit size ls -ALh / -lah /… So this is the same thing
Vi File name Edit the file
Ls (command) –help View the help documentation for ls
200-300 Commands Man ls To view a document The up and down keys of the ls command are used to adjust the subtitle of the document. The F key is used to switch from the next screen to the previous screen. The B key is used to switch from the previous screen to the previous screen
Gedit file name Command for editing file content TAB Automatic completion command
Cat file name View file contents The history command displays all the commands you have executed before
! Number of lines Run the command corresponding to the number of lines (you can find the corresponding number of lines in history)
Rm Command to delete the file name
Ls 1* lists all files starting with 1. Wildcard * replaces N digits. There is also a wildcard that replaces digits
ls 2? (a question mark represents a digit number) 23 ls 1? 3. TXT lists all files that meet the requirements in the case of the same bits 1 and 3
Ls 1[12345]3 is a regular expression, and ls 1[1-5]3 is a regular expression. If the first and third bits are the same, all files that meet the current range of the second bits are 1-5
Redirection Writes the content that would otherwise be displayed on the terminal to a file. This is called redirection
The demo sample
TXT file, equivalent to save ls display content in XXX. TXT file, open the result can be viewed ls alh > XXX. TXT is also the same meaning
ls >> xxx.txt
If there is content in the current xxx. TXT file, >> means to append content, which means to add new content to the original content and > means to delete the original content and add a new content to the file
TXT Command to view file contents The difference between the more command and the cat command is as follows: the cat command displays all contents at one time, while the more command displays one screen. The F key can switch to the next screen, and the B key can switch to the previous screen. The more command can be handy for large files (with a lot of content)
Ls – leisure/bin | more to show all the content to | inside, and then to call through more | to show the effect of the split screen | called pipes
If you want to run two commands at the same time, such as ls and ls-alh, then we can use a semicolon to separate the two commands: ls; ls -alh
CD/root directory/Other Directory /… /
CD./ desktop point. Indicates the current path CD.. Indicates the upper path of the current path
cd .. /.. Indicates the previous path of the current path such as the current path /home/sakura/ desktop CD.. /.. The result is /home
CD/Skip directly to the root directory CD – Send to the path where you worked last time (remember only once) CD ~ Return to the user’s home directory, that is, the default original path /home/sakura
Current understanding of the concept: colored files are folders and uncolored files are ordinary files
Ctrl+C does not execute, terminates, equivalent to a line break
Rm *. TXT Delete all. TXT files (using wildcard characters)
Tree Displays contents in the form of a directory tree
Mkdir A/B/C/D/E -p for recursive create directory p for parents If you want to create A and subdirectory B under A, you can’t do it without -p
Rmdir Folder name Deletes the folder in the current path
Rmdir cannot delete non-empty folders, but rm can delete both files and folders. When deleting folders, you need to add an option: -r rm folder name -r recursive processing. All files in the specified directory are processed together with subdirectories
Mv Original file name New file name This command can be used to rename a file or folder
Softlink data in the hardlink file -> 1. TXT <– 1.softlink. TXT -> 1.hardlink. TXT
Ln -s Source file Destination file
ln -s 1.txt 1-softlink.txt
One file (source file) creates a different link (target file) in another location. -s stands for software. With -s, this link is called a soft link, which is equivalent to a shortcut in Windows
Ln 1.txt 1-hardlink. TXT create a hardlink even after deleting the source file. A hardlink is equivalent to copying a source file, you can open and read the content in the source file
Grep “content” file name Search for “content” in the current file. Grep -v “Content” file name Search for “content” in the current file. -v Indicates whether the current file does not contain “content”
For example, grep “NTFS” xxx. TXT indicates the search for things in the xxx. TXT file that contain NTFS content, and grep -v “NTFS” xxx. TXT indicates the search for things in the xxx. TXT file that do not contain NTFS content
TXT ^ The upward arrow means to start from the beginning. If we want to search the content ending with NTFS, we use the following command: grep “NTFS $” xxx. TXT $indicates that the content ending with NTFS is the current content
Mv file name Folder name/Cut and paste the current file into the target folder
As a side feature, rename a file or folder
Mv Original file name New file name This command can be used to rename a file or folder
Cp file name Folder name Copy and paste the current file to the target folder. To copy A folder, add -r to the end. For example, cp A B/ -r Copy folder A to folder B
Day2:
Find / -name “*name*” * is a wildcard character that means to find files in the current directory that have the name. -name means to find files by name. Sudo find / -name “*name*”
Find / -name “name” Finds files whose full name is name in the current directory
Sudo find / -size 1G Searches for files of 1 GB size in the current directory
Sudo find / -size +1G Searches for files larger than 1 GB in the current directory. Sudo find / -size -1G Searches for files smaller than 1 GB in the current directory
Ll This command is equivalent to the ls -la command
Tar -cvf Package name Files to be packed The files to be packed in the current path are packed to the specified package. Only the tar -xvf package name is used to decompress the packages in the current path
Tar -cvf test.tar *. Py Package the files ending in. Py in the current path to the test.tar file tar -xvf test.tar Decompress the test.tar package to the current path
Tar -zcvf xxx.tar.gz *. Py Packs the files (.py files) that need to be packed in the current directory into the specified package (xxx.tar) and compresses -z. Gz tar -zxvf XXX.tar. gz Decompress the XXX.tar. gz package. -z indicates the operation for the compressed files ending in
Bz2 *. Py package and compress the *. Py file into the yyy.tar.bz2 file. -j Indicates the command for the compression mode ending in -j is the command for compression mode ending in. Bz2
Zip zzz.zip *. Py Package and compress the *. Py file into zzz.zip unzip zzz.zip Decompress zzz.zip
Summary:.gz ending files <.bz2 ending files <.zip ending files.rar ending files
The. Zip file is decompressed in -d./ upzip -d./test myzip.zip
Gz The specified path for decompressing the. Gz file is -c specified directory/tar -zxvf test.tar.gz -c dongge/
All the commands we type are a file in the bin/ folder
Which is used to find and display the absolute path to a given command
Which ls The result is /bin/ls
CAL Displays the current date and year
Cal-y Year Displays the calendar for the entire year of the specified year
Date Displays the current time
Date “+ % % m Y = = = = = = = = = = % d” display the current date + representative results for 2018 = = = = = = = = = = 02 26 date Y = = = = = “+ % % m = = = = = % d” displays the current date + on behalf of the display The result is 18=====02=====26 Here’s the difference
Date “+%Y year %m month %d date “result = February 26, 2018
Date Indicates the time
Ps (process process) Displays process information
Ps-aux Displays information about all processes from beginning to end
Top Displays the running status of the current computer process
Htop View the current running status of the computer
Ps top HTOP Is used to view the current running status of the PC
Kill -9 9822 First of all, -9 means to forcibly shut down the process code 9822, and to check the code code, just hit the ps command
Reboot Restart command
The computer will shutdown automatically at 8:20 this evening
Init 0 Power off init 6 Restart
df
Df -h Displays the current disk usage
You can view the IP address or change the IP address by using the ifconfig command. You can ping the IP address to check whether a certain network segment is connected
Sudo useradd account name -m to add a new account command -m means to create a folder in the /home directory with the name of the account
Ls /home/home contains user information. You can view user information
Cat /etc/passwd You can view the number and information about users in the last line
Su user Switch user command
Sudo passwd Username Changes the password of a user
Whoami Displays the current user name
Exit Exits the current user
Ubuntu has multi-user capabilities
SSH Username@IP address Remotely log in to a PC
Ctrl+Shift+ T opens multiple terminals and merges them
Alt+ number key (not keypad) to switch terminals
Who View current logged-in user When you log in to a user remotely, another user is also displayed
Userdel Deletes a user
Userdel User name Deletes a user
Run the sudo userdel -r command to delete the user name and home directory of the specified user. /home -r command to delete the files in the home directory
Su – XXXX Log in to user XXXX. – Indicates that the directory will be changed
Example: sudo useradd XXXX -m sudo passwd XXXX Enter a new UNIX password: 123456 Enter a new UNIX password: 123456 passwd: the password has been updated successfully su XXXX password: 123456
pwd
/home/python
exit
pwd
/home/python
Path not switched
su – xxxx
pwd
/home/xxxx
Path switch
Sudo -s switch to root (super administrator)
Ifconfig Nic model (for example, ENS33) IP address (for example, 172.16.7.33) Changes the IP address of a NIC
~$Indicates the account of a common user. ~# Indicates the account of a user with root permission
File owner user group
CD ~ Jumps to the root directory
Sudo groupAdd YYY Creates or adds a group
Cat /etc/group You can check whether a group is created
Sudo groupdel YYY Deletes a group
Groupmod + Tab a few more times to view all group names so to summarize: there are two ways to view group names
cat /etc/group | grep sudo
sudo:x:27:python <—
cat/etc/group | grep adm
adm:x:4:syslog,python <—
lpadmin:x:113:python
Sudo usermod -a -g adm usermod -g adm usermod -g adm usermod -g adm usermod -g adm usermod -g adm usermod -g adm usermod -g adm usermod -g adm -a means add, -g means specify account specifies the account of sudo group
CHGRP The command for changing the owning group of a file is in the following format: CHGRP User group name file name
Chown Command format is as follows: chown Specifies the name of the file owner to which you want to change the file
Ll show that after the first column with the position of the ten letters The first position is used to identify files and folders – said is a normal file, d represents the folder, this is the way to really distinguish between files and folders, can’t use color to distinguish whether the file folder Behind every three letters for a group respectively for the following permissions: Permissions of file owners (U) Permissions of group members (G) Permissions of others (O)
RWX r means read in w means write x means executable r – – only read in r – x can read and execute but not write to band – indicates no permission
For example, on Ubuntu 14.04, the current PWD path is /home/sakura/ desktop drwxr-xr-x
RWX r-x r-x d indicates that this folder is a folder. RWX indicates that the owner of the folder has read, write and execute permissions. R-x indicates that the group of the folder has read and execute permissions but cannot write to the folder
Chmod u= RWX 1.py Changes the permissions of the owner of 1.py to readable, writable, and executable files
Chmod u=r,g=r,o=r 2.py Owner permission of the 1.py file Group permission Change the permissions of others to read only
The digital method:
r——->4
w——->2
x——->1
1 x
2 w
3 wx
4 r
5 rx
6 rw
7 rwx
Editor explanation
Sublime Text3 Ctrl+Shift+ T for quick copy
Move code select the code you want to move and then hit TAB (move to the right) hold Shift+ TAB (move to the left)
Vim editor explains
Press ESC to exit edit (insert) mode, enter command mode and then write: to enter last-line mode
Press uppercase I to insert at the beginning of the line Hold down I to enter the insert code format (writing text) to insert a character before the cursor
Press uppercase A at the end of the line to insert A: Insert A character after the cursor
Press upper case O to insert upper case O (lowercase letter) to enter edit mode for next line
Yy: copy the line where the cursor is located
P: paste
Dd: cut the line where the cursor is located 2dd: cut the line 2 down from the current cursor D: cut the line from the current cursor to the end of the line D0: cut the line from the current cursor to the beginning of the line x: Delete the current cursor (from the back). Only one of the commands will be deleted at a time. Dw: Delete the word at the beginning of the cursor, including the character where the cursor is located.
Code up and down around the key: H left J k l right
H: top of the current screen M: middle of the current screen L: bottom of the current screen
Ctrl+ F to scroll down a page of code Ctrl+ B to scroll up a page of code
Ctrl+ D to scroll down half a page of code Ctrl+ U to scroll up half a page of code
Line number -g moves to the specified line 20G: quickly locate the 20th line of code G: quickly return to the last line of the entire code gg: quickly return to the first line of the entire code
W: Jump one word backwards to the beginning of the next word b: Jump one word backwards to the beginning of the previous word
U: Undo the previous operation
Ctrl+ R: Reverse undo
Select a piece of V: move selected text by character V: move selected text by line Visual mode can cooperate with D, Y,>>,<< to achieve the text block delete (cut), copy, left and right movement
>> : moves code to the right (entire text) << : moves code to the left (entire text). : repeats the previous command
{: jump by segment move up code piece by piece} : jump by segment move down code piece by piece code is written in pieces, not next to each other
R: replaces a character. R: replaces the current cursor and subsequent characters
For example, if we search for /hello, we find 10 hello characters in the text. We can press n/ n to look up and down n: next n: previous
Replace command: In last-line mode, enter: :%s/ original string/new string to be replaced /g Example :%s/ hello/world/g To replace all hello characters in the text with world. This method replaces all original characters in the current text with new characters
In last-line mode, replace hello with world between lines 1 and 10 as follows: :1,10s/hello/world/g
In the last line mode, press :w to save, :q to exit, and :wq to save and exit
If the text is edited but not saved, just say :q and it says not saved. If we want to force out, type :q! That will do
In command mode, Shift+zz equals to :wq
After all master is the primary god la la la (^∇^*)